]> git.hungrycats.org Git - linux/commitdiff
backlight: Use sysfs_emit() instead of sprintf()
authorLevente Szajko <raedrimhun@proton.me>
Wed, 5 Aug 2026 13:51:39 +0000 (13:51 +0000)
committerLee Jones <lee@kernel.org>
Wed, 12 Aug 2026 13:06:29 +0000 (14:06 +0100)
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>
Link: https://patch.msgid.link/20260805135027.43890-1-raedrimhun@proton.me
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/video/backlight/backlight.c
drivers/video/backlight/lcd.c

index a22d0bbb6e63964e88a366cf08f984df22ca93cc..fc9bb303e8c5fb4fcb8199cd49bb44714756d9ac 100644 (file)
@@ -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);
 
index e918f57608effc5db7986830e53355e434ad377f..461e393837d3c961be268aa748870abf6810517b 100644 (file)
@@ -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);