* [PATCH v3] gpio: sim: Replace sprintf() with sysfs_emit()
@ 2026-04-28 11:33 Maxwell Doose
0 siblings, 0 replies; 4+ messages in thread
From: Maxwell Doose @ 2026-04-28 11:33 UTC (permalink / raw)
To: linusw, brgl, linux-gpio, linux-kernel
Replace sprintf() function calls with sysfs_emit() in the configfs show
callbacks. This will help harden the driver and will bring the driver
up-to-date with more modern functions.
Suggested-by: Bartosz Golaszewski <brgl@kernel.org>
Signed-off-by: Maxwell Doose <m32285159@gmail.com>
---
v2:
- Rebase commit onto tag 7.1-rc1.
- No functional changes from v1.
v3:
- Add missing sysfs_emit(), caught by Bartosz Golaszewski.
drivers/gpio/gpio-sim.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
index e19701c2ed67..b1f31861f40d 100644
--- a/drivers/gpio/gpio-sim.c
+++ b/drivers/gpio/gpio-sim.c
@@ -695,9 +695,9 @@ static ssize_t gpio_sim_device_config_dev_name_show(struct config_item *item,
pdev = dev->pdev;
if (pdev)
- return sprintf(page, "%s\n", dev_name(&pdev->dev));
+ return sysfs_emit(page, "%s\n", dev_name(&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);
@@ -711,7 +711,7 @@ gpio_sim_device_config_live_show(struct config_item *item, char *page)
scoped_guard(mutex, &dev->lock)
live = gpio_sim_device_is_live(dev);
- return sprintf(page, "%c\n", live ? '1' : '0');
+ return sysfs_emit(page, "%c\n", live ? '1' : '0');
}
static unsigned int gpio_sim_get_line_names_size(struct gpio_sim_bank *bank)
@@ -1056,7 +1056,7 @@ static int gpio_sim_emit_chip_name(struct device *dev, void *data)
return 0;
if (device_match_fwnode(dev, ctx->swnode))
- return sprintf(ctx->page, "%s\n", dev_name(dev));
+ return sysfs_emit(ctx->page, "%s\n", dev_name(dev));
return 0;
}
@@ -1074,7 +1074,7 @@ static ssize_t gpio_sim_bank_config_chip_name_show(struct config_item *item,
return device_for_each_child(&dev->pdev->dev, &ctx,
gpio_sim_emit_chip_name);
- return sprintf(page, "none\n");
+ return sysfs_emit(page, "none\n");
}
CONFIGFS_ATTR_RO(gpio_sim_bank_config_, chip_name);
@@ -1087,7 +1087,7 @@ gpio_sim_bank_config_label_show(struct config_item *item, char *page)
guard(mutex)(&dev->lock);
- return sprintf(page, "%s\n", bank->label ?: "");
+ return sysfs_emit(page, "%s\n", bank->label ?: "");
}
static ssize_t gpio_sim_bank_config_label_store(struct config_item *item,
@@ -1122,7 +1122,7 @@ gpio_sim_bank_config_num_lines_show(struct config_item *item, char *page)
guard(mutex)(&dev->lock);
- return sprintf(page, "%u\n", bank->num_lines);
+ return sysfs_emit(page, "%u\n", bank->num_lines);
}
static ssize_t
@@ -1168,7 +1168,7 @@ gpio_sim_line_config_name_show(struct config_item *item, char *page)
guard(mutex)(&dev->lock);
- return sprintf(page, "%s\n", line->name ?: "");
+ return sysfs_emit(page, "%s\n", line->name ?: "");
}
static ssize_t gpio_sim_line_config_name_store(struct config_item *item,
@@ -1203,7 +1203,7 @@ gpio_sim_line_config_valid_show(struct config_item *item, char *page)
guard(mutex)(&dev->lock);
- return sprintf(page, "%c\n", line->valid ? '1' : '0');
+ return sysfs_emit(page, "%c\n", line->valid ? '1' : '0');
}
static ssize_t gpio_sim_line_config_valid_store(struct config_item *item,
@@ -1241,7 +1241,7 @@ static ssize_t gpio_sim_hog_config_name_show(struct config_item *item,
guard(mutex)(&dev->lock);
- return sprintf(page, "%s\n", hog->name ?: "");
+ return sysfs_emit(page, "%s\n", hog->name ?: "");
}
static ssize_t gpio_sim_hog_config_name_store(struct config_item *item,
@@ -1295,7 +1295,7 @@ static ssize_t gpio_sim_hog_config_direction_show(struct config_item *item,
return -EINVAL;
}
- return sprintf(page, "%s\n", repr);
+ return sysfs_emit(page, "%s\n", repr);
}
static ssize_t
@@ -1335,7 +1335,7 @@ static ssize_t gpio_sim_hog_config_active_low_show(struct config_item *item,
guard(mutex)(&dev->lock);
- return sprintf(page, "%c\n", hog->active_low ? '1' : '0');
+ return sysfs_emit(page, "%c\n", hog->active_low ? '1' : '0');
}
static ssize_t
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3] gpio: sim: Replace sprintf() with sysfs_emit()
@ 2026-04-28 11:34 Maxwell Doose
2026-04-29 7:50 ` Bartosz Golaszewski
0 siblings, 1 reply; 4+ messages in thread
From: Maxwell Doose @ 2026-04-28 11:34 UTC (permalink / raw)
To: linusw, brgl; +Cc: linux-gpio, linux-kernel
Replace sprintf() function calls with sysfs_emit() in the configfs show
callbacks. This will help harden the driver and will bring the driver
up-to-date with more modern functions.
Suggested-by: Bartosz Golaszewski <brgl@kernel.org>
Signed-off-by: Maxwell Doose <m32285159@gmail.com>
---
v2:
- Rebase commit onto tag 7.1-rc1.
- No functional changes from v1.
v3:
- Add missing sysfs_emit(), caught by Bartosz Golaszewski.
drivers/gpio/gpio-sim.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
index e19701c2ed67..b1f31861f40d 100644
--- a/drivers/gpio/gpio-sim.c
+++ b/drivers/gpio/gpio-sim.c
@@ -695,9 +695,9 @@ static ssize_t gpio_sim_device_config_dev_name_show(struct config_item *item,
pdev = dev->pdev;
if (pdev)
- return sprintf(page, "%s\n", dev_name(&pdev->dev));
+ return sysfs_emit(page, "%s\n", dev_name(&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);
@@ -711,7 +711,7 @@ gpio_sim_device_config_live_show(struct config_item *item, char *page)
scoped_guard(mutex, &dev->lock)
live = gpio_sim_device_is_live(dev);
- return sprintf(page, "%c\n", live ? '1' : '0');
+ return sysfs_emit(page, "%c\n", live ? '1' : '0');
}
static unsigned int gpio_sim_get_line_names_size(struct gpio_sim_bank *bank)
@@ -1056,7 +1056,7 @@ static int gpio_sim_emit_chip_name(struct device *dev, void *data)
return 0;
if (device_match_fwnode(dev, ctx->swnode))
- return sprintf(ctx->page, "%s\n", dev_name(dev));
+ return sysfs_emit(ctx->page, "%s\n", dev_name(dev));
return 0;
}
@@ -1074,7 +1074,7 @@ static ssize_t gpio_sim_bank_config_chip_name_show(struct config_item *item,
return device_for_each_child(&dev->pdev->dev, &ctx,
gpio_sim_emit_chip_name);
- return sprintf(page, "none\n");
+ return sysfs_emit(page, "none\n");
}
CONFIGFS_ATTR_RO(gpio_sim_bank_config_, chip_name);
@@ -1087,7 +1087,7 @@ gpio_sim_bank_config_label_show(struct config_item *item, char *page)
guard(mutex)(&dev->lock);
- return sprintf(page, "%s\n", bank->label ?: "");
+ return sysfs_emit(page, "%s\n", bank->label ?: "");
}
static ssize_t gpio_sim_bank_config_label_store(struct config_item *item,
@@ -1122,7 +1122,7 @@ gpio_sim_bank_config_num_lines_show(struct config_item *item, char *page)
guard(mutex)(&dev->lock);
- return sprintf(page, "%u\n", bank->num_lines);
+ return sysfs_emit(page, "%u\n", bank->num_lines);
}
static ssize_t
@@ -1168,7 +1168,7 @@ gpio_sim_line_config_name_show(struct config_item *item, char *page)
guard(mutex)(&dev->lock);
- return sprintf(page, "%s\n", line->name ?: "");
+ return sysfs_emit(page, "%s\n", line->name ?: "");
}
static ssize_t gpio_sim_line_config_name_store(struct config_item *item,
@@ -1203,7 +1203,7 @@ gpio_sim_line_config_valid_show(struct config_item *item, char *page)
guard(mutex)(&dev->lock);
- return sprintf(page, "%c\n", line->valid ? '1' : '0');
+ return sysfs_emit(page, "%c\n", line->valid ? '1' : '0');
}
static ssize_t gpio_sim_line_config_valid_store(struct config_item *item,
@@ -1241,7 +1241,7 @@ static ssize_t gpio_sim_hog_config_name_show(struct config_item *item,
guard(mutex)(&dev->lock);
- return sprintf(page, "%s\n", hog->name ?: "");
+ return sysfs_emit(page, "%s\n", hog->name ?: "");
}
static ssize_t gpio_sim_hog_config_name_store(struct config_item *item,
@@ -1295,7 +1295,7 @@ static ssize_t gpio_sim_hog_config_direction_show(struct config_item *item,
return -EINVAL;
}
- return sprintf(page, "%s\n", repr);
+ return sysfs_emit(page, "%s\n", repr);
}
static ssize_t
@@ -1335,7 +1335,7 @@ static ssize_t gpio_sim_hog_config_active_low_show(struct config_item *item,
guard(mutex)(&dev->lock);
- return sprintf(page, "%c\n", hog->active_low ? '1' : '0');
+ return sysfs_emit(page, "%c\n", hog->active_low ? '1' : '0');
}
static ssize_t
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3] gpio: sim: Replace sprintf() with sysfs_emit()
2026-04-28 11:34 Maxwell Doose
@ 2026-04-29 7:50 ` Bartosz Golaszewski
2026-04-30 2:25 ` Maxwell Doose
0 siblings, 1 reply; 4+ messages in thread
From: Bartosz Golaszewski @ 2026-04-29 7:50 UTC (permalink / raw)
To: linusw, brgl, Maxwell Doose; +Cc: Bartosz Golaszewski, linux-gpio, linux-kernel
On Tue, 28 Apr 2026 06:34:39 -0500, Maxwell Doose wrote:
> Replace sprintf() function calls with sysfs_emit() in the configfs show
> callbacks. This will help harden the driver and will bring the driver
> up-to-date with more modern functions.
>
>
Applied, thanks!
[1/1] gpio: sim: Replace sprintf() with sysfs_emit()
https://git.kernel.org/brgl/c/be22c0f7f2d573addcdf3a92f8aaef7a45a8c133
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v3] gpio: sim: Replace sprintf() with sysfs_emit()
2026-04-29 7:50 ` Bartosz Golaszewski
@ 2026-04-30 2:25 ` Maxwell Doose
0 siblings, 0 replies; 4+ messages in thread
From: Maxwell Doose @ 2026-04-30 2:25 UTC (permalink / raw)
To: Bartosz Golaszewski; +Cc: linusw, brgl, linux-gpio, linux-kernel
On Wed, Apr 29, 2026 at 2:50 AM Bartosz Golaszewski
<bartosz.golaszewski@oss.qualcomm.com> wrote:
>
> On Tue, 28 Apr 2026 06:34:39 -0500, Maxwell Doose wrote:
> > Replace sprintf() function calls with sysfs_emit() in the configfs show
> > callbacks. This will help harden the driver and will bring the driver
> > up-to-date with more modern functions.
> >
> >
>
> Applied, thanks!
>
Nice, glad this got through. Looking forward to making more contributions!
best regards,
maxwell
> [1/1] gpio: sim: Replace sprintf() with sysfs_emit()
> https://git.kernel.org/brgl/c/be22c0f7f2d573addcdf3a92f8aaef7a45a8c133
>
> Best regards,
> --
> Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-30 2:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-28 11:33 [PATCH v3] gpio: sim: Replace sprintf() with sysfs_emit() Maxwell Doose
-- strict thread matches above, loose matches on Subject: below --
2026-04-28 11:34 Maxwell Doose
2026-04-29 7:50 ` Bartosz Golaszewski
2026-04-30 2:25 ` Maxwell Doose
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox