aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/ledtrig-timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/leds/ledtrig-timer.c')
-rw-r--r--drivers/leds/ledtrig-timer.c54
1 files changed, 23 insertions, 31 deletions
diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
index 328c64c0841c..9010f7abaf2c 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++;
41
42 if (count == size) {
43 led_blink_set(led_cdev, &state, &led_cdev->blink_delay_off);
44 led_cdev->blink_delay_on = state;
45 ret = count;
46 }
47 40
48 return ret; 41 led_blink_set(led_cdev, &state, &led_cdev->blink_delay_off);
42 led_cdev->blink_delay_on = state;
43
44 return size;
49} 45}
50 46
51static ssize_t led_delay_off_show(struct device *dev, 47static 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);
66 size_t count = after - buf;
67
68 if (isspace(*after))
69 count++;
70
71 if (count == size) {
72 led_blink_set(led_cdev, &led_cdev->blink_delay_on, &state);
73 led_cdev->blink_delay_off = state;
74 ret = count;
75 }
76 61
77 return ret; 62 ret = kstrtoul(buf, 10, &state);
63 if (ret)
64 return ret;
65
66 led_blink_set(led_cdev, &led_cdev->blink_delay_on, &state);
67 led_cdev->blink_delay_off = state;
68
69 return size;
78} 70}
79 71
80static DEVICE_ATTR(delay_on, 0644, led_delay_on_show, led_delay_on_store); 72static DEVICE_ATTR(delay_on, 0644, led_delay_on_show, led_delay_on_store);
@@ -95,8 +87,7 @@ static void timer_trig_activate(struct led_classdev *led_cdev)
95 87
96 led_blink_set(led_cdev, &led_cdev->blink_delay_on, 88 led_blink_set(led_cdev, &led_cdev->blink_delay_on,
97 &led_cdev->blink_delay_off); 89 &led_cdev->blink_delay_off);
98 90 led_cdev->activated = true;
99 led_cdev->trigger_data = (void *)1;
100 91
101 return; 92 return;
102 93
@@ -106,9 +97,10 @@ err_out_delayon:
106 97
107static void timer_trig_deactivate(struct led_classdev *led_cdev) 98static void timer_trig_deactivate(struct led_classdev *led_cdev)
108{ 99{
109 if (led_cdev->trigger_data) { 100 if (led_cdev->activated) {
110 device_remove_file(led_cdev->dev, &dev_attr_delay_on); 101 device_remove_file(led_cdev->dev, &dev_attr_delay_on);
111 device_remove_file(led_cdev->dev, &dev_attr_delay_off); 102 device_remove_file(led_cdev->dev, &dev_attr_delay_off);
103 led_cdev->activated = false;
112 } 104 }
113 105
114 /* Stop blinking */ 106 /* Stop blinking */