Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Lin Tzu Yang <rongh7426@gmail.com>
To: Linus Walleij <linusw@kernel.org>, Bartosz Golaszewski <brgl@kernel.org>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: [PATCH] gpio: virtuser: report the right dev_name before the device is live
Date: Tue,  1 Dec 2026 22:26:49 +0800	[thread overview]
Message-ID: <20261201142649.900883-1-rongh7426@gmail.com> (raw)

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@vger.kernel.org
Signed-off-by: Lin Tzu Yang <rongh7426@gmail.com>
---
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


                 reply	other threads:[~2026-12-01 14:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261201142649.900883-1-rongh7426@gmail.com \
    --to=rongh7426@gmail.com \
    --cc=brgl@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@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