summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjorn Andersson <bjorn.andersson@sonymobile.com>2015-10-02 20:44:00 +0300
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2015-10-02 21:44:15 +0300
commit77fa05541cc02ab87e6d6e42254052b0cd30c3a4 (patch)
treefe3414c62114c54f2c15a4edbb12b4578bb1e672
parenta27b5e0a78c31b57fa5cceaec4415caeca2e50dd (diff)
downloadlinux-77fa05541cc02ab87e6d6e42254052b0cd30c3a4.tar.xz
Input: gpio_keys - don't report events on gpio failure
In the cases where the gpio chip fails to acquire the current state an error is reported back to gpio_keys. This is currently interpreted as if the line went high, which just confuses the developer. This patch introduces an error print in this case and skipps the reporting of a input event; to aid in debugging this issue. Reported-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/keyboard/gpio_keys.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 9d517ca7eb5a..bef317ff7352 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -341,8 +341,14 @@ static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
const struct gpio_keys_button *button = bdata->button;
struct input_dev *input = bdata->input;
unsigned int type = button->type ?: EV_KEY;
- int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;
+ int state = gpio_get_value_cansleep(button->gpio);
+ if (state < 0) {
+ dev_err(input->dev.parent, "failed to get gpio state\n");
+ return;
+ }
+
+ state = (state ? 1 : 0) ^ button->active_low;
if (type == EV_ABS) {
if (state)
input_event(input, type, button->code, button->value);