Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* [PATCH] video: backlight: Use sysfs_emit() instead of sprintf()
@ 2026-08-05 13:51 Levente Szajko
  2026-08-10 11:15 ` Daniel Thompson
  0 siblings, 1 reply; 2+ messages in thread
From: Levente Szajko @ 2026-08-05 13:51 UTC (permalink / raw)
  To: lee, danielt
  Cc: jingoohan1, deller, dri-devel, linux-fbdev, linux-kernel,
	Levente Szajko

Replace sprintf() with sysfs_emit() in the sysfs show callbacks of
backlight.c and lcd.c, as recommended by Documentation/filesystems/sysfs.rst.

No functional change intended.

Signed-off-by: Levente Szajko <raedrimhun@proton.me>
---
 drivers/video/backlight/backlight.c | 16 ++++++++--------
 drivers/video/backlight/lcd.c       |  6 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index a22d0bbb6e63..fc9bb303e8c5 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -139,7 +139,7 @@ static ssize_t bl_power_show(struct device *dev, struct device_attribute *attr,
 {
 	struct backlight_device *bd = to_backlight_device(dev);
 
-	return sprintf(buf, "%d\n", bd->props.power);
+	return sysfs_emit(buf, "%d\n", bd->props.power);
 }
 
 static ssize_t bl_power_store(struct device *dev, struct device_attribute *attr,
@@ -180,7 +180,7 @@ static ssize_t brightness_show(struct device *dev,
 {
 	struct backlight_device *bd = to_backlight_device(dev);
 
-	return sprintf(buf, "%d\n", bd->props.brightness);
+	return sysfs_emit(buf, "%d\n", bd->props.brightness);
 }
 
 int backlight_device_set_brightness(struct backlight_device *bd,
@@ -228,7 +228,7 @@ static ssize_t type_show(struct device *dev, struct device_attribute *attr,
 {
 	struct backlight_device *bd = to_backlight_device(dev);
 
-	return sprintf(buf, "%s\n", backlight_types[bd->props.type]);
+	return sysfs_emit(buf, "%s\n", backlight_types[bd->props.type]);
 }
 static DEVICE_ATTR_RO(type);
 
@@ -237,7 +237,7 @@ static ssize_t max_brightness_show(struct device *dev,
 {
 	struct backlight_device *bd = to_backlight_device(dev);
 
-	return sprintf(buf, "%d\n", bd->props.max_brightness);
+	return sysfs_emit(buf, "%d\n", bd->props.max_brightness);
 }
 static DEVICE_ATTR_RO(max_brightness);
 
@@ -251,9 +251,9 @@ static ssize_t actual_brightness_show(struct device *dev,
 	if (bd->ops && bd->ops->get_brightness) {
 		rc = bd->ops->get_brightness(bd);
 		if (rc >= 0)
-			rc = sprintf(buf, "%d\n", rc);
+			rc = sysfs_emit(buf, "%d\n", rc);
 	} else {
-		rc = sprintf(buf, "%d\n", bd->props.brightness);
+		rc = sysfs_emit(buf, "%d\n", bd->props.brightness);
 	}
 	mutex_unlock(&bd->ops_lock);
 
@@ -267,9 +267,9 @@ static ssize_t scale_show(struct device *dev,
 	struct backlight_device *bd = to_backlight_device(dev);
 
 	if (WARN_ON(bd->props.scale > BACKLIGHT_SCALE_NON_LINEAR))
-		return sprintf(buf, "unknown\n");
+		return sysfs_emit(buf, "unknown\n");
 
-	return sprintf(buf, "%s\n", backlight_scale_types[bd->props.scale]);
+	return sysfs_emit(buf, "%s\n", backlight_scale_types[bd->props.scale]);
 }
 static DEVICE_ATTR_RO(scale);
 
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
index e918f57608ef..461e393837d3 100644
--- a/drivers/video/backlight/lcd.c
+++ b/drivers/video/backlight/lcd.c
@@ -77,7 +77,7 @@ static ssize_t lcd_power_show(struct device *dev, struct device_attribute *attr,
 
 	mutex_lock(&ld->ops_lock);
 	if (ld->ops && ld->ops->get_power)
-		rc = sprintf(buf, "%d\n", ld->ops->get_power(ld));
+		rc = sysfs_emit(buf, "%d\n", ld->ops->get_power(ld));
 	else
 		rc = -ENXIO;
 	mutex_unlock(&ld->ops_lock);
@@ -118,7 +118,7 @@ static ssize_t contrast_show(struct device *dev,
 
 	mutex_lock(&ld->ops_lock);
 	if (ld->ops && ld->ops->get_contrast)
-		rc = sprintf(buf, "%d\n", ld->ops->get_contrast(ld));
+		rc = sysfs_emit(buf, "%d\n", ld->ops->get_contrast(ld));
 	mutex_unlock(&ld->ops_lock);
 
 	return rc;
@@ -154,7 +154,7 @@ static ssize_t max_contrast_show(struct device *dev,
 {
 	struct lcd_device *ld = to_lcd_device(dev);
 
-	return sprintf(buf, "%d\n", ld->props.max_contrast);
+	return sysfs_emit(buf, "%d\n", ld->props.max_contrast);
 }
 static DEVICE_ATTR_RO(max_contrast);
 
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] video: backlight: Use sysfs_emit() instead of sprintf()
  2026-08-05 13:51 [PATCH] video: backlight: Use sysfs_emit() instead of sprintf() Levente Szajko
@ 2026-08-10 11:15 ` Daniel Thompson
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Thompson @ 2026-08-10 11:15 UTC (permalink / raw)
  To: Levente Szajko
  Cc: lee, jingoohan1, deller, dri-devel, linux-fbdev, linux-kernel

On Wed, Aug 05, 2026 at 01:51:39PM +0000, Levente Szajko wrote:
> Replace sprintf() with sysfs_emit() in the sysfs show callbacks of
> backlight.c and lcd.c, as recommended by Documentation/filesystems/sysfs.rst.
>
> No functional change intended.
>
> Signed-off-by: Levente Szajko <raedrimhun@proton.me>

Reviewed-by: Daniel Thompson (RISCstar) <danielt@kernel.org>


Daniel.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-10 11:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05 13:51 [PATCH] video: backlight: Use sysfs_emit() instead of sprintf() Levente Szajko
2026-08-10 11:15 ` Daniel Thompson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox