From: Peng Fan <van.freenix@gmail.com>
To: dmitry.torokhov@gmail.com
Cc: linus.walleij@linaro.org, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org, van.freenix@gmail.com,
Alexander Stein <alexander.stein@systec-electronic.com>,
Tejun Heo <tj@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Wolfram Sang <wsa@the-dreams.de>,
Fabio Estevam <fabio.estevam@freescale.com>
Subject: [PATCH] input: gpio-keys: report error when invalid key number
Date: Mon, 24 Aug 2015 20:07:44 +0800 [thread overview]
Message-ID: <1440418064-15971-1-git-send-email-van.freenix@gmail.com> (raw)
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
next reply other threads:[~2015-08-24 12:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-24 12:07 Peng Fan [this message]
2015-08-24 17:48 ` [PATCH] input: gpio-keys: report error when invalid key number Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1440418064-15971-1-git-send-email-van.freenix@gmail.com \
--to=van.freenix@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.stein@systec-electronic.com \
--cc=dmitry.torokhov@gmail.com \
--cc=fabio.estevam@freescale.com \
--cc=linus.walleij@linaro.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
--cc=wsa@the-dreams.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox