summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.h
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2015-10-21 09:29:53 -0400
committerLinus Walleij <linus.walleij@linaro.org>2016-02-09 05:09:35 -0500
commit3c702e9987e261042a07e43460a8148be254412e (patch)
treed95bdf248a27344606cee7eb9297d892db5b429b /drivers/gpio/gpiolib.h
parent34ffd85d9c46cde3dc987cac82bff370a937ac4b (diff)
gpio: add a userspace chardev ABI for GPIOs
A new chardev that is to be used for userspace GPIO access is added in this patch. It is intended to gradually replace the horribly broken sysfs ABI. Using a chardev has many upsides: - All operations are per-gpiochip, which is the actual device underlying the GPIOs, making us tie in to the kernel device model properly. - Hotpluggable GPIO controllers can come and go, as this kind of problem has been know to userspace for character devices since ages, and if a gpiochip handle is held in userspace we know we will break something, whereas the sysfs is stateless. - The one-value-per-file rule of sysfs is really hard to maintain when you want to twist more than one knob at a time, for example have in-kernel APIs to switch several GPIO lines at the same time, and this will be possible to do with a single ioctl() from userspace, saving a lot of context switching. We also need to add a new bus type for GPIO. This is necessary for example for userspace coldplug, where sysfs is traversed to find the boot-time device nodes and create the character devices in /dev. This new chardev ABI is *non* *optional* and can be counted on to be present in the future, emphasizing the preference of this ABI. The ABI only implements one single ioctl() to get the name and number of GPIO lines of a chip. Even this is debatable: see it as a minimal example for review. This ABI shall be ruthlessly reviewed and etched in stone. The old /sys/class/gpio is still optional to compile in, but will be deprecated. Unique device IDs are created using IDR, which is overkill and insanely scalable, but also well tested. Cc: Johan Hovold <johan@kernel.org> Cc: Michael Welling <mwelling@ieee.org> Cc: Markus Pargmann <mpa@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.h')
-rw-r--r--drivers/gpio/gpiolib.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
index 3f329c922f5b..1524ba0ca99d 100644
--- a/drivers/gpio/gpiolib.h
+++ b/drivers/gpio/gpiolib.h
@@ -26,6 +26,7 @@ struct acpi_device;
26 * struct gpio_device - internal state container for GPIO devices 26 * struct gpio_device - internal state container for GPIO devices
27 * @id: numerical ID number for the GPIO chip 27 * @id: numerical ID number for the GPIO chip
28 * @dev: the GPIO device struct 28 * @dev: the GPIO device struct
29 * @chrdev: character device for the GPIO device
29 * @owner: helps prevent removal of modules exporting active GPIOs 30 * @owner: helps prevent removal of modules exporting active GPIOs
30 * @chip: pointer to the corresponding gpiochip, holding static 31 * @chip: pointer to the corresponding gpiochip, holding static
31 * data for this device 32 * data for this device
@@ -39,6 +40,7 @@ struct acpi_device;
39struct gpio_device { 40struct gpio_device {
40 int id; 41 int id;
41 struct device dev; 42 struct device dev;
43 struct cdev chrdev;
42 struct module *owner; 44 struct module *owner;
43 struct gpio_chip *chip; 45 struct gpio_chip *chip;
44 struct list_head list; 46 struct list_head list;