diff options
author | Shuah Khan <shuahkhan@gmail.com> | 2012-05-29 18:07:28 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-29 19:22:31 -0400 |
commit | 03c091e5b726ada6aaf9af1d0e973679099101e4 (patch) | |
tree | acbe5d242a76b2296d15804c4cc2766ca1295d4b /drivers/leds | |
parent | b00961824a33aadec4a825eaeccfbe3db8ec7032 (diff) |
leds: change existing triggers to use activated flag
Change existing triggers backlight, gpio, and heartbeat to use the new
->activated flag to set activate successful status in their activate
routines and check it in their deactivate routines to do cleanup.
Signed-off-by: Shuah Khan <shuahkhan@gmail.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/ledtrig-backlight.c | 4 | ||||
-rw-r--r-- | drivers/leds/ledtrig-gpio.c | 4 | ||||
-rw-r--r-- | drivers/leds/ledtrig-heartbeat.c | 4 |
3 files changed, 9 insertions, 3 deletions
diff --git a/drivers/leds/ledtrig-backlight.c b/drivers/leds/ledtrig-backlight.c index 2b513a2ad7de..e2726867c5d4 100644 --- a/drivers/leds/ledtrig-backlight.c +++ b/drivers/leds/ledtrig-backlight.c | |||
@@ -120,6 +120,7 @@ static void bl_trig_activate(struct led_classdev *led) | |||
120 | ret = fb_register_client(&n->notifier); | 120 | ret = fb_register_client(&n->notifier); |
121 | if (ret) | 121 | if (ret) |
122 | dev_err(led->dev, "unable to register backlight trigger\n"); | 122 | dev_err(led->dev, "unable to register backlight trigger\n"); |
123 | led->activated = true; | ||
123 | 124 | ||
124 | return; | 125 | return; |
125 | 126 | ||
@@ -133,10 +134,11 @@ static void bl_trig_deactivate(struct led_classdev *led) | |||
133 | struct bl_trig_notifier *n = | 134 | struct bl_trig_notifier *n = |
134 | (struct bl_trig_notifier *) led->trigger_data; | 135 | (struct bl_trig_notifier *) led->trigger_data; |
135 | 136 | ||
136 | if (n) { | 137 | if (led->activated) { |
137 | device_remove_file(led->dev, &dev_attr_inverted); | 138 | device_remove_file(led->dev, &dev_attr_inverted); |
138 | fb_unregister_client(&n->notifier); | 139 | fb_unregister_client(&n->notifier); |
139 | kfree(n); | 140 | kfree(n); |
141 | led->activated = false; | ||
140 | } | 142 | } |
141 | } | 143 | } |
142 | 144 | ||
diff --git a/drivers/leds/ledtrig-gpio.c b/drivers/leds/ledtrig-gpio.c index ecc4bf3f37a9..f057c101b896 100644 --- a/drivers/leds/ledtrig-gpio.c +++ b/drivers/leds/ledtrig-gpio.c | |||
@@ -200,6 +200,7 @@ static void gpio_trig_activate(struct led_classdev *led) | |||
200 | gpio_data->led = led; | 200 | gpio_data->led = led; |
201 | led->trigger_data = gpio_data; | 201 | led->trigger_data = gpio_data; |
202 | INIT_WORK(&gpio_data->work, gpio_trig_work); | 202 | INIT_WORK(&gpio_data->work, gpio_trig_work); |
203 | led->activated = true; | ||
203 | 204 | ||
204 | return; | 205 | return; |
205 | 206 | ||
@@ -217,7 +218,7 @@ static void gpio_trig_deactivate(struct led_classdev *led) | |||
217 | { | 218 | { |
218 | struct gpio_trig_data *gpio_data = led->trigger_data; | 219 | struct gpio_trig_data *gpio_data = led->trigger_data; |
219 | 220 | ||
220 | if (gpio_data) { | 221 | if (led->activated) { |
221 | device_remove_file(led->dev, &dev_attr_gpio); | 222 | device_remove_file(led->dev, &dev_attr_gpio); |
222 | device_remove_file(led->dev, &dev_attr_inverted); | 223 | device_remove_file(led->dev, &dev_attr_inverted); |
223 | device_remove_file(led->dev, &dev_attr_desired_brightness); | 224 | device_remove_file(led->dev, &dev_attr_desired_brightness); |
@@ -225,6 +226,7 @@ static void gpio_trig_deactivate(struct led_classdev *led) | |||
225 | if (gpio_data->gpio != 0) | 226 | if (gpio_data->gpio != 0) |
226 | free_irq(gpio_to_irq(gpio_data->gpio), led); | 227 | free_irq(gpio_to_irq(gpio_data->gpio), led); |
227 | kfree(gpio_data); | 228 | kfree(gpio_data); |
229 | led->activated = false; | ||
228 | } | 230 | } |
229 | } | 231 | } |
230 | 232 | ||
diff --git a/drivers/leds/ledtrig-heartbeat.c b/drivers/leds/ledtrig-heartbeat.c index 759c0bba4a8f..1aacf4c6c3e4 100644 --- a/drivers/leds/ledtrig-heartbeat.c +++ b/drivers/leds/ledtrig-heartbeat.c | |||
@@ -83,15 +83,17 @@ static void heartbeat_trig_activate(struct led_classdev *led_cdev) | |||
83 | led_heartbeat_function, (unsigned long) led_cdev); | 83 | led_heartbeat_function, (unsigned long) led_cdev); |
84 | heartbeat_data->phase = 0; | 84 | heartbeat_data->phase = 0; |
85 | led_heartbeat_function(heartbeat_data->timer.data); | 85 | led_heartbeat_function(heartbeat_data->timer.data); |
86 | led_cdev->activated = true; | ||
86 | } | 87 | } |
87 | 88 | ||
88 | static void heartbeat_trig_deactivate(struct led_classdev *led_cdev) | 89 | static void heartbeat_trig_deactivate(struct led_classdev *led_cdev) |
89 | { | 90 | { |
90 | struct heartbeat_trig_data *heartbeat_data = led_cdev->trigger_data; | 91 | struct heartbeat_trig_data *heartbeat_data = led_cdev->trigger_data; |
91 | 92 | ||
92 | if (heartbeat_data) { | 93 | if (led_cdev->activated) { |
93 | del_timer_sync(&heartbeat_data->timer); | 94 | del_timer_sync(&heartbeat_data->timer); |
94 | kfree(heartbeat_data); | 95 | kfree(heartbeat_data); |
96 | led_cdev->activated = false; | ||
95 | } | 97 | } |
96 | } | 98 | } |
97 | 99 | ||