diff mbox

input_ gpio_keys: scan gpio state at probe time

Message ID 1259146416-6713-1-git-send-email-daniel@caiaq.de
State New, archived
Headers show

Commit Message

Daniel Mack Nov. 25, 2009, 10:53 a.m. UTC
None
diff mbox

Patch

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;