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
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