Commit 6f2fdde9 authored by Christian Marangi's avatar Christian Marangi Committed by Lee Jones

leds: leds-lp5569: Convert to sysfs_emit API

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: default avatarChristian Marangi <ansuelsmth@gmail.com>
Link: https://lore.kernel.org/r/20240626221520.2846-1-ansuelsmth@gmail.comSigned-off-by: default avatarLee Jones <lee@kernel.org>
parent 940b2716
...@@ -268,7 +268,7 @@ static ssize_t lp5569_led_open_test(struct lp55xx_led *led, char *buf) ...@@ -268,7 +268,7 @@ static ssize_t lp5569_led_open_test(struct lp55xx_led *led, char *buf)
led_tmp = led; led_tmp = led;
for (i = 0; i < pdata->num_channels; i++) { for (i = 0; i < pdata->num_channels; i++) {
if (leds_fault[led_tmp->chan_nr]) if (leds_fault[led_tmp->chan_nr])
pos += sprintf(buf + pos, "LED %d OPEN FAIL\n", pos += sysfs_emit_at(buf, pos, "LED %d OPEN FAIL\n",
led_tmp->chan_nr); led_tmp->chan_nr);
led_tmp++; led_tmp++;
...@@ -366,7 +366,7 @@ static ssize_t lp5569_led_short_test(struct lp55xx_led *led, char *buf) ...@@ -366,7 +366,7 @@ static ssize_t lp5569_led_short_test(struct lp55xx_led *led, char *buf)
led_tmp = led; led_tmp = led;
for (i = 0; i < pdata->num_channels; i++) { for (i = 0; i < pdata->num_channels; i++) {
if (leds_fault[led_tmp->chan_nr]) if (leds_fault[led_tmp->chan_nr])
pos += sprintf(buf + pos, "LED %d SHORTED FAIL\n", pos += sysfs_emit_at(buf, pos, "LED %d SHORTED FAIL\n",
led_tmp->chan_nr); led_tmp->chan_nr);
led_tmp++; led_tmp++;
...@@ -404,7 +404,7 @@ static ssize_t lp5569_selftest(struct device *dev, ...@@ -404,7 +404,7 @@ static ssize_t lp5569_selftest(struct device *dev,
goto fail; goto fail;
/* Test LED Shorted */ /* Test LED Shorted */
pos = lp5569_led_short_test(led, buf); pos += lp5569_led_short_test(led, buf);
if (pos < 0) if (pos < 0)
goto fail; goto fail;
...@@ -420,10 +420,10 @@ static ssize_t lp5569_selftest(struct device *dev, ...@@ -420,10 +420,10 @@ static ssize_t lp5569_selftest(struct device *dev,
} }
if (pos == 0) if (pos == 0)
pos = sprintf(buf, "OK\n"); pos = sysfs_emit(buf, "OK\n");
goto release_lock; goto release_lock;
fail: fail:
pos = sprintf(buf, "FAIL\n"); pos = sysfs_emit(buf, "FAIL\n");
release_lock: release_lock:
mutex_unlock(&chip->lock); mutex_unlock(&chip->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment