diff options
author | Michael Buesch <mb@bu3sch.de> | 2007-09-27 09:10:44 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:54:20 -0400 |
commit | 47f0c502209056da728e6a306a43d5e19a37f4fa (patch) | |
tree | db62b1f47c0c37f8c5e7943a1410737721803614 /net/mac80211/ieee80211_led.c | |
parent | ddd3d2be85e3207c47f2b3c431723e6c758b4b0d (diff) |
[MAC80211]: Add association LED trigger
Many devices have LEDs to indicate the link status.
Export this functionality to drivers.
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mac80211/ieee80211_led.c')
-rw-r--r-- | net/mac80211/ieee80211_led.c | 67 |
1 files changed, 51 insertions, 16 deletions
diff --git a/net/mac80211/ieee80211_led.c b/net/mac80211/ieee80211_led.c index 719d75b20707..4cf89af9d100 100644 --- a/net/mac80211/ieee80211_led.c +++ b/net/mac80211/ieee80211_led.c | |||
@@ -33,33 +33,58 @@ void ieee80211_led_tx(struct ieee80211_local *local, int q) | |||
33 | led_trigger_event(local->tx_led, LED_FULL); | 33 | led_trigger_event(local->tx_led, LED_FULL); |
34 | } | 34 | } |
35 | 35 | ||
36 | void ieee80211_led_assoc(struct ieee80211_local *local, bool associated) | ||
37 | { | ||
38 | if (unlikely(!local->assoc_led)) | ||
39 | return; | ||
40 | if (associated) | ||
41 | led_trigger_event(local->assoc_led, LED_FULL); | ||
42 | else | ||
43 | led_trigger_event(local->assoc_led, LED_OFF); | ||
44 | } | ||
45 | |||
36 | void ieee80211_led_init(struct ieee80211_local *local) | 46 | void ieee80211_led_init(struct ieee80211_local *local) |
37 | { | 47 | { |
38 | local->rx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL); | 48 | local->rx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL); |
39 | if (!local->rx_led) | 49 | if (local->rx_led) { |
40 | return; | 50 | snprintf(local->rx_led_name, sizeof(local->rx_led_name), |
41 | snprintf(local->rx_led_name, sizeof(local->rx_led_name), | 51 | "%srx", wiphy_name(local->hw.wiphy)); |
42 | "%srx", wiphy_name(local->hw.wiphy)); | 52 | local->rx_led->name = local->rx_led_name; |
43 | local->rx_led->name = local->rx_led_name; | 53 | if (led_trigger_register(local->rx_led)) { |
44 | if (led_trigger_register(local->rx_led)) { | 54 | kfree(local->rx_led); |
45 | kfree(local->rx_led); | 55 | local->rx_led = NULL; |
46 | local->rx_led = NULL; | 56 | } |
47 | } | 57 | } |
48 | 58 | ||
49 | local->tx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL); | 59 | local->tx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL); |
50 | if (!local->tx_led) | 60 | if (local->tx_led) { |
51 | return; | 61 | snprintf(local->tx_led_name, sizeof(local->tx_led_name), |
52 | snprintf(local->tx_led_name, sizeof(local->tx_led_name), | 62 | "%stx", wiphy_name(local->hw.wiphy)); |
53 | "%stx", wiphy_name(local->hw.wiphy)); | 63 | local->tx_led->name = local->tx_led_name; |
54 | local->tx_led->name = local->tx_led_name; | 64 | if (led_trigger_register(local->tx_led)) { |
55 | if (led_trigger_register(local->tx_led)) { | 65 | kfree(local->tx_led); |
56 | kfree(local->tx_led); | 66 | local->tx_led = NULL; |
57 | local->tx_led = NULL; | 67 | } |
68 | } | ||
69 | |||
70 | local->assoc_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL); | ||
71 | if (local->assoc_led) { | ||
72 | snprintf(local->assoc_led_name, sizeof(local->assoc_led_name), | ||
73 | "%sassoc", wiphy_name(local->hw.wiphy)); | ||
74 | local->assoc_led->name = local->assoc_led_name; | ||
75 | if (led_trigger_register(local->assoc_led)) { | ||
76 | kfree(local->assoc_led); | ||
77 | local->assoc_led = NULL; | ||
78 | } | ||
58 | } | 79 | } |
59 | } | 80 | } |
60 | 81 | ||
61 | void ieee80211_led_exit(struct ieee80211_local *local) | 82 | void ieee80211_led_exit(struct ieee80211_local *local) |
62 | { | 83 | { |
84 | if (local->assoc_led) { | ||
85 | led_trigger_unregister(local->assoc_led); | ||
86 | kfree(local->assoc_led); | ||
87 | } | ||
63 | if (local->tx_led) { | 88 | if (local->tx_led) { |
64 | led_trigger_unregister(local->tx_led); | 89 | led_trigger_unregister(local->tx_led); |
65 | kfree(local->tx_led); | 90 | kfree(local->tx_led); |
@@ -70,6 +95,16 @@ void ieee80211_led_exit(struct ieee80211_local *local) | |||
70 | } | 95 | } |
71 | } | 96 | } |
72 | 97 | ||
98 | char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw) | ||
99 | { | ||
100 | struct ieee80211_local *local = hw_to_local(hw); | ||
101 | |||
102 | if (local->assoc_led) | ||
103 | return local->assoc_led_name; | ||
104 | return NULL; | ||
105 | } | ||
106 | EXPORT_SYMBOL(__ieee80211_get_assoc_led_name); | ||
107 | |||
73 | char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw) | 108 | char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw) |
74 | { | 109 | { |
75 | struct ieee80211_local *local = hw_to_local(hw); | 110 | struct ieee80211_local *local = hw_to_local(hw); |