ar9170: fix LED power state handling
authorChristian Lamparter <chunkeey@web.de>
Mon, 25 May 2009 19:51:19 +0000 (21:51 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 3 Jun 2009 18:05:15 +0000 (14:05 -0400)
This patch fixes a minor visual bug in the led code, which
left the LED in the wrong power state when it was toggled
in a _unexpected_ way (e.g: enabling the LED twice).

Signed-off-by: Christian Lamparter <chunkeey@web.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ar9170/ar9170.h
drivers/net/wireless/ath/ar9170/led.c

index 1247dcb9081afe06b616cd44ea113f05ce79b5ee..396b24016f5edc40294930bf2f03f1195efc0a0f 100644 (file)
@@ -91,6 +91,7 @@ struct ar9170_led {
        struct led_classdev l;
        char name[32];
        unsigned int toggled;
+       bool last_state;
        bool registered;
 };
 
index 341cead7f606d3a96fe603171a217c00c1a17fb5..3c8a5728920dde76e8dc87df0160a9a5db1d4711 100644 (file)
@@ -101,9 +101,12 @@ static void ar9170_led_brightness_set(struct led_classdev *led,
        struct ar9170_led *arl = container_of(led, struct ar9170_led, l);
        struct ar9170 *ar = arl->ar;
 
-       arl->toggled++;
+       if (arl->last_state != !!brightness) {
+               arl->toggled++;
+               arl->last_state = !!brightness;
+       }
 
-       if (likely(IS_ACCEPTING_CMD(ar) && brightness))
+       if (likely(IS_ACCEPTING_CMD(ar) && arl->toggled))
                queue_delayed_work(ar->hw->workqueue, &ar->led_work, HZ/10);
 }