linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] [PATCH] input: export gpio-keys driven switch status over gpiolib sysfs
@ 2009-06-04 22:39 Janusz Krzysztofik
  2009-06-11  6:18 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Janusz Krzysztofik @ 2009-06-04 22:39 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input, linux-omap

This patch adds support for exporting status of GPIO switches, configured as
gpio-keys buttons that generate events of type EV_SW, over standard gpiolib
sysfs interface. That way, switch state can be easily accessed from userspace
via a modern sysfs API in addition to traditional ioclt API, without the need
for adding a new, usualy controversial entry to sysfs interface.

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
---
diff -up linux-2.6.30-rc5/drivers/input/keyboard/gpio_keys.c.orig linux-2.6.30-rc5/drivers/input/keyboard/gpio_keys.c
--- linux-2.6.30-rc5/drivers/input/keyboard/gpio_keys.c.orig	2009-03-24 00:12:14.000000000 +0100
+++ linux-2.6.30-rc5/drivers/input/keyboard/gpio_keys.c	2009-06-04 21:31:19.000000000 +0200
@@ -157,6 +157,19 @@ static int __devinit gpio_keys_probe(str
 			wakeup = 1;
 
 		input_set_capability(input, type, button->code);
+
+		/* For GPIO buttons generating events of type EV_SW
+		 * (ie switches), export their status
+		 * over gpiolib sysfs interface if configured */
+#ifdef CONFIG_GPIO_SYSFS
+		if (type == EV_SW) {
+			error = gpio_export(button->gpio, false);
+			if (error)
+				pr_warning("gpio-keys: "
+					"failed to export GPIO %d, error %d\n",
+					button->gpio, error);
+		}
+#endif
 	}
 
 	error = input_register_device(input);

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

end of thread, other threads:[~2009-06-12 11:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-04 22:39 [RFC] [PATCH] input: export gpio-keys driven switch status over gpiolib sysfs Janusz Krzysztofik
2009-06-11  6:18 ` Dmitry Torokhov
2009-06-12 11:19   ` Janusz Krzysztofik

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).