[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260116081036.352286-7-tzungbi@kernel.org>
Date: Fri, 16 Jan 2026 08:10:19 +0000
From: Tzung-Bi Shih <tzungbi@...nel.org>
To: Benson Leung <bleung@...omium.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J . Wysocki" <rafael@...nel.org>,
Danilo Krummrich <dakr@...nel.org>,
Bartosz Golaszewski <brgl@...ev.pl>,
Linus Walleij <linusw@...nel.org>
Cc: Jonathan Corbet <corbet@....net>,
Shuah Khan <shuah@...nel.org>,
linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org,
chrome-platform@...ts.linux.dev,
linux-kselftest@...r.kernel.org,
tzungbi@...nel.org,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Wolfram Sang <wsa+renesas@...g-engineering.com>,
Simona Vetter <simona.vetter@...ll.ch>,
Dan Williams <dan.j.williams@...el.com>,
Jason Gunthorpe <jgg@...dia.com>,
linux-gpio@...r.kernel.org
Subject: [PATCH 06/23] gpiolib: Access `gpio_bus_type` in gpiochip_setup_dev()
To make the intent clear, access `gpio_bus_type` only when it's ready in
gpiochip_setup_dev().
Signed-off-by: Tzung-Bi Shih <tzungbi@...nel.org>
---
drivers/gpio/gpiolib.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 6fac59716405..3242644eebc6 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -902,6 +902,8 @@ static int gpiochip_setup_dev(struct gpio_device *gdev)
struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev);
int ret;
+ gdev->dev.bus = &gpio_bus_type;
+
/*
* If fwnode doesn't belong to another device, it's safe to clear its
* initialized flag.
@@ -1096,7 +1098,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
device_initialize(&gdev->dev);
/* From this point, the .release() function cleans up gdev->dev */
gdev->dev.type = &gpio_dev_type;
- gdev->dev.bus = &gpio_bus_type;
gdev->dev.parent = gc->parent;
device_set_node(&gdev->dev, gpiochip_choose_fwnode(gc));
@@ -1217,8 +1218,8 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
* we get a device node entry in sysfs under
* /sys/bus/gpio/devices/gpiochipN/dev that can be used for
* coldplug of device nodes and other udev business.
- * We can do this only if gpiolib has been initialized.
- * Otherwise, defer until later.
+ * We can do this only if gpiolib has been initialized
+ * (i.e., `gpio_bus_type` is ready). Otherwise, defer until later.
*/
if (gpiolib_initialized) {
ret = gpiochip_setup_dev(gdev);
--
2.52.0.457.g6b5491de43-goog
Powered by blists - more mailing lists