From: Maxwell Doose <m32285159@gmail.com>
To: linusw@kernel.org, brgl@kernel.org
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] gpio: sim: Remove intermediate pointer variable and harden function
Date: Thu, 23 Apr 2026 17:32:30 -0500 [thread overview]
Message-ID: <20260423223230.47001-1-m32285159@gmail.com> (raw)
Remove the *pdev intermediate variable and directly dereference the
pointer. While at it, replace sprintf() calls with sysfs_emit() to
harden the driver.
Signed-off-by: Maxwell Doose <m32285159@gmail.com>
---
drivers/gpio/gpio-sim.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
index 13b87c8e6d0c..3c230f94eea2 100644
--- a/drivers/gpio/gpio-sim.c
+++ b/drivers/gpio/gpio-sim.c
@@ -691,15 +691,13 @@ static ssize_t gpio_sim_device_config_dev_name_show(struct config_item *item,
char *page)
{
struct gpio_sim_device *dev = to_gpio_sim_device(item);
- struct platform_device *pdev;
guard(mutex)(&dev->lock);
- pdev = dev->probe_data.pdev;
- if (pdev)
- return sprintf(page, "%s\n", dev_name(&pdev->dev));
+ if (dev->probe_data.pdev)
+ return sysfs_emit(page, "%s\n", dev_name(&dev->probe_data.pdev->dev));
- return sprintf(page, "gpio-sim.%d\n", dev->id);
+ return sysfs_emit(page, "gpio-sim.%d\n", dev->id);
}
CONFIGFS_ATTR_RO(gpio_sim_device_config_, dev_name);
--
2.53.0
next reply other threads:[~2026-04-23 22:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 22:32 Maxwell Doose [this message]
2026-04-24 7:54 ` [PATCH] gpio: sim: Remove intermediate pointer variable and harden function Bartosz Golaszewski
2026-04-24 13:05 ` Maxwell Doose
2026-04-24 13:13 ` Bartosz Golaszewski
2026-04-24 13:22 ` Maxwell Doose
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=20260423223230.47001-1-m32285159@gmail.com \
--to=m32285159@gmail.com \
--cc=brgl@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@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