From: Miao Wang via B4 Relay <devnull+shankerwangmiao.gmail.com@kernel.org>
To: Binbin Zhou <zhoubinbin@loongson.cn>,
Chong Qiao <qiaochong@loongson.cn>, Lee Jones <lee@kernel.org>,
Huacai Chen <chenhuacai@kernel.org>,
Corey Minyard <corey@minyard.net>,
Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>
Cc: Xi Ruoyao <xry111@xry111.site>, WANG Xuerui <kernel@xen0n.name>,
Yinbo Zhu <zhuyinbo@loongson.cn>,
Jiaxun Yang <jiaxun.yang@flygoat.com>,
mfd@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-gpio@vger.kernel.org,
openipmi-developer@lists.sourceforge.net,
Miao Wang <shankerwangmiao@gmail.com>,
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Subject: [PATCH RFC v9 6/8] gpiolib: add gpio_device_get_fwnode() helper
Date: Tue, 11 Aug 2026 16:07:30 +0800 [thread overview]
Message-ID: <20260811-ls2kbmc-mod-v9-6-4fa9a5584406@gmail.com> (raw)
In-Reply-To: <20260811-ls2kbmc-mod-v9-0-4fa9a5584406@gmail.com>
From: Miao Wang <shankerwangmiao@gmail.com>
Add a helper function to retrieve the fwnode associated with a
struct gpio_device. This is useful for drivers that need to access the
fwnode of a GPIO device for various purposes, such as creating software
nodes or handling GPIOs in a platform-specific manner.
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
---
drivers/gpio/gpiolib.c | 17 +++++++++++++++++
include/linux/gpio/driver.h | 1 +
2 files changed, 18 insertions(+)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index e5fb60111151f6de20b424551acf213fb058e190..bf3e7f67a90f576d137fd7261b0afc741eea3245 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1583,6 +1583,23 @@ struct device *gpio_device_to_device(struct gpio_device *gdev)
}
EXPORT_SYMBOL_GPL(gpio_device_to_device);
+/**
+ * gpio_device_get_fwnode() - Retrieve the fwnode of the underlying device.
+ * @gdev: GPIO device for which to return the fwnode.
+ *
+ * This does not increase the reference count of the GPIO device nor the
+ * returned fwnode handle, since the caller is expected to hold a reference
+ * to the GPIO device, and fwnode_handle_put() is thus not needed.
+ *
+ * Returns:
+ * The fwnode handle of the underlying device.
+ */
+struct fwnode_handle *gpio_device_get_fwnode(struct gpio_device *gdev)
+{
+ return dev_fwnode(gpio_device_to_device(gdev));
+}
+EXPORT_SYMBOL_GPL(gpio_device_get_fwnode);
+
#ifdef CONFIG_GPIOLIB_IRQCHIP
/*
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 17511434ed077dde8807bd7630c342e146e5230b..4dd9120707ec72a978f5f916cc5473a91b65d2b9 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -641,6 +641,7 @@ DEFINE_FREE(gpio_device_put, struct gpio_device *,
if (!IS_ERR_OR_NULL(_T)) gpio_device_put(_T))
struct device *gpio_device_to_device(struct gpio_device *gdev);
+struct fwnode_handle *gpio_device_get_fwnode(struct gpio_device *gdev);
bool gpiochip_line_is_irq(struct gpio_chip *gc, unsigned int offset);
int gpiochip_reqres_irq(struct gpio_chip *gc, unsigned int offset);
--
2.49.0
WARNING: multiple messages have this Message-ID (diff)
From: Miao Wang <shankerwangmiao@gmail.com>
To: Binbin Zhou <zhoubinbin@loongson.cn>,
Chong Qiao <qiaochong@loongson.cn>, Lee Jones <lee@kernel.org>,
Huacai Chen <chenhuacai@kernel.org>,
Corey Minyard <corey@minyard.net>,
Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>
Cc: Xi Ruoyao <xry111@xry111.site>, WANG Xuerui <kernel@xen0n.name>,
Yinbo Zhu <zhuyinbo@loongson.cn>,
Jiaxun Yang <jiaxun.yang@flygoat.com>,
mfd@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-gpio@vger.kernel.org,
openipmi-developer@lists.sourceforge.net,
Miao Wang <shankerwangmiao@gmail.com>,
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Subject: [PATCH RFC v9 6/8] gpiolib: add gpio_device_get_fwnode() helper
Date: Tue, 11 Aug 2026 16:07:30 +0800 [thread overview]
Message-ID: <20260811-ls2kbmc-mod-v9-6-4fa9a5584406@gmail.com> (raw)
In-Reply-To: <20260811-ls2kbmc-mod-v9-0-4fa9a5584406@gmail.com>
Add a helper function to retrieve the fwnode associated with a
struct gpio_device. This is useful for drivers that need to access the
fwnode of a GPIO device for various purposes, such as creating software
nodes or handling GPIOs in a platform-specific manner.
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
---
drivers/gpio/gpiolib.c | 17 +++++++++++++++++
include/linux/gpio/driver.h | 1 +
2 files changed, 18 insertions(+)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index e5fb60111151f6de20b424551acf213fb058e190..bf3e7f67a90f576d137fd7261b0afc741eea3245 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1583,6 +1583,23 @@ struct device *gpio_device_to_device(struct gpio_device *gdev)
}
EXPORT_SYMBOL_GPL(gpio_device_to_device);
+/**
+ * gpio_device_get_fwnode() - Retrieve the fwnode of the underlying device.
+ * @gdev: GPIO device for which to return the fwnode.
+ *
+ * This does not increase the reference count of the GPIO device nor the
+ * returned fwnode handle, since the caller is expected to hold a reference
+ * to the GPIO device, and fwnode_handle_put() is thus not needed.
+ *
+ * Returns:
+ * The fwnode handle of the underlying device.
+ */
+struct fwnode_handle *gpio_device_get_fwnode(struct gpio_device *gdev)
+{
+ return dev_fwnode(gpio_device_to_device(gdev));
+}
+EXPORT_SYMBOL_GPL(gpio_device_get_fwnode);
+
#ifdef CONFIG_GPIOLIB_IRQCHIP
/*
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 17511434ed077dde8807bd7630c342e146e5230b..4dd9120707ec72a978f5f916cc5473a91b65d2b9 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -641,6 +641,7 @@ DEFINE_FREE(gpio_device_put, struct gpio_device *,
if (!IS_ERR_OR_NULL(_T)) gpio_device_put(_T))
struct device *gpio_device_to_device(struct gpio_device *gdev);
+struct fwnode_handle *gpio_device_get_fwnode(struct gpio_device *gdev);
bool gpiochip_line_is_irq(struct gpio_chip *gc, unsigned int offset);
int gpiochip_reqres_irq(struct gpio_chip *gc, unsigned int offset);
--
2.49.0
next prev parent reply other threads:[~2026-08-11 8:07 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 8:07 [PATCH RFC v9 0/8] mfd: ls2kbmc: multiple fixes for this driver Miao Wang via B4 Relay
2026-08-11 8:07 ` Miao Wang
2026-08-11 8:07 ` [PATCH RFC v9 1/8] mfd: ls2kbmc: Make a copy when parsing mode string Miao Wang via B4 Relay
2026-08-11 8:07 ` Miao Wang
2026-08-11 8:07 ` [PATCH RFC v9 2/8] mfd: ls2kbmc: Sanity check for the connected pci port Miao Wang via B4 Relay
2026-08-11 8:07 ` Miao Wang
2026-08-11 8:07 ` [PATCH RFC v9 3/8] mfd: ls2kbmc: Redraw using exported functions Miao Wang via B4 Relay
2026-08-11 8:07 ` Miao Wang
2026-08-11 8:07 ` [PATCH RFC v9 4/8] mfd: ls2kbmc: Cancel the work queue on removal Miao Wang via B4 Relay
2026-08-11 8:07 ` Miao Wang
2026-08-11 8:07 ` [PATCH RFC v9 5/8] ipmi: ls2k: adjust dependency to its mfd driver Miao Wang via B4 Relay
2026-08-11 8:07 ` Miao Wang
2026-08-11 8:07 ` Miao Wang via B4 Relay [this message]
2026-08-11 8:07 ` [PATCH RFC v9 6/8] gpiolib: add gpio_device_get_fwnode() helper Miao Wang
2026-08-11 8:07 ` [PATCH RFC v9 7/8] mfd: ls2kbmc: Capture the reset event of BMC through GPIO Miao Wang via B4 Relay
2026-08-11 8:07 ` Miao Wang
2026-08-11 8:07 ` [PATCH RFC v9 8/8] mfd: ls2kbmc: Able to be compiled as a module Miao Wang via B4 Relay
2026-08-11 8:07 ` Miao Wang
2026-08-11 13:47 ` [PATCH RFC v9 0/8] mfd: ls2kbmc: multiple fixes for this driver Bartosz Golaszewski
2026-08-11 14:12 ` Miao Wang
2026-08-13 8:54 ` Lee Jones
2026-08-13 12:09 ` 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=20260811-ls2kbmc-mod-v9-6-4fa9a5584406@gmail.com \
--to=devnull+shankerwangmiao.gmail.com@kernel.org \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=brgl@kernel.org \
--cc=chenhuacai@kernel.org \
--cc=corey@minyard.net \
--cc=jiaxun.yang@flygoat.com \
--cc=kernel@xen0n.name \
--cc=lee@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=openipmi-developer@lists.sourceforge.net \
--cc=qiaochong@loongson.cn \
--cc=shankerwangmiao@gmail.com \
--cc=xry111@xry111.site \
--cc=zhoubinbin@loongson.cn \
--cc=zhuyinbo@loongson.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.