[PATCH] video: backlight: Use sysfs_emit() instead of sprintf()

Levente Szajko <[email protected]>
Newsgroups org.freedesktop.lists.dri-devel,org.kernel.vger.linux-fbdev,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
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 <[email protected]>
---
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.