Skip to content

Commit

Permalink
Input: gpio-keys - report error when disabling unsupported key
Browse files Browse the repository at this point in the history
When trying to disable a key that is not supported by the device we should
report error, not do nothing and report success:

root@yocto:/sys/devices/soc0/gpio-keys# cat keys
114-116
root@yocto:/sys/devices/soc0/gpio-keys# echo 77 > keys
root@yocto:/sys/devices/soc0/gpio-keys#

We want 'echo 77 > keys' to report an error, but silence to give us an
illusion that all is 'ok'.

Signed-off-by: Peng Fan <van.freenix@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
  • Loading branch information
Peng Fan authored and Dmitry Torokhov committed Aug 24, 2015
1 parent ff89de6 commit 4ea14a5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/input/keyboard/gpio_keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata,
}
}

if (i == ddata->pdata->nbuttons) {
error = -EINVAL;
goto out;
}

mutex_lock(&ddata->disable_lock);

for (i = 0; i < ddata->pdata->nbuttons; i++) {
Expand Down

0 comments on commit 4ea14a5

Please sign in to comment.