Skip to content

Commit 3f6fb1c

Browse files
ye xingchenpavelmachek
authored andcommitted
leds: use sysfs_emit() to instead of scnprintf()
Replace the open-code with sysfs_emit() to simplify the code. Signed-off-by: ye xingchen <[email protected]> Signed-off-by: Pavel Machek <[email protected]>
1 parent 135780f commit 3f6fb1c

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

drivers/leds/leds-blinkm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ static ssize_t show_color_common(struct device *dev, char *buf, int color)
139139
return ret;
140140
switch (color) {
141141
case RED:
142-
return scnprintf(buf, PAGE_SIZE, "%02X\n", data->red);
142+
return sysfs_emit(buf, "%02X\n", data->red);
143143
case GREEN:
144-
return scnprintf(buf, PAGE_SIZE, "%02X\n", data->green);
144+
return sysfs_emit(buf, "%02X\n", data->green);
145145
case BLUE:
146-
return scnprintf(buf, PAGE_SIZE, "%02X\n", data->blue);
146+
return sysfs_emit(buf, "%02X\n", data->blue);
147147
default:
148148
return -EINVAL;
149149
}
@@ -253,7 +253,7 @@ static DEVICE_ATTR_RW(blue);
253253
static ssize_t test_show(struct device *dev, struct device_attribute *attr,
254254
char *buf)
255255
{
256-
return scnprintf(buf, PAGE_SIZE,
256+
return sysfs_emit(buf,
257257
"#Write into test to start test sequence!#\n");
258258
}
259259

drivers/leds/leds-lm3533.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ static ssize_t show_id(struct device *dev,
314314
struct led_classdev *led_cdev = dev_get_drvdata(dev);
315315
struct lm3533_led *led = to_lm3533_led(led_cdev);
316316

317-
return scnprintf(buf, PAGE_SIZE, "%d\n", led->id);
317+
return sysfs_emit(buf, "%d\n", led->id);
318318
}
319319

320320
/*
@@ -344,7 +344,7 @@ static ssize_t show_risefalltime(struct device *dev,
344344
if (ret)
345345
return ret;
346346

347-
return scnprintf(buf, PAGE_SIZE, "%x\n", val);
347+
return sysfs_emit(buf, "%x\n", val);
348348
}
349349

350350
static ssize_t show_risetime(struct device *dev,
@@ -415,7 +415,7 @@ static ssize_t show_als_channel(struct device *dev,
415415

416416
channel = (val & LM3533_REG_CTRLBANK_BCONF_ALS_CHANNEL_MASK) + 1;
417417

418-
return scnprintf(buf, PAGE_SIZE, "%u\n", channel);
418+
return sysfs_emit(buf, "%u\n", channel);
419419
}
420420

421421
static ssize_t store_als_channel(struct device *dev,
@@ -465,7 +465,7 @@ static ssize_t show_als_en(struct device *dev,
465465

466466
enable = val & LM3533_REG_CTRLBANK_BCONF_ALS_EN_MASK;
467467

468-
return scnprintf(buf, PAGE_SIZE, "%d\n", enable);
468+
return sysfs_emit(buf, "%d\n", enable);
469469
}
470470

471471
static ssize_t store_als_en(struct device *dev,
@@ -518,7 +518,7 @@ static ssize_t show_linear(struct device *dev,
518518
else
519519
linear = 0;
520520

521-
return scnprintf(buf, PAGE_SIZE, "%x\n", linear);
521+
return sysfs_emit(buf, "%x\n", linear);
522522
}
523523

524524
static ssize_t store_linear(struct device *dev,
@@ -564,7 +564,7 @@ static ssize_t show_pwm(struct device *dev,
564564
if (ret)
565565
return ret;
566566

567-
return scnprintf(buf, PAGE_SIZE, "%u\n", val);
567+
return sysfs_emit(buf, "%u\n", val);
568568
}
569569

570570
static ssize_t store_pwm(struct device *dev,

drivers/leds/leds-lp5521.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ static ssize_t lp5521_selftest(struct device *dev,
469469
ret = lp5521_run_selftest(chip, buf);
470470
mutex_unlock(&chip->lock);
471471

472-
return scnprintf(buf, PAGE_SIZE, "%s\n", ret ? "FAIL" : "OK");
472+
return sysfs_emit(buf, "%s\n", ret ? "FAIL" : "OK");
473473
}
474474

475475
/* device attributes */

drivers/leds/leds-lp55xx-common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static ssize_t led_current_show(struct device *dev,
8888
{
8989
struct lp55xx_led *led = dev_to_lp55xx_led(dev);
9090

91-
return scnprintf(buf, PAGE_SIZE, "%d\n", led->led_current);
91+
return sysfs_emit(buf, "%d\n", led->led_current);
9292
}
9393

9494
static ssize_t led_current_store(struct device *dev,
@@ -121,7 +121,7 @@ static ssize_t max_current_show(struct device *dev,
121121
{
122122
struct lp55xx_led *led = dev_to_lp55xx_led(dev);
123123

124-
return scnprintf(buf, PAGE_SIZE, "%d\n", led->max_current);
124+
return sysfs_emit(buf, "%d\n", led->max_current);
125125
}
126126

127127
static DEVICE_ATTR_RW(led_current);

drivers/leds/trigger/ledtrig-pattern.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static ssize_t repeat_show(struct device *dev, struct device_attribute *attr,
155155

156156
mutex_unlock(&data->lock);
157157

158-
return scnprintf(buf, PAGE_SIZE, "%d\n", repeat);
158+
return sysfs_emit(buf, "%d\n", repeat);
159159
}
160160

161161
static ssize_t repeat_store(struct device *dev, struct device_attribute *attr,

0 commit comments

Comments
 (0)