mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
To: Linus Walleij <linusw@kernel.org>, Bartosz Golaszewski <brgl@kernel.org>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Subject: [PATCH] gpiolib: unduplicate the pointer used for storing GPIO chip data
Date: Fri, 17 Jul 2026 14:37:31 +0200	[thread overview]
Message-ID: <20260717-gpio-dev-drvdata-v1-1-401b0cbd4d70@oss.qualcomm.com> (raw)

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>


             reply	other threads:[~2026-07-17 12:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17 12:37 Bartosz Golaszewski [this message]
2026-07-20 10:11 ` Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260717-gpio-dev-drvdata-v1-1-401b0cbd4d70@oss.qualcomm.com \
    --to=bartosz.golaszewski@oss.qualcomm.com \
    --cc=brgl@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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