[PATCH] gpio: virtuser: report the right dev_name before the device is live

From: Lin Tzu Yang

Date: Tue Dec 01 2026 - 09:27:04 EST


Until the consumer is enabled, dev_name_show() prints the name the
platform device is going to get, but it uses the gpio-sim prefix:
"gpio-sim.N". The device is registered as "gpio-virtuser.N", which is
also what the lookup table built for it uses, and that is what
dev_name shows once the consumer is live.

The wrong name can also belong to a real device: with one gpio-sim
chip and one consumer, dev_name of the disabled consumer reads
"gpio-sim.0", the name of the simulated chip.

Print "gpio-virtuser.N" instead.

Fixes: 91581c4b3f29 ("gpio: virtuser: new virtual testing driver for the GPIO API")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lin Tzu Yang <rongh7426@xxxxxxxxx>
---
Found while writing a selftest for gpio-virtuser, which I will send
separately for gpio/for-next. In a QEMU/KVM arm64 guest with one
gpio-sim chip, dev_name read "gpio-sim.0" before enabling and after
disabling the consumer, and "gpio-virtuser.0" while it was live. With
this patch it reads "gpio-virtuser.0" in all three states, and the
platform device of that name exists once the consumer is live.
Tested on configfs-next 2e0fad9d2eae, where this file is the same
apart from the key show fix I sent earlier today; the patch is
against gpio/for-current.

This patch was written with the help of an AI coding assistant
(Claude). I ran the tests above and reviewed the change.

drivers/gpio/gpio-virtuser.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-virtuser.c b/drivers/gpio/gpio-virtuser.c
index 5bf5d891c4..5d000aff98 100644
--- a/drivers/gpio/gpio-virtuser.c
+++ b/drivers/gpio/gpio-virtuser.c
@@ -1375,7 +1375,7 @@ gpio_virtuser_device_config_dev_name_show(struct config_item *item,
if (pdev)
return sprintf(page, "%s\n", dev_name(&pdev->dev));

- return sprintf(page, "gpio-sim.%d\n", dev->id);
+ return sprintf(page, "gpio-virtuser.%d\n", dev->id);
}

CONFIGFS_ATTR_RO(gpio_virtuser_device_config_, dev_name);
--
2.47.3