* [PATCH] staging: greybus: use sysfs_emit instead of sprintf in light.c
[not found] <20260819-greybus-light-sysfs-emit-v1-1-43c4b680de6a.ref@yahoo.pl>
@ 2026-08-19 15:44 ` Tomasz Unger
2026-09-01 10:06 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Tomasz Unger @ 2026-08-19 15:44 UTC (permalink / raw)
To: Rui Miguel Silva, Johan Hovold, Alex Elder, Greg Kroah-Hartman
Cc: greybus-dev, linux-staging, linux-kernel, Tomasz Unger
Per Documentation/filesystems/sysfs.rst, new implementations of
show() methods should only use sysfs_emit() or sysfs_emit_at()
when formatting the value to be returned to user space, since it
is aware of the sysfs PAGE_SIZE buffer and includes sanity checks
that sprintf() lacks.
This fixes fade_in_show() and fade_out_show() (both generated by
the gb_lights_fade_attr() macro) and color_show().
Signed-off-by: Tomasz Unger <tomasz.unger@yahoo.pl>
---
Verified with checkpatch.pl - no errors or warnings.
Compiled the gb-light module successfully with CONFIG_GREYBUS_LIGHT=m
and CONFIG_LEDS_CLASS_FLASH=m (both previously disabled).
greybus.ko, led-class-flash.ko and gb-light.ko all load without
errors in a QEMU environment (verified via insmod and lsmod, dmesg
shows no errors). This confirms the modules load cleanly but does
not exercise the changed sysfs show() code paths, which would
require an actual Greybus light device bound to the driver.
---
drivers/staging/greybus/light.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
index cab02b5da867..2689f9a7524a 100644
--- a/drivers/staging/greybus/light.c
+++ b/drivers/staging/greybus/light.c
@@ -173,7 +173,7 @@ static ssize_t fade_##__dir##_show(struct device *dev, \
struct led_classdev *cdev = dev_get_drvdata(dev); \
struct gb_channel *channel = get_channel_from_cdev(cdev); \
\
- return sprintf(buf, "%u\n", channel->fade_##__dir); \
+ return sysfs_emit(buf, "%u\n", channel->fade_##__dir); \
} \
\
static ssize_t fade_##__dir##_store(struct device *dev, \
@@ -220,7 +220,7 @@ static ssize_t color_show(struct device *dev, struct device_attribute *attr,
struct led_classdev *cdev = dev_get_drvdata(dev);
struct gb_channel *channel = get_channel_from_cdev(cdev);
- return sprintf(buf, "0x%08x\n", channel->color);
+ return sysfs_emit(buf, "0x%08x\n", channel->color);
}
static ssize_t color_store(struct device *dev, struct device_attribute *attr,
---
base-commit: 8d3ae59288f1e7d58d76558a6ee96d533bc5019f
change-id: 20260819-greybus-light-sysfs-emit-4b8beab74fcc
Best regards,
--
Tomasz Unger <tomasz.unger@yahoo.pl>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] staging: greybus: use sysfs_emit instead of sprintf in light.c
2026-08-19 15:44 ` [PATCH] staging: greybus: use sysfs_emit instead of sprintf in light.c Tomasz Unger
@ 2026-09-01 10:06 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2026-09-01 10:06 UTC (permalink / raw)
To: Tomasz Unger
Cc: Rui Miguel Silva, Johan Hovold, Alex Elder, greybus-dev,
linux-staging, linux-kernel
On Wed, Aug 19, 2026 at 05:44:55PM +0200, Tomasz Unger wrote:
> Per Documentation/filesystems/sysfs.rst, new implementations of
> show() methods should only use sysfs_emit() or sysfs_emit_at()
> when formatting the value to be returned to user space, since it
> is aware of the sysfs PAGE_SIZE buffer and includes sanity checks
> that sprintf() lacks.
>
> This fixes fade_in_show() and fade_out_show() (both generated by
> the gb_lights_fade_attr() macro) and color_show().
>
> Signed-off-by: Tomasz Unger <tomasz.unger@yahoo.pl>
> ---
> Verified with checkpatch.pl - no errors or warnings.
> Compiled the gb-light module successfully with CONFIG_GREYBUS_LIGHT=m
> and CONFIG_LEDS_CLASS_FLASH=m (both previously disabled).
> greybus.ko, led-class-flash.ko and gb-light.ko all load without
> errors in a QEMU environment (verified via insmod and lsmod, dmesg
> shows no errors). This confirms the modules load cleanly but does
> not exercise the changed sysfs show() code paths, which would
> require an actual Greybus light device bound to the driver.
> ---
> drivers/staging/greybus/light.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Please see the archives for why this patch has been rejected in the
past.
sorry,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-01 10:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20260819-greybus-light-sysfs-emit-v1-1-43c4b680de6a.ref@yahoo.pl>
2026-08-19 15:44 ` [PATCH] staging: greybus: use sysfs_emit instead of sprintf in light.c Tomasz Unger
2026-09-01 10:06 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®