diff options
author | Ivo van Doorn <ivdoorn@gmail.com> | 2008-01-07 13:45:24 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:01:04 -0500 |
commit | cdcb006fbe7a74b5f7827f5c5c27e11399a2fab7 (patch) | |
tree | 6141a5b4315775bea971d3457191071d36061822 /net | |
parent | df26e7ea049abe5104062f1f3e9ee7ede9d5104f (diff) |
mac80211: Add radio led trigger
Some devices have a seperate LED which indicates if the radio is
enabled or not. This adds a LED trigger to mac80211 where drivers
can hook into when they are interested in radio status changes.
v2: Check hw.conf.radio_enabled when calling start().
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/mac80211/ieee80211.c | 3 | ||||
-rw-r--r-- | net/mac80211/ieee80211_i.h | 5 | ||||
-rw-r--r-- | net/mac80211/ieee80211_ioctl.c | 2 | ||||
-rw-r--r-- | net/mac80211/ieee80211_led.c | 35 | ||||
-rw-r--r-- | net/mac80211/ieee80211_led.h | 6 |
5 files changed, 49 insertions, 2 deletions
diff --git a/net/mac80211/ieee80211.c b/net/mac80211/ieee80211.c index 8ba69ae676ca..4807e5215a79 100644 --- a/net/mac80211/ieee80211.c +++ b/net/mac80211/ieee80211.c | |||
@@ -219,6 +219,7 @@ static int ieee80211_open(struct net_device *dev) | |||
219 | if (res) | 219 | if (res) |
220 | return res; | 220 | return res; |
221 | ieee80211_hw_config(local); | 221 | ieee80211_hw_config(local); |
222 | ieee80211_led_radio(local, local->hw.conf.radio_enabled); | ||
222 | } | 223 | } |
223 | 224 | ||
224 | switch (sdata->type) { | 225 | switch (sdata->type) { |
@@ -392,6 +393,8 @@ static int ieee80211_stop(struct net_device *dev) | |||
392 | if (local->ops->stop) | 393 | if (local->ops->stop) |
393 | local->ops->stop(local_to_hw(local)); | 394 | local->ops->stop(local_to_hw(local)); |
394 | 395 | ||
396 | ieee80211_led_radio(local, 0); | ||
397 | |||
395 | tasklet_disable(&local->tx_pending_tasklet); | 398 | tasklet_disable(&local->tx_pending_tasklet); |
396 | tasklet_disable(&local->tasklet); | 399 | tasklet_disable(&local->tasklet); |
397 | } | 400 | } |
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 662e69ef7eed..b898b316bda1 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -500,8 +500,9 @@ struct ieee80211_local { | |||
500 | 500 | ||
501 | #ifdef CONFIG_MAC80211_LEDS | 501 | #ifdef CONFIG_MAC80211_LEDS |
502 | int tx_led_counter, rx_led_counter; | 502 | int tx_led_counter, rx_led_counter; |
503 | struct led_trigger *tx_led, *rx_led, *assoc_led; | 503 | struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led; |
504 | char tx_led_name[32], rx_led_name[32], assoc_led_name[32]; | 504 | char tx_led_name[32], rx_led_name[32], |
505 | assoc_led_name[32], radio_led_name[32]; | ||
505 | #endif | 506 | #endif |
506 | 507 | ||
507 | u32 channel_use; | 508 | u32 channel_use; |
diff --git a/net/mac80211/ieee80211_ioctl.c b/net/mac80211/ieee80211_ioctl.c index 04ddce76135b..2604e21c05a8 100644 --- a/net/mac80211/ieee80211_ioctl.c +++ b/net/mac80211/ieee80211_ioctl.c | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include <net/mac80211.h> | 22 | #include <net/mac80211.h> |
23 | #include "ieee80211_i.h" | 23 | #include "ieee80211_i.h" |
24 | #include "ieee80211_led.h" | ||
24 | #include "ieee80211_rate.h" | 25 | #include "ieee80211_rate.h" |
25 | #include "wpa.h" | 26 | #include "wpa.h" |
26 | #include "aes_ccm.h" | 27 | #include "aes_ccm.h" |
@@ -652,6 +653,7 @@ static int ieee80211_ioctl_siwtxpower(struct net_device *dev, | |||
652 | if (local->hw.conf.radio_enabled != !(data->txpower.disabled)) { | 653 | if (local->hw.conf.radio_enabled != !(data->txpower.disabled)) { |
653 | local->hw.conf.radio_enabled = !(data->txpower.disabled); | 654 | local->hw.conf.radio_enabled = !(data->txpower.disabled); |
654 | need_reconfig = 1; | 655 | need_reconfig = 1; |
656 | ieee80211_led_radio(local, local->hw.conf.radio_enabled); | ||
655 | } | 657 | } |
656 | 658 | ||
657 | if (need_reconfig) { | 659 | if (need_reconfig) { |
diff --git a/net/mac80211/ieee80211_led.c b/net/mac80211/ieee80211_led.c index 4cf89af9d100..f401484ab6d7 100644 --- a/net/mac80211/ieee80211_led.c +++ b/net/mac80211/ieee80211_led.c | |||
@@ -43,6 +43,16 @@ void ieee80211_led_assoc(struct ieee80211_local *local, bool associated) | |||
43 | led_trigger_event(local->assoc_led, LED_OFF); | 43 | led_trigger_event(local->assoc_led, LED_OFF); |
44 | } | 44 | } |
45 | 45 | ||
46 | void ieee80211_led_radio(struct ieee80211_local *local, bool enabled) | ||
47 | { | ||
48 | if (unlikely(!local->radio_led)) | ||
49 | return; | ||
50 | if (enabled) | ||
51 | led_trigger_event(local->radio_led, LED_FULL); | ||
52 | else | ||
53 | led_trigger_event(local->radio_led, LED_OFF); | ||
54 | } | ||
55 | |||
46 | void ieee80211_led_init(struct ieee80211_local *local) | 56 | void ieee80211_led_init(struct ieee80211_local *local) |
47 | { | 57 | { |
48 | local->rx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL); | 58 | local->rx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL); |
@@ -77,10 +87,25 @@ void ieee80211_led_init(struct ieee80211_local *local) | |||
77 | local->assoc_led = NULL; | 87 | local->assoc_led = NULL; |
78 | } | 88 | } |
79 | } | 89 | } |
90 | |||
91 | local->radio_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL); | ||
92 | if (local->radio_led) { | ||
93 | snprintf(local->radio_led_name, sizeof(local->radio_led_name), | ||
94 | "%sradio", wiphy_name(local->hw.wiphy)); | ||
95 | local->radio_led->name = local->radio_led_name; | ||
96 | if (led_trigger_register(local->radio_led)) { | ||
97 | kfree(local->radio_led); | ||
98 | local->radio_led = NULL; | ||
99 | } | ||
100 | } | ||
80 | } | 101 | } |
81 | 102 | ||
82 | void ieee80211_led_exit(struct ieee80211_local *local) | 103 | void ieee80211_led_exit(struct ieee80211_local *local) |
83 | { | 104 | { |
105 | if (local->radio_led) { | ||
106 | led_trigger_unregister(local->radio_led); | ||
107 | kfree(local->radio_led); | ||
108 | } | ||
84 | if (local->assoc_led) { | 109 | if (local->assoc_led) { |
85 | led_trigger_unregister(local->assoc_led); | 110 | led_trigger_unregister(local->assoc_led); |
86 | kfree(local->assoc_led); | 111 | kfree(local->assoc_led); |
@@ -95,6 +120,16 @@ void ieee80211_led_exit(struct ieee80211_local *local) | |||
95 | } | 120 | } |
96 | } | 121 | } |
97 | 122 | ||
123 | char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw) | ||
124 | { | ||
125 | struct ieee80211_local *local = hw_to_local(hw); | ||
126 | |||
127 | if (local->radio_led) | ||
128 | return local->radio_led_name; | ||
129 | return NULL; | ||
130 | } | ||
131 | EXPORT_SYMBOL(__ieee80211_get_radio_led_name); | ||
132 | |||
98 | char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw) | 133 | char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw) |
99 | { | 134 | { |
100 | struct ieee80211_local *local = hw_to_local(hw); | 135 | struct ieee80211_local *local = hw_to_local(hw); |
diff --git a/net/mac80211/ieee80211_led.h b/net/mac80211/ieee80211_led.h index 0feb22619835..77b1e1ba6039 100644 --- a/net/mac80211/ieee80211_led.h +++ b/net/mac80211/ieee80211_led.h | |||
@@ -16,6 +16,8 @@ extern void ieee80211_led_rx(struct ieee80211_local *local); | |||
16 | extern void ieee80211_led_tx(struct ieee80211_local *local, int q); | 16 | extern void ieee80211_led_tx(struct ieee80211_local *local, int q); |
17 | extern void ieee80211_led_assoc(struct ieee80211_local *local, | 17 | extern void ieee80211_led_assoc(struct ieee80211_local *local, |
18 | bool associated); | 18 | bool associated); |
19 | extern void ieee80211_led_radio(struct ieee80211_local *local, | ||
20 | bool enabled); | ||
19 | extern void ieee80211_led_init(struct ieee80211_local *local); | 21 | extern void ieee80211_led_init(struct ieee80211_local *local); |
20 | extern void ieee80211_led_exit(struct ieee80211_local *local); | 22 | extern void ieee80211_led_exit(struct ieee80211_local *local); |
21 | #else | 23 | #else |
@@ -29,6 +31,10 @@ static inline void ieee80211_led_assoc(struct ieee80211_local *local, | |||
29 | bool associated) | 31 | bool associated) |
30 | { | 32 | { |
31 | } | 33 | } |
34 | static inline void ieee80211_led_radio(struct ieee80211_local *local, | ||
35 | bool enabled) | ||
36 | { | ||
37 | } | ||
32 | static inline void ieee80211_led_init(struct ieee80211_local *local) | 38 | static inline void ieee80211_led_init(struct ieee80211_local *local) |
33 | { | 39 | { |
34 | } | 40 | } |