diff mbox series

[1/3] leds: leds-lp5569: Convert to sysfs_emit API

Message ID 20240626221520.2846-1-ansuelsmth@gmail.com
State New
Headers show
Series [1/3] leds: leds-lp5569: Convert to sysfs_emit API | expand

Commit Message

Christian Marangi June 26, 2024, 10:15 p.m. UTC
Convert sprintf to the much safer sysfs_emit API to handle output for
sysfs.

Also better handle situation where on the same chip there may be LED
open and shorted at the same time.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/leds/leds-lp5569.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Lee Jones July 4, 2024, 3:44 p.m. UTC | #1
On Thu, 27 Jun 2024 00:15:11 +0200, Christian Marangi wrote:
> Convert sprintf to the much safer sysfs_emit API to handle output for
> sysfs.
> 
> Also better handle situation where on the same chip there may be LED
> open and shorted at the same time.
> 
> 
> [...]

Applied, thanks!

[1/3] leds: leds-lp5569: Convert to sysfs_emit API
      commit: 6f2fdde9096f3c4d35a7711c91a78c086be66aed
[2/3] leds: leds-lp5523: Convert to sysfs_emit API
      commit: 8eac0379d3bd9d048b1144d74d9309a198fd3f40
[3/3] leds: leds-lp55xx: Convert mutex lock/unlock to guard API
      commit: efd0d1cbb8c5dd1049922e839fa7d85811facd53

--
Lee Jones [李琼斯]
diff mbox series

Patch

diff --git a/drivers/leds/leds-lp5569.c b/drivers/leds/leds-lp5569.c
index 7ccd8dd6026a..e5e7e61c8916 100644
--- a/drivers/leds/leds-lp5569.c
+++ b/drivers/leds/leds-lp5569.c
@@ -268,8 +268,8 @@  static ssize_t lp5569_led_open_test(struct lp55xx_led *led, char *buf)
 	led_tmp = led;
 	for (i = 0; i < pdata->num_channels; i++) {
 		if (leds_fault[led_tmp->chan_nr])
-			pos += sprintf(buf + pos, "LED %d OPEN FAIL\n",
-				       led_tmp->chan_nr);
+			pos += sysfs_emit_at(buf, pos, "LED %d OPEN FAIL\n",
+					     led_tmp->chan_nr);
 
 		led_tmp++;
 	}
@@ -366,8 +366,8 @@  static ssize_t lp5569_led_short_test(struct lp55xx_led *led, char *buf)
 	led_tmp = led;
 	for (i = 0; i < pdata->num_channels; i++) {
 		if (leds_fault[led_tmp->chan_nr])
-			pos += sprintf(buf + pos, "LED %d SHORTED FAIL\n",
-				       led_tmp->chan_nr);
+			pos += sysfs_emit_at(buf, pos, "LED %d SHORTED FAIL\n",
+					     led_tmp->chan_nr);
 
 		led_tmp++;
 	}
@@ -404,7 +404,7 @@  static ssize_t lp5569_selftest(struct device *dev,
 		goto fail;
 
 	/* Test LED Shorted */
-	pos = lp5569_led_short_test(led, buf);
+	pos += lp5569_led_short_test(led, buf);
 	if (pos < 0)
 		goto fail;
 
@@ -420,10 +420,10 @@  static ssize_t lp5569_selftest(struct device *dev,
 	}
 
 	if (pos == 0)
-		pos = sprintf(buf, "OK\n");
+		pos = sysfs_emit(buf, "OK\n");
 	goto release_lock;
 fail:
-	pos = sprintf(buf, "FAIL\n");
+	pos = sysfs_emit(buf, "FAIL\n");
 
 release_lock:
 	mutex_unlock(&chip->lock);