]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
leds: change existing triggers to use activated flag
authorShuah Khan <shuahkhan@gmail.com>
Tue, 29 May 2012 22:07:28 +0000 (15:07 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 29 May 2012 23:22:31 +0000 (16:22 -0700)
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>
drivers/leds/ledtrig-backlight.c
drivers/leds/ledtrig-gpio.c
drivers/leds/ledtrig-heartbeat.c

index 2b513a2ad7dec3b7d81b934e8d852903f73548c9..e2726867c5d42c7a5f2cc6c37b786d922eb0b883 100644 (file)
@@ -120,6 +120,7 @@ static void bl_trig_activate(struct led_classdev *led)
        ret = fb_register_client(&n->notifier);
        if (ret)
                dev_err(led->dev, "unable to register backlight trigger\n");
+       led->activated = true;
 
        return;
 
@@ -133,10 +134,11 @@ static void bl_trig_deactivate(struct led_classdev *led)
        struct bl_trig_notifier *n =
                (struct bl_trig_notifier *) led->trigger_data;
 
-       if (n) {
+       if (led->activated) {
                device_remove_file(led->dev, &dev_attr_inverted);
                fb_unregister_client(&n->notifier);
                kfree(n);
+               led->activated = false;
        }
 }
 
index ecc4bf3f37a937d74ab71f6c6cf91c9fc3763eb9..f057c101b896e56561a41f54809e1a10e52d0aaa 100644 (file)
@@ -200,6 +200,7 @@ static void gpio_trig_activate(struct led_classdev *led)
        gpio_data->led = led;
        led->trigger_data = gpio_data;
        INIT_WORK(&gpio_data->work, gpio_trig_work);
+       led->activated = true;
 
        return;
 
@@ -217,7 +218,7 @@ static void gpio_trig_deactivate(struct led_classdev *led)
 {
        struct gpio_trig_data *gpio_data = led->trigger_data;
 
-       if (gpio_data) {
+       if (led->activated) {
                device_remove_file(led->dev, &dev_attr_gpio);
                device_remove_file(led->dev, &dev_attr_inverted);
                device_remove_file(led->dev, &dev_attr_desired_brightness);
@@ -225,6 +226,7 @@ static void gpio_trig_deactivate(struct led_classdev *led)
                if (gpio_data->gpio != 0)
                        free_irq(gpio_to_irq(gpio_data->gpio), led);
                kfree(gpio_data);
+               led->activated = false;
        }
 }
 
index 759c0bba4a8fa54d95b12d5434ad72a643a25f88..1aacf4c6c3e42156d4ee396b5b21d75ee153754c 100644 (file)
@@ -83,15 +83,17 @@ static void heartbeat_trig_activate(struct led_classdev *led_cdev)
                    led_heartbeat_function, (unsigned long) led_cdev);
        heartbeat_data->phase = 0;
        led_heartbeat_function(heartbeat_data->timer.data);
+       led_cdev->activated = true;
 }
 
 static void heartbeat_trig_deactivate(struct led_classdev *led_cdev)
 {
        struct heartbeat_trig_data *heartbeat_data = led_cdev->trigger_data;
 
-       if (heartbeat_data) {
+       if (led_cdev->activated) {
                del_timer_sync(&heartbeat_data->timer);
                kfree(heartbeat_data);
+               led_cdev->activated = false;
        }
 }