Skip to content

Commit 6485543

Browse files
Bartosz GolaszewskiJiri Kosina
authored andcommitted
HID: cp2112: 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 4c49d90 commit 6485543

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/hid/hid-cp2112.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
215215
return 0;
216216
}
217217

218-
static void cp2112_gpio_set_unlocked(struct cp2112_device *dev,
219-
unsigned int offset, int value)
218+
static int cp2112_gpio_set_unlocked(struct cp2112_device *dev,
219+
unsigned int offset, int value)
220220
{
221221
struct hid_device *hdev = dev->hdev;
222222
u8 *buf = dev->in_out_buffer;
@@ -231,16 +231,18 @@ static void cp2112_gpio_set_unlocked(struct cp2112_device *dev,
231231
HID_REQ_SET_REPORT);
232232
if (ret < 0)
233233
hid_err(hdev, "error setting GPIO values: %d\n", ret);
234+
235+
return ret;
234236
}
235237

236-
static void cp2112_gpio_set(struct gpio_chip *chip, unsigned int offset,
237-
int value)
238+
static int cp2112_gpio_set(struct gpio_chip *chip, unsigned int offset,
239+
int value)
238240
{
239241
struct cp2112_device *dev = gpiochip_get_data(chip);
240242

241243
guard(mutex)(&dev->lock);
242244

243-
cp2112_gpio_set_unlocked(dev, offset, value);
245+
return cp2112_gpio_set_unlocked(dev, offset, value);
244246
}
245247

246248
static int cp2112_gpio_get_all(struct gpio_chip *chip)
@@ -1286,7 +1288,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
12861288
dev->gc.label = "cp2112_gpio";
12871289
dev->gc.direction_input = cp2112_gpio_direction_input;
12881290
dev->gc.direction_output = cp2112_gpio_direction_output;
1289-
dev->gc.set = cp2112_gpio_set;
1291+
dev->gc.set_rv = cp2112_gpio_set;
12901292
dev->gc.get = cp2112_gpio_get;
12911293
dev->gc.base = -1;
12921294
dev->gc.ngpio = CP2112_GPIO_MAX_GPIO;

0 commit comments

Comments
 (0)