RFKILL: set the status of the leds on activation.
authorDmitry Baryshkov <dbaryshkov@gmail.com>
Tue, 22 Jul 2008 10:21:59 +0000 (14:21 +0400)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 1 Aug 2008 19:31:33 +0000 (15:31 -0400)
Provide default activate function to set the state of the led
when the led becomes bound to the trigger

Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/rfkill/rfkill.c

index 5c24f36471894f7fa7a14da2757c517d5afe3076..d2d45655cd1a69582a8fdc2948c69c652ed0fd19 100644 (file)
@@ -105,6 +105,16 @@ static void rfkill_led_trigger(struct rfkill *rfkill,
 #endif /* CONFIG_RFKILL_LEDS */
 }
 
+#ifdef CONFIG_RFKILL_LEDS
+static void rfkill_led_trigger_activate(struct led_classdev *led)
+{
+       struct rfkill *rfkill = container_of(led->trigger,
+                       struct rfkill, led_trigger);
+
+       rfkill_led_trigger(rfkill, rfkill->state);
+}
+#endif /* CONFIG_RFKILL_LEDS */
+
 static void notify_rfkill_state_change(struct rfkill *rfkill)
 {
        blocking_notifier_call_chain(&rfkill_notifier_list,
@@ -591,6 +601,8 @@ static void rfkill_led_trigger_register(struct rfkill *rfkill)
 
        if (!rfkill->led_trigger.name)
                rfkill->led_trigger.name = rfkill->dev.bus_id;
+       if (!rfkill->led_trigger.activate)
+               rfkill->led_trigger.activate = rfkill_led_trigger_activate;
        error = led_trigger_register(&rfkill->led_trigger);
        if (error)
                rfkill->led_trigger.name = NULL;