leds: use sysfs_emit() to instead of scnprintf()
authorye xingchen <ye.xingchen@zte.com.cn>
Thu, 1 Dec 2022 08:11:24 +0000 (16:11 +0800)
committerPavel Machek <pavel@ucw.cz>
Wed, 7 Dec 2022 20:05:20 +0000 (21:05 +0100)
Replace the open-code with sysfs_emit() to simplify the code.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
drivers/leds/leds-blinkm.c
drivers/leds/leds-lm3533.c
drivers/leds/leds-lp5521.c
drivers/leds/leds-lp55xx-common.c
drivers/leds/trigger/ledtrig-pattern.c

index 3fb6a2fdaefa67bd2818cd29bfdb8f1cb797b7ec..e19cc8a7b7cac2c997700e4d371ebf8e9436d241 100644 (file)
@@ -139,11 +139,11 @@ static ssize_t show_color_common(struct device *dev, char *buf, int color)
                return ret;
        switch (color) {
        case RED:
-               return scnprintf(buf, PAGE_SIZE, "%02X\n", data->red);
+               return sysfs_emit(buf, "%02X\n", data->red);
        case GREEN:
-               return scnprintf(buf, PAGE_SIZE, "%02X\n", data->green);
+               return sysfs_emit(buf, "%02X\n", data->green);
        case BLUE:
-               return scnprintf(buf, PAGE_SIZE, "%02X\n", data->blue);
+               return sysfs_emit(buf, "%02X\n", data->blue);
        default:
                return -EINVAL;
        }
@@ -253,7 +253,7 @@ static DEVICE_ATTR_RW(blue);
 static ssize_t test_show(struct device *dev, struct device_attribute *attr,
                         char *buf)
 {
-       return scnprintf(buf, PAGE_SIZE,
+       return sysfs_emit(buf,
                         "#Write into test to start test sequence!#\n");
 }
 
index 43d5970d96aa229f08d7d563bb68580873b10a94..bcd414eb47246e514afd16b2298c57ae3872f1ab 100644 (file)
@@ -314,7 +314,7 @@ static ssize_t show_id(struct device *dev,
        struct led_classdev *led_cdev = dev_get_drvdata(dev);
        struct lm3533_led *led = to_lm3533_led(led_cdev);
 
-       return scnprintf(buf, PAGE_SIZE, "%d\n", led->id);
+       return sysfs_emit(buf, "%d\n", led->id);
 }
 
 /*
@@ -344,7 +344,7 @@ static ssize_t show_risefalltime(struct device *dev,
        if (ret)
                return ret;
 
-       return scnprintf(buf, PAGE_SIZE, "%x\n", val);
+       return sysfs_emit(buf, "%x\n", val);
 }
 
 static ssize_t show_risetime(struct device *dev,
@@ -415,7 +415,7 @@ static ssize_t show_als_channel(struct device *dev,
 
        channel = (val & LM3533_REG_CTRLBANK_BCONF_ALS_CHANNEL_MASK) + 1;
 
-       return scnprintf(buf, PAGE_SIZE, "%u\n", channel);
+       return sysfs_emit(buf, "%u\n", channel);
 }
 
 static ssize_t store_als_channel(struct device *dev,
@@ -465,7 +465,7 @@ static ssize_t show_als_en(struct device *dev,
 
        enable = val & LM3533_REG_CTRLBANK_BCONF_ALS_EN_MASK;
 
-       return scnprintf(buf, PAGE_SIZE, "%d\n", enable);
+       return sysfs_emit(buf, "%d\n", enable);
 }
 
 static ssize_t store_als_en(struct device *dev,
@@ -518,7 +518,7 @@ static ssize_t show_linear(struct device *dev,
        else
                linear = 0;
 
-       return scnprintf(buf, PAGE_SIZE, "%x\n", linear);
+       return sysfs_emit(buf, "%x\n", linear);
 }
 
 static ssize_t store_linear(struct device *dev,
@@ -564,7 +564,7 @@ static ssize_t show_pwm(struct device *dev,
        if (ret)
                return ret;
 
-       return scnprintf(buf, PAGE_SIZE, "%u\n", val);
+       return sysfs_emit(buf, "%u\n", val);
 }
 
 static ssize_t store_pwm(struct device *dev,
index 7ff20c2605041bb8ec79c69288235f89abb115e6..19478d9c19a70d5932d3c3af7a150589ba112242 100644 (file)
@@ -469,7 +469,7 @@ static ssize_t lp5521_selftest(struct device *dev,
        ret = lp5521_run_selftest(chip, buf);
        mutex_unlock(&chip->lock);
 
-       return scnprintf(buf, PAGE_SIZE, "%s\n", ret ? "FAIL" : "OK");
+       return sysfs_emit(buf, "%s\n", ret ? "FAIL" : "OK");
 }
 
 /* device attributes */
index ca2e28fb843f17e3e72b3ed767d22d580ddb1e69..c1940964067af8c09450a87bdc658b542cbdd0f0 100644 (file)
@@ -88,7 +88,7 @@ static ssize_t led_current_show(struct device *dev,
 {
        struct lp55xx_led *led = dev_to_lp55xx_led(dev);
 
-       return scnprintf(buf, PAGE_SIZE, "%d\n", led->led_current);
+       return sysfs_emit(buf, "%d\n", led->led_current);
 }
 
 static ssize_t led_current_store(struct device *dev,
@@ -121,7 +121,7 @@ static ssize_t max_current_show(struct device *dev,
 {
        struct lp55xx_led *led = dev_to_lp55xx_led(dev);
 
-       return scnprintf(buf, PAGE_SIZE, "%d\n", led->max_current);
+       return sysfs_emit(buf, "%d\n", led->max_current);
 }
 
 static DEVICE_ATTR_RW(led_current);
index 43a265dc4696e34c716c5568ec8f6540c7abcc22..885ca63f383fb4d27af588043582c69c6ea3a822 100644 (file)
@@ -155,7 +155,7 @@ static ssize_t repeat_show(struct device *dev, struct device_attribute *attr,
 
        mutex_unlock(&data->lock);
 
-       return scnprintf(buf, PAGE_SIZE, "%d\n", repeat);
+       return sysfs_emit(buf, "%d\n", repeat);
 }
 
 static ssize_t repeat_store(struct device *dev, struct device_attribute *attr,