Skip to content

Commit 6f2fdde

Browse files
Ansuellag-linaro
authored andcommitted
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: Christian Marangi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 940b271 commit 6f2fdde

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/leds/leds-lp5569.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ static ssize_t lp5569_led_open_test(struct lp55xx_led *led, char *buf)
268268
led_tmp = led;
269269
for (i = 0; i < pdata->num_channels; i++) {
270270
if (leds_fault[led_tmp->chan_nr])
271-
pos += sprintf(buf + pos, "LED %d OPEN FAIL\n",
272-
led_tmp->chan_nr);
271+
pos += sysfs_emit_at(buf, pos, "LED %d OPEN FAIL\n",
272+
led_tmp->chan_nr);
273273

274274
led_tmp++;
275275
}
@@ -366,8 +366,8 @@ static ssize_t lp5569_led_short_test(struct lp55xx_led *led, char *buf)
366366
led_tmp = led;
367367
for (i = 0; i < pdata->num_channels; i++) {
368368
if (leds_fault[led_tmp->chan_nr])
369-
pos += sprintf(buf + pos, "LED %d SHORTED FAIL\n",
370-
led_tmp->chan_nr);
369+
pos += sysfs_emit_at(buf, pos, "LED %d SHORTED FAIL\n",
370+
led_tmp->chan_nr);
371371

372372
led_tmp++;
373373
}
@@ -404,7 +404,7 @@ static ssize_t lp5569_selftest(struct device *dev,
404404
goto fail;
405405

406406
/* Test LED Shorted */
407-
pos = lp5569_led_short_test(led, buf);
407+
pos += lp5569_led_short_test(led, buf);
408408
if (pos < 0)
409409
goto fail;
410410

@@ -420,10 +420,10 @@ static ssize_t lp5569_selftest(struct device *dev,
420420
}
421421

422422
if (pos == 0)
423-
pos = sprintf(buf, "OK\n");
423+
pos = sysfs_emit(buf, "OK\n");
424424
goto release_lock;
425425
fail:
426-
pos = sprintf(buf, "FAIL\n");
426+
pos = sysfs_emit(buf, "FAIL\n");
427427

428428
release_lock:
429429
mutex_unlock(&chip->lock);

0 commit comments

Comments
 (0)