backlight: Use sysfs_emit() instead of sprintf()

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>
This commit is contained in:
Levente Szajko
2026-08-05 13:51:39 +00:00
committed by Lee Jones
parent 0bf739c3cd
commit cf1a12e080
2 changed files with 11 additions and 11 deletions

View 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);

View 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);