Linux Framebuffer Layer development
 help / color / mirror / Atom feed
From: Levente Szajko <raedrimhun@proton.me>
To: lee@kernel.org, danielt@kernel.org
Cc: jingoohan1@gmail.com, deller@gmx.de,
	dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Levente Szajko <raedrimhun@proton.me>
Subject: [PATCH] video: backlight: Use sysfs_emit() instead of sprintf()
Date: Wed, 05 Aug 2026 13:51:39 +0000	[thread overview]
Message-ID: <20260805135027.43890-1-raedrimhun@proton.me> (raw)

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



             reply	other threads:[~2026-08-05 13:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05 13:51 Levente Szajko [this message]
2026-08-10 11:15 ` [PATCH] video: backlight: Use sysfs_emit() instead of sprintf() Daniel Thompson
2026-08-12 13:06 ` (subset) " Lee Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260805135027.43890-1-raedrimhun@proton.me \
    --to=raedrimhun@proton.me \
    --cc=danielt@kernel.org \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jingoohan1@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox