On Wed, Dec 09, 2015 at 02:08:35PM +0100, Linus Walleij wrote: > This removes the use of container_of() constructions from *all* > GPIO drivers in the kernel. It is done by instead adding an > optional void *data pointer to the struct gpio_chip and an > accessor function, gpiochip_get_data() to get it from a driver. > > WHY? > > Because we want to have a proper userspace ABI for GPIO chips, > which involves using a character device that the user opens > and closes. While the character device is open, the underlying > kernel objects must not go away. > > Currently the GPIO drivers keep their state in the struct > gpio_chip, and that is often allocated by the drivers, very > often as a part of a containing per-instance state container > struct for the driver: > > struct foo_state { > struct gpio_chip chip; <- OMG my state is there > }; > > Drivers cannot allocate and manage this state: if a user has the > character device open, the objects allocated must stay around > even if the driver goes away. Instead drivers need to pass a > descriptor to the GPIO core, and then the core should allocate > and manage the lifecycle of things related to the device, such > as the chardev itself or the struct device related to the GPIO > device. Yes, but it does not mean that the object that is being maintained by the subsystem and that us attached to character device needs to be gpio_chip itself. You can have something like struct gpio_chip_chardev { struct cdev chardev; struct gpio_chip *chip; bool dead; }; struct gpio_chip { ... struct gpio_chip_chardev *chardev; ... }; You alloctae the new structure when you register/export gpio chip in gpio subsystem core and leave all the individual drivers alone. Thanks. -- Dmitry -- 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