mirror of
https://github.com/torvalds/linux.git
synced 2026-06-05 13:06:59 +02:00
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>
This commit is contained in:
parent
4c49d905ca
commit
6485543488
|
|
@ -215,7 +215,7 @@ static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cp2112_gpio_set_unlocked(struct cp2112_device *dev,
|
static int cp2112_gpio_set_unlocked(struct cp2112_device *dev,
|
||||||
unsigned int offset, int value)
|
unsigned int offset, int value)
|
||||||
{
|
{
|
||||||
struct hid_device *hdev = dev->hdev;
|
struct hid_device *hdev = dev->hdev;
|
||||||
|
|
@ -231,16 +231,18 @@ static void cp2112_gpio_set_unlocked(struct cp2112_device *dev,
|
||||||
HID_REQ_SET_REPORT);
|
HID_REQ_SET_REPORT);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
hid_err(hdev, "error setting GPIO values: %d\n", ret);
|
hid_err(hdev, "error setting GPIO values: %d\n", ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cp2112_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
static int cp2112_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||||
int value)
|
int value)
|
||||||
{
|
{
|
||||||
struct cp2112_device *dev = gpiochip_get_data(chip);
|
struct cp2112_device *dev = gpiochip_get_data(chip);
|
||||||
|
|
||||||
guard(mutex)(&dev->lock);
|
guard(mutex)(&dev->lock);
|
||||||
|
|
||||||
cp2112_gpio_set_unlocked(dev, offset, value);
|
return cp2112_gpio_set_unlocked(dev, offset, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cp2112_gpio_get_all(struct gpio_chip *chip)
|
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)
|
||||||
dev->gc.label = "cp2112_gpio";
|
dev->gc.label = "cp2112_gpio";
|
||||||
dev->gc.direction_input = cp2112_gpio_direction_input;
|
dev->gc.direction_input = cp2112_gpio_direction_input;
|
||||||
dev->gc.direction_output = cp2112_gpio_direction_output;
|
dev->gc.direction_output = cp2112_gpio_direction_output;
|
||||||
dev->gc.set = cp2112_gpio_set;
|
dev->gc.set_rv = cp2112_gpio_set;
|
||||||
dev->gc.get = cp2112_gpio_get;
|
dev->gc.get = cp2112_gpio_get;
|
||||||
dev->gc.base = -1;
|
dev->gc.base = -1;
|
||||||
dev->gc.ngpio = CP2112_GPIO_MAX_GPIO;
|
dev->gc.ngpio = CP2112_GPIO_MAX_GPIO;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user