Skip to content

Commit 9815a42

Browse files
Bartosz GolaszewskiJiri Kosina
authored andcommitted
HID: mcp2200: use new line value setter callbacks
struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jiri Kosina <jkosina@suse.com>
1 parent 6485543 commit 9815a42

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

drivers/hid/hid-mcp2200.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ static int mcp_cmd_read_all(struct mcp2200 *mcp)
127127
return mcp->status;
128128
}
129129

130-
static void mcp_set_multiple(struct gpio_chip *gc, unsigned long *mask,
131-
unsigned long *bits)
130+
static int mcp_set_multiple(struct gpio_chip *gc, unsigned long *mask,
131+
unsigned long *bits)
132132
{
133133
struct mcp2200 *mcp = gpiochip_get_data(gc);
134134
u8 value;
@@ -150,16 +150,20 @@ static void mcp_set_multiple(struct gpio_chip *gc, unsigned long *mask,
150150

151151
if (status == sizeof(struct mcp_set_clear_outputs))
152152
mcp->gpio_val = value;
153+
else
154+
status = -EIO;
153155

154156
mutex_unlock(&mcp->lock);
157+
158+
return status;
155159
}
156160

157-
static void mcp_set(struct gpio_chip *gc, unsigned int gpio_nr, int value)
161+
static int mcp_set(struct gpio_chip *gc, unsigned int gpio_nr, int value)
158162
{
159163
unsigned long mask = 1 << gpio_nr;
160164
unsigned long bmap_value = value << gpio_nr;
161165

162-
mcp_set_multiple(gc, &mask, &bmap_value);
166+
return mcp_set_multiple(gc, &mask, &bmap_value);
163167
}
164168

165169
static int mcp_get_multiple(struct gpio_chip *gc, unsigned long *mask,
@@ -263,9 +267,10 @@ static int mcp_direction_output(struct gpio_chip *gc, unsigned int gpio_nr,
263267
bmap_value = value << gpio_nr;
264268

265269
ret = mcp_set_direction(gc, gpio_nr, MCP2200_DIR_OUT);
266-
if (!ret)
267-
mcp_set_multiple(gc, &mask, &bmap_value);
268-
return ret;
270+
if (ret)
271+
return ret;
272+
273+
return mcp_set_multiple(gc, &mask, &bmap_value);
269274
}
270275

271276
static const struct gpio_chip template_chip = {
@@ -274,8 +279,8 @@ static const struct gpio_chip template_chip = {
274279
.get_direction = mcp_get_direction,
275280
.direction_input = mcp_direction_input,
276281
.direction_output = mcp_direction_output,
277-
.set = mcp_set,
278-
.set_multiple = mcp_set_multiple,
282+
.set_rv = mcp_set,
283+
.set_multiple_rv = mcp_set_multiple,
279284
.get = mcp_get,
280285
.get_multiple = mcp_get_multiple,
281286
.base = -1,

0 commit comments

Comments
 (0)