mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] gpiolib: unduplicate the pointer used for storing GPIO chip data
@ 2026-07-17 12:37 Bartosz Golaszewski
  0 siblings, 0 replies; only message in thread
From: Bartosz Golaszewski @ 2026-07-17 12:37 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

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.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/gpio/gpiolib.c | 4 ++--
 drivers/gpio/gpiolib.h | 2 --
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index c433a095907fe6ea0fb0a3e1234bcf1f37042cde..723953f909c6159218cad73ecb3ca0dc9acb4c29 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -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);
 
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
index 650a702741dfb938fbdf11db65a46ac85b6af512..cdf64785280e95e43f8d8b3645b93fb970347238 100644
--- a/drivers/gpio/gpiolib.h
+++ b/drivers/gpio/gpiolib.h
@@ -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,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-17 12:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-17 12:37 [PATCH] gpiolib: unduplicate the pointer used for storing GPIO chip data Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome