summaryrefslogtreecommitdiff
path: root/drivers/leds/leds-wm831x-status.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-06-06 02:07:55 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2018-06-06 02:07:55 +0300
commit5231804cf9e584f3e7e763a0d6d2fffe011c1bce (patch)
tree3cf92cadb21c9a88e1ee2a120647458a6b470246 /drivers/leds/leds-wm831x-status.c
parent2158091d9cda6f126f71973667e8a9fc1e795d03 (diff)
parent6d71021ab3b0bd6ff98270343353b03dfae5d550 (diff)
downloadlinux-5231804cf9e584f3e7e763a0d6d2fffe011c1bce.tar.xz
Merge tag 'leds_for_4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds
Pull LED updates from Jacek Anaszewski: "This was quite a fruitful cycle, taking into account usual traffic on linux-leds list, as we managed to merge three new LED class drivers. New LED class drivers with related DT bindings: - add LED driver for CR0014114 board - add Spreadtrum SC27xx breathing light controller driver - introduce the lm3601x LED driver LED class fix: - ensure workqueue is initialized before setting brightness Improvements and fixes to existing LED class drivers: - fix return value check in sc27xx_led_probe() - use sysfs_match_string() helper in wm831x_status_src_store()" * tag 'leds_for_4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds: leds: class: ensure workqueue is initialized before setting brightness leds: lm3601x: Introduce the lm3601x LED driver dt: bindings: lm3601x: Introduce the lm3601x driver leds: sc27xx: Fix return value check in sc27xx_led_probe() leds: Add Spreadtrum SC27xx breathing light controller driver dt-bindings: leds: Add SC27xx breathing light controller documentation leds: wm831x-status: Use sysfs_match_string() helper leds: add LED driver for CR0014114 board dt-bindings: Add vendor prefix and docs for CR0014114
Diffstat (limited to 'drivers/leds/leds-wm831x-status.c')
-rw-r--r--drivers/leds/leds-wm831x-status.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/drivers/leds/leds-wm831x-status.c b/drivers/leds/leds-wm831x-status.c
index be93b20e792a..c5798b92e4d3 100644
--- a/drivers/leds/leds-wm831x-status.c
+++ b/drivers/leds/leds-wm831x-status.c
@@ -188,24 +188,14 @@ static ssize_t wm831x_status_src_store(struct device *dev,
{
struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct wm831x_status *led = to_wm831x_status(led_cdev);
- char name[20];
int i;
- size_t len;
- name[sizeof(name) - 1] = '\0';
- strncpy(name, buf, sizeof(name) - 1);
- len = strlen(name);
-
- if (len && name[len - 1] == '\n')
- name[len - 1] = '\0';
-
- for (i = 0; i < ARRAY_SIZE(led_src_texts); i++) {
- if (!strcmp(name, led_src_texts[i])) {
- mutex_lock(&led->mutex);
- led->src = i;
- mutex_unlock(&led->mutex);
- wm831x_status_set(led);
- }
+ i = sysfs_match_string(led_src_texts, buf);
+ if (i >= 0) {
+ mutex_lock(&led->mutex);
+ led->src = i;
+ mutex_unlock(&led->mutex);
+ wm831x_status_set(led);
}
return size;