]> git.baikalelectronics.ru Git - kernel.git/commit
gpio: make the gpiochip a real device
authorLinus Walleij <linus.walleij@linaro.org>
Tue, 20 Oct 2015 09:10:38 +0000 (11:10 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 9 Feb 2016 10:03:53 +0000 (11:03 +0100)
commitfe5a97fa12cac357d368a82b8b64829f4ba32162
tree5bc008bdf99c6fe651cf4c4d2384e48b072f8df4
parentd7e15052ecc9ac4f938d1d7432c1d120a2711a7e
gpio: make the gpiochip a real device

GPIO chips have been around for years, but were never real devices,
instead they were piggy-backing on a parent device (such as a
platform_device or amba_device) but this was always optional.
GPIO chips could also exist without any device at all, with its
struct device *parent (ex *dev) pointer being set to null.

When sysfs was in use, a mock device would be created, with the
optional parent assigned, or just floating orphaned with NULL
as parent.

If sysfs is active, it will use this device as parent.

We now create a gpio_device struct containing a real
struct device and move the subsystem over to using that. The
list of struct gpio_chip:s is augmented to hold struct
gpio_device:s and we find gpio_chips:s by first looking up
the struct gpio_device.

The struct gpio_device is designed to stay around even if the
gpio_chip is removed, so as to satisfy users in userspace
that need a backing data structure to hold the state of the
session initiated with e.g. a character device even if there is
no physical chip anymore.

From this point on, gpiochips are devices.

Cc: Johan Hovold <johan@kernel.org>
Cc: Michael Welling <mwelling@ieee.org>
Cc: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib-sysfs.c
drivers/gpio/gpiolib.c
drivers/gpio/gpiolib.h
include/linux/gpio/driver.h