]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
leds: simple_strtoul() cleanup
authorShuah Khan <shuahkhan@gmail.com>
Tue, 29 May 2012 22:07:26 +0000 (15:07 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 29 May 2012 23:22:31 +0000 (16:22 -0700)
led-class.c and ledtrig-timer.c still use simple_strtoul().  Change them
to use kstrtoul() instead of obsolete simple_strtoul().

Also fix the existing int ret declaration to be ssize_t to match the
return type for _store functions in ledtrig-timer.c.

Signed-off-by: Shuah Khan <shuahkhan@gmail.com>
Cc: Joe Perches <joe@perches.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Bryan Wu <bryan.wu@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/leds/led-class.c
drivers/leds/ledtrig-timer.c

index 5bff8439dc68a7e8c6424f0cbed3746cd9820efb..8ee92c81aec2c1577c3fb1cfd173d8835c2c7725 100644 (file)
@@ -44,23 +44,18 @@ static ssize_t led_brightness_store(struct device *dev,
                struct device_attribute *attr, const char *buf, size_t size)
 {
        struct led_classdev *led_cdev = dev_get_drvdata(dev);
+       unsigned long state;
        ssize_t ret = -EINVAL;
-       char *after;
-       unsigned long state = simple_strtoul(buf, &after, 10);
-       size_t count = after - buf;
 
-       if (isspace(*after))
-               count++;
+       ret = kstrtoul(buf, 10, &state);
+       if (ret)
+               return ret;
 
-       if (count == size) {
-               ret = count;
+       if (state == LED_OFF)
+               led_trigger_remove(led_cdev);
+       led_set_brightness(led_cdev, state);
 
-               if (state == LED_OFF)
-                       led_trigger_remove(led_cdev);
-               led_set_brightness(led_cdev, state);
-       }
-
-       return ret;
+       return size;
 }
 
 static ssize_t led_max_brightness_show(struct device *dev,
index 328c64c0841cdda76f0d4ac7ed2b13cf801bec7b..b32d5eae82271974aef59c14e7f156542cd236b6 100644 (file)
@@ -31,21 +31,17 @@ static ssize_t led_delay_on_store(struct device *dev,
                struct device_attribute *attr, const char *buf, size_t size)
 {
        struct led_classdev *led_cdev = dev_get_drvdata(dev);
-       int ret = -EINVAL;
-       char *after;
-       unsigned long state = simple_strtoul(buf, &after, 10);
-       size_t count = after - buf;
-
-       if (isspace(*after))
-               count++;
-
-       if (count == size) {
-               led_blink_set(led_cdev, &state, &led_cdev->blink_delay_off);
-               led_cdev->blink_delay_on = state;
-               ret = count;
-       }
+       unsigned long state;
+       ssize_t ret = -EINVAL;
+
+       ret = kstrtoul(buf, 10, &state);
+       if (ret)
+               return ret;
+
+       led_blink_set(led_cdev, &state, &led_cdev->blink_delay_off);
+       led_cdev->blink_delay_on = state;
 
-       return ret;
+       return size;
 }
 
 static ssize_t led_delay_off_show(struct device *dev,
@@ -60,21 +56,17 @@ static ssize_t led_delay_off_store(struct device *dev,
                struct device_attribute *attr, const char *buf, size_t size)
 {
        struct led_classdev *led_cdev = dev_get_drvdata(dev);
-       int ret = -EINVAL;
-       char *after;
-       unsigned long state = simple_strtoul(buf, &after, 10);
-       size_t count = after - buf;
-
-       if (isspace(*after))
-               count++;
-
-       if (count == size) {
-               led_blink_set(led_cdev, &led_cdev->blink_delay_on, &state);
-               led_cdev->blink_delay_off = state;
-               ret = count;
-       }
+       unsigned long state;
+       ssize_t ret = -EINVAL;
+
+       ret = kstrtoul(buf, 10, &state);
+       if (ret)
+               return ret;
+
+       led_blink_set(led_cdev, &led_cdev->blink_delay_on, &state);
+       led_cdev->blink_delay_off = state;
 
-       return ret;
+       return size;
 }
 
 static DEVICE_ATTR(delay_on, 0644, led_delay_on_show, led_delay_on_store);