gpiolib: unduplicate the pointer used for storing GPIO chip data
PATCH 1/1 gpiolib: unduplicate the pointer used for storing GPIO chip data
We currently carry a dedicated pointer inside struct gpio_device for storing the driver data. However: struct gpio_device already embeds a struct device which is not accessed by anyone other than GPIO core and also has a dedicated driver data pointer which is currently unused. Convert gpiochip_set/get_data() to calling dev_set/get_drvdata() on the GPIO device's struct device and remove the duplicated pointer from struct gpio_device.
--- drivers/gpio/gpiolib.c | 4 ++-- drivers/gpio/gpiolib.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/gpio/gpiolib.c +2 -2
@@ -1103,7 +1103,7 @@ static void gpiochip_setup_devs(void)static void gpiochip_set_data (struct gpio_chip *gc,void *data) { - gc->gpiodev->data = data; +dev_set_drvdata (&gc->gpiodev->dev, data); }/**
@@ -1115,7 +1115,7 @@ static void gpiochip_set_data(struct gpio_chip *gc, void *data)*/ void *gpiochip_get_data (struct gpio_chip *gc) { -return gc->gpiodev->data; +return dev_get_drvdata (&gc->gpiodev->dev); }EXPORT_SYMBOL_GPL (gpiochip_get_data);
drivers/gpio/gpiolib.h +0 -2
@@ -45,7 +45,6 @@ struct fwnode_handle;* at device creation time. * @label: a descriptive name for the GPIO device, such as the part number * or name of the IP component in a System on Chip. -* @data: per-instance data assigned by the driver * @list: links gpio_device:s together for traversal * @line_state_notifier: used to notify subscribers about lines being * requested, released or reconfigured
@@ -75,7 +74,6 @@ struct gpio_device {u16 ngpio;bool can_sleep;const char *label; -void *data;struct list_head list;struct raw_notifier_head line_state_notifier;rwlock_t line_state_lock;
---
base-commit: 1a1757b76427f6201bfe0bf1bea9f7574f332a93
change-id: 20260717-gpio-dev-drvdata-005219c06a25
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>
Bartosz Golaszewski
maintainerQuoted 10 lines · Bartosz Golaszewski
We currently carry a dedicated pointer inside struct
gpio_devicefor storing the driver data. However: structgpio_devicealready embeds a struct device which is not accessed by anyone other than GPIO core and also has a dedicated driver data pointer which is currently unused. Convert gpiochip_set/get_data() to calling dev_set/get_drvdata() on the GPIO device's struct device and remove the duplicated pointer from structgpio_device.Signed-off-by Bartosz Golaszewski <[email protected]>---
Sashiko is right, this will break sysfs unbinding so let's drop this.
Bart