[PATCH] input_ gpio_keys: scan gpio state at probe time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



gpio_keys.c registers interrupts at both edges of all given gpio lines
and updates the input device when they change. However, the driver fails
to check the current line state at probe time.

Signed-off-by: Daniel Mack <daniel@xxxxxxxx>
Cc: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
Cc: Jani Nikula <ext-jani.1.nikula@xxxxxxxxx>
Cc: Mike Rapoport <mike@xxxxxxxxxxxxxx>
---
 drivers/input/keyboard/gpio_keys.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 77d1309..cb5f862 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -171,6 +171,18 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
 		goto fail2;
 	}
 
+	/* get current state of buttons */
+	for (i = 0; i < pdata->nbuttons; i++) {
+		struct gpio_keys_button *button = &pdata->buttons[i];
+		int state = !!gpio_get_value(button->gpio) ^ button->active_low;
+
+		if (state) {
+			unsigned int type = button->type ?: EV_KEY;
+			input_event(input, type, button->code, !!state);
+			input_sync(input);
+		}
+	}
+
 	device_init_wakeup(&pdev->dev, wakeup);
 
 	return 0;
-- 
1.6.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux