* [PATCH] input: gpio-keys: report error when invalid key number
@ 2015-08-24 12:07 Peng Fan
2015-08-24 17:48 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Peng Fan @ 2015-08-24 12:07 UTC (permalink / raw)
To: dmitry.torokhov
Cc: linus.walleij, linux-input, linux-kernel, van.freenix,
Alexander Stein, Tejun Heo, Andrew Morton, Wolfram Sang,
Fabio Estevam
When the input key number is not valid one of
'/sys/devices/soc0/gpio-keys/keys', need to report
an error, but not continue.
See the following example:
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 not
silence to give us an fake illusion that all is 'ok'.
Signed-off-by: Peng Fan <van.freenix@gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Alexander Stein <alexander.stein@systec-electronic.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
---
drivers/input/keyboard/gpio_keys.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index ddf4045..b98f3b4 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -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++) {
--
1.8.4.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] input: gpio-keys: report error when invalid key number
2015-08-24 12:07 [PATCH] input: gpio-keys: report error when invalid key number Peng Fan
@ 2015-08-24 17:48 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2015-08-24 17:48 UTC (permalink / raw)
To: Peng Fan
Cc: linus.walleij, linux-input, linux-kernel, Alexander Stein,
Tejun Heo, Andrew Morton, Wolfram Sang, Fabio Estevam
On Mon, Aug 24, 2015 at 08:07:44PM +0800, Peng Fan wrote:
> When the input key number is not valid one of
> '/sys/devices/soc0/gpio-keys/keys', need to report
> an error, but not continue.
>
> See the following example:
> 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 not
> silence to give us an fake illusion that all is 'ok'.
>
> Signed-off-by: Peng Fan <van.freenix@gmail.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Alexander Stein <alexander.stein@systec-electronic.com>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: Fabio Estevam <fabio.estevam@freescale.com>
Applied, thank you.
> ---
> drivers/input/keyboard/gpio_keys.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> index ddf4045..b98f3b4 100644
> --- a/drivers/input/keyboard/gpio_keys.c
> +++ b/drivers/input/keyboard/gpio_keys.c
> @@ -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++) {
> --
> 1.8.4.5
>
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-24 17:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-24 12:07 [PATCH] input: gpio-keys: report error when invalid key number Peng Fan
2015-08-24 17:48 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).