]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
leds: leds-lp5523: Convert to sysfs_emit API
authorChristian Marangi <ansuelsmth@gmail.com>
Wed, 26 Jun 2024 22:15:12 +0000 (00:15 +0200)
committerLee Jones <lee@kernel.org>
Thu, 4 Jul 2024 15:44:45 +0000 (16:44 +0100)
Convert sprintf to the much safer sysfs_emit API to handle output for
sysfs.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Link: https://lore.kernel.org/r/20240626221520.2846-2-ansuelsmth@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/leds/leds-lp5523.c

index 57df920192d2371769da93dcec63c5bb53a86fc1..095060533d1a1c6b12c8fd191967356a4d5b81d9 100644 (file)
@@ -245,8 +245,8 @@ static ssize_t lp5523_selftest(struct device *dev,
                        goto fail;
 
                if (adc >= vdd || adc < LP5523_ADC_SHORTCIRC_LIM)
-                       pos += sprintf(buf + pos, "LED %d FAIL\n",
-                                      led->chan_nr);
+                       pos += sysfs_emit_at(buf, pos, "LED %d FAIL\n",
+                                            led->chan_nr);
 
                lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + led->chan_nr,
                             0x00);
@@ -257,10 +257,10 @@ static ssize_t lp5523_selftest(struct device *dev,
                led++;
        }
        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);