Skip to content

Commit

Permalink
HID: cp2112: fix broken gpio_direction_input callback
Browse files Browse the repository at this point in the history
When everything goes smoothly, ret is set to 0 which makes the function
to return EIO error.

Fixes: 8e9faa1 ("HID: cp2112: fix gpio-callback error handling")
Signed-off-by: Sébastien Szymanski <sebastien.szymanski@armadeus.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Sébastien Szymanski authored and Jiri Kosina committed Nov 10, 2017
1 parent ce4dd82 commit 7da85fb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/hid/hid-cp2112.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
HID_REQ_GET_REPORT);
if (ret != CP2112_GPIO_CONFIG_LENGTH) {
hid_err(hdev, "error requesting GPIO config: %d\n", ret);
if (ret >= 0)
ret = -EIO;
goto exit;
}

Expand All @@ -205,16 +207,18 @@ static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
CP2112_GPIO_CONFIG_LENGTH, HID_FEATURE_REPORT,
HID_REQ_SET_REPORT);
if (ret < 0) {
if (ret != CP2112_GPIO_CONFIG_LENGTH) {
hid_err(hdev, "error setting GPIO config: %d\n", ret);
if (ret >= 0)
ret = -EIO;
goto exit;
}

ret = 0;

exit:
mutex_unlock(&dev->lock);
return ret < 0 ? ret : -EIO;
return ret;
}

static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
Expand Down

0 comments on commit 7da85fb

Please sign in to comment.