diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2018-05-03 21:10:03 +0300 |
---|---|---|
committer | Jacek Anaszewski <jacek.anaszewski@gmail.com> | 2018-05-03 21:50:13 +0200 |
commit | d54e5b522202b287132b9f24569b9c107f6af36d (patch) | |
tree | defae17828ad0ef3dd49893151d8b893d010f879 /drivers | |
parent | 9e50d5fb0d1874e7e8750e58b8ee7a27ed63f748 (diff) |
leds: wm831x-status: Use sysfs_match_string() helper
Use sysfs_match_string() helper instead of open coded variant.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/leds/leds-wm831x-status.c | 22 |
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; |