[PATCH] leds: trigger: pattern: use sysfs_emit_at() instead of scnprintf()

tang.dongxing@zte.com.cn posted 1 patch 9 months ago
drivers/leds/trigger/ledtrig-pattern.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] leds: trigger: pattern: use sysfs_emit_at() instead of scnprintf()
Posted by tang.dongxing@zte.com.cn 9 months ago
From: TangDongxing <tang.dongxing@zte.com.cn>

Follow the advice in Documentation/filesystems/sysfs.rst:
show() should only use sysfs_emit() or sysfs_emit_at() when formatting
the value to be returned to user space.

Signed-off-by: TangDongxing <tang.dongxing@zte.com.cn>
---
 drivers/leds/trigger/ledtrig-pattern.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/leds/trigger/ledtrig-pattern.c b/drivers/leds/trigger/ledtrig-pattern.c
index a594bd5e2233..861122c3e97b 100644
--- a/drivers/leds/trigger/ledtrig-pattern.c
+++ b/drivers/leds/trigger/ledtrig-pattern.c
@@ -256,7 +256,7 @@ static ssize_t pattern_trig_show_patterns(struct pattern_trig_data *data,
 		goto out;

 	for (i = 0; i < data->npatterns; i++) {
-		count += scnprintf(buf + count, PAGE_SIZE - count,
+		count += sysfs_emit_at(buf, count,
 				   "%d %u ",
 				   data->patterns[i].brightness,
 				   data->patterns[i].delta_t);
-- 
2.25.1
Re: [PATCH] leds: trigger: pattern: use sysfs_emit_at() instead of scnprintf()
Posted by Krzysztof Kozlowski 9 months ago
On 17/03/2025 08:04, tang.dongxing@zte.com.cn wrote:
> From: TangDongxing <tang.dongxing@zte.com.cn>
> 
> Follow the advice in Documentation/filesystems/sysfs.rst:
> show() should only use sysfs_emit() or sysfs_emit_at() when formatting
> the value to be returned to user space.
> 
> Signed-off-by: TangDongxing <tang.dongxing@zte.com.cn>

Can ZTE slow down and address the feedback first?

Best regards,
Krzysztof