[RFC] [PATCH] input: export gpio-keys driven switch status over gpiolib sysfs

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

 



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@xxxxxxxxxxxx>
---
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);
--
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