diff options
author | Shuah Khan <shuahkhan@gmail.com> | 2012-05-29 18:07:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-29 19:22:31 -0400 |
commit | 872b86be0a285b11b03614456b67fdaf78e86f3d (patch) | |
tree | 1bd709cf5e71997b290e3eaf9a4aa8dd16dc49a9 /drivers/leds | |
parent | 5ba736311bf6fea25c97e868b7de6d3de8800aba (diff) |
leds: simple_strtoul() cleanup
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>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/led-class.c | 21 | ||||
-rw-r--r-- | drivers/leds/ledtrig-timer.c | 48 |
2 files changed, 28 insertions, 41 deletions
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index 5bff8439dc68..8ee92c81aec2 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c | |||
@@ -44,23 +44,18 @@ static ssize_t led_brightness_store(struct device *dev, | |||
44 | struct device_attribute *attr, const char *buf, size_t size) | 44 | struct device_attribute *attr, const char *buf, size_t size) |
45 | { | 45 | { |
46 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | 46 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
47 | unsigned long state; | ||
47 | ssize_t ret = -EINVAL; | 48 | ssize_t ret = -EINVAL; |
48 | char *after; | ||
49 | unsigned long state = simple_strtoul(buf, &after, 10); | ||
50 | size_t count = after - buf; | ||
51 | 49 | ||
52 | if (isspace(*after)) | 50 | ret = kstrtoul(buf, 10, &state); |
53 | count++; | 51 | if (ret) |
52 | return ret; | ||
54 | 53 | ||
55 | if (count == size) { | 54 | if (state == LED_OFF) |
56 | ret = count; | 55 | led_trigger_remove(led_cdev); |
56 | led_set_brightness(led_cdev, state); | ||
57 | 57 | ||
58 | if (state == LED_OFF) | 58 | return size; |
59 | led_trigger_remove(led_cdev); | ||
60 | led_set_brightness(led_cdev, state); | ||
61 | } | ||
62 | |||
63 | return ret; | ||
64 | } | 59 | } |
65 | 60 | ||
66 | static ssize_t led_max_brightness_show(struct device *dev, | 61 | static ssize_t led_max_brightness_show(struct device *dev, |
diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c index 328c64c0841c..b32d5eae8227 100644 --- a/drivers/leds/ledtrig-timer.c +++ b/drivers/leds/ledtrig-timer.c | |||
@@ -31,21 +31,17 @@ static ssize_t led_delay_on_store(struct device *dev, | |||
31 | struct device_attribute *attr, const char *buf, size_t size) | 31 | struct device_attribute *attr, const char *buf, size_t size) |
32 | { | 32 | { |
33 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | 33 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
34 | int ret = -EINVAL; | 34 | unsigned long state; |
35 | char *after; | 35 | ssize_t ret = -EINVAL; |
36 | unsigned long state = simple_strtoul(buf, &after, 10); | 36 | |
37 | size_t count = after - buf; | 37 | ret = kstrtoul(buf, 10, &state); |
38 | 38 | if (ret) | |
39 | if (isspace(*after)) | 39 | return ret; |
40 | count++; | 40 | |
41 | 41 | led_blink_set(led_cdev, &state, &led_cdev->blink_delay_off); | |
42 | if (count == size) { | 42 | led_cdev->blink_delay_on = state; |
43 | led_blink_set(led_cdev, &state, &led_cdev->blink_delay_off); | ||
44 | led_cdev->blink_delay_on = state; | ||
45 | ret = count; | ||
46 | } | ||
47 | 43 | ||
48 | return ret; | 44 | return size; |
49 | } | 45 | } |
50 | 46 | ||
51 | static ssize_t led_delay_off_show(struct device *dev, | 47 | static ssize_t led_delay_off_show(struct device *dev, |
@@ -60,21 +56,17 @@ static ssize_t led_delay_off_store(struct device *dev, | |||
60 | struct device_attribute *attr, const char *buf, size_t size) | 56 | struct device_attribute *attr, const char *buf, size_t size) |
61 | { | 57 | { |
62 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | 58 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
63 | int ret = -EINVAL; | 59 | unsigned long state; |
64 | char *after; | 60 | ssize_t ret = -EINVAL; |
65 | unsigned long state = simple_strtoul(buf, &after, 10); | 61 | |
66 | size_t count = after - buf; | 62 | ret = kstrtoul(buf, 10, &state); |
67 | 63 | if (ret) | |
68 | if (isspace(*after)) | 64 | return ret; |
69 | count++; | 65 | |
70 | 66 | led_blink_set(led_cdev, &led_cdev->blink_delay_on, &state); | |
71 | if (count == size) { | 67 | led_cdev->blink_delay_off = state; |
72 | led_blink_set(led_cdev, &led_cdev->blink_delay_on, &state); | ||
73 | led_cdev->blink_delay_off = state; | ||
74 | ret = count; | ||
75 | } | ||
76 | 68 | ||
77 | return ret; | 69 | return size; |
78 | } | 70 | } |
79 | 71 | ||
80 | static DEVICE_ATTR(delay_on, 0644, led_delay_on_show, led_delay_on_store); | 72 | static DEVICE_ATTR(delay_on, 0644, led_delay_on_show, led_delay_on_store); |