linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] input: gpio_keys: Don't report events on gpio failure
@ 2015-07-28  1:50 Bjorn Andersson
  2015-07-28 21:00 ` Dmitry Torokhov
  2015-10-02 10:34 ` Linus Walleij
  0 siblings, 2 replies; 11+ messages in thread
From: Bjorn Andersson @ 2015-07-28  1:50 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, linux-kernel, John Stultz, Linus Walleij

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>
---
 drivers/input/keyboard/gpio_keys.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index ddf4045de084..3ce3298ac09e 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -336,8 +336,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);
-- 
1.8.2.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-10-02 17:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-28  1:50 [PATCH] input: gpio_keys: Don't report events on gpio failure Bjorn Andersson
2015-07-28 21:00 ` Dmitry Torokhov
2015-08-10 22:41   ` Bjorn Andersson
2015-08-13 13:06     ` Linus Walleij
2015-08-17  6:59       ` Alexandre Courbot
2015-08-17 19:34         ` Bjorn Andersson
2015-08-31  4:51           ` Alexandre Courbot
2015-08-26  7:34         ` Linus Walleij
2015-09-21  4:19   ` Bjorn Andersson
2015-10-02 10:34 ` Linus Walleij
2015-10-02 17:44   ` 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).