Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Revert "gpio: Access `gpio_bus_type` in gpiochip_setup_dev()"

This reverts commit cc11f4ef666fbca02c8a2f11d0184d57e6b75579.

Commit cc11f4ef666f ("gpio: Access `gpio_bus_type` in
gpiochip_setup_dev()") moved the bus type assignment from
gpiochip_add_data_with_key() to gpiochip_setup_dev().

This change introduced a bug where dev_printk() and friends might access
the bus name after gpiochip_add_data_with_key() but before
gpiochip_setup_dev() has run. In this window, the bus type is not yet
initialized, leading to empty bus names in logs.

Move the bus type assignment back to gpiochip_add_data_with_key() to
ensure the bus name is available before any potential users like
dev_printk().

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Closes: https://lore.kernel.org/all/CAMuHMdU0Xb=Moca5LUex+VxyHQa2-uYJgYf4hzHiSEjDCQQT=Q@mail.gmail.com/
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://patch.msgid.link/20260313054112.1248074-1-tzungbi@kernel.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

authored by

Tzung-Bi Shih and committed by
Bartosz Golaszewski
3518fd4c 7673e4c7

+3 -4
+3 -4
drivers/gpio/gpiolib.c
··· 908 908 struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev); 909 909 int ret; 910 910 911 - gdev->dev.bus = &gpio_bus_type; 912 - 913 911 /* 914 912 * If fwnode doesn't belong to another device, it's safe to clear its 915 913 * initialized flag. ··· 1158 1160 * then make sure they get free():ed there. 1159 1161 */ 1160 1162 gdev->dev.type = &gpio_dev_type; 1163 + gdev->dev.bus = &gpio_bus_type; 1161 1164 gdev->dev.parent = gc->parent; 1162 1165 device_set_node(&gdev->dev, gpiochip_choose_fwnode(gc)); 1163 1166 ··· 1298 1299 * we get a device node entry in sysfs under 1299 1300 * /sys/bus/gpio/devices/gpiochipN/dev that can be used for 1300 1301 * coldplug of device nodes and other udev business. 1301 - * We can do this only if gpiolib has been initialized 1302 - * (i.e., `gpio_bus_type` is ready). Otherwise, defer until later. 1302 + * We can do this only if gpiolib has been initialized. 1303 + * Otherwise, defer until later. 1303 1304 */ 1304 1305 if (gpiolib_initialized) { 1305 1306 ret = gpiochip_setup_dev(gc);