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 | |
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')
-rw-r--r-- | net/mac80211/ieee80211_i.h | 4 | ||||
-rw-r--r-- | net/mac80211/ieee80211_led.c | 67 | ||||
-rw-r--r-- | net/mac80211/ieee80211_led.h | 6 | ||||
-rw-r--r-- | net/mac80211/ieee80211_sta.c | 5 |
4 files changed, 63 insertions, 19 deletions
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index db80e1be1dcb..d34a9deca67a 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -503,8 +503,8 @@ struct ieee80211_local { | |||
503 | 503 | ||
504 | #ifdef CONFIG_MAC80211_LEDS | 504 | #ifdef CONFIG_MAC80211_LEDS |
505 | int tx_led_counter, rx_led_counter; | 505 | int tx_led_counter, rx_led_counter; |
506 | struct led_trigger *tx_led, *rx_led; | 506 | struct led_trigger *tx_led, *rx_led, *assoc_led; |
507 | char tx_led_name[32], rx_led_name[32]; | 507 | char tx_led_name[32], rx_led_name[32], assoc_led_name[32]; |
508 | #endif | 508 | #endif |
509 | 509 | ||
510 | u32 channel_use; | 510 | u32 channel_use; |
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); |
diff --git a/net/mac80211/ieee80211_led.h b/net/mac80211/ieee80211_led.h index 5c8ab8263878..0feb22619835 100644 --- a/net/mac80211/ieee80211_led.h +++ b/net/mac80211/ieee80211_led.h | |||
@@ -14,6 +14,8 @@ | |||
14 | #ifdef CONFIG_MAC80211_LEDS | 14 | #ifdef CONFIG_MAC80211_LEDS |
15 | extern void ieee80211_led_rx(struct ieee80211_local *local); | 15 | 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, | ||
18 | bool associated); | ||
17 | extern void ieee80211_led_init(struct ieee80211_local *local); | 19 | extern void ieee80211_led_init(struct ieee80211_local *local); |
18 | extern void ieee80211_led_exit(struct ieee80211_local *local); | 20 | extern void ieee80211_led_exit(struct ieee80211_local *local); |
19 | #else | 21 | #else |
@@ -23,6 +25,10 @@ static inline void ieee80211_led_rx(struct ieee80211_local *local) | |||
23 | static inline void ieee80211_led_tx(struct ieee80211_local *local, int q) | 25 | static inline void ieee80211_led_tx(struct ieee80211_local *local, int q) |
24 | { | 26 | { |
25 | } | 27 | } |
28 | static inline void ieee80211_led_assoc(struct ieee80211_local *local, | ||
29 | bool associated) | ||
30 | { | ||
31 | } | ||
26 | static inline void ieee80211_led_init(struct ieee80211_local *local) | 32 | static inline void ieee80211_led_init(struct ieee80211_local *local) |
27 | { | 33 | { |
28 | } | 34 | } |
diff --git a/net/mac80211/ieee80211_sta.c b/net/mac80211/ieee80211_sta.c index bd9d7aa74083..1641e8fe44b7 100644 --- a/net/mac80211/ieee80211_sta.c +++ b/net/mac80211/ieee80211_sta.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <net/mac80211.h> | 31 | #include <net/mac80211.h> |
32 | #include "ieee80211_i.h" | 32 | #include "ieee80211_i.h" |
33 | #include "ieee80211_rate.h" | 33 | #include "ieee80211_rate.h" |
34 | #include "ieee80211_led.h" | ||
34 | 35 | ||
35 | #define IEEE80211_AUTH_TIMEOUT (HZ / 5) | 36 | #define IEEE80211_AUTH_TIMEOUT (HZ / 5) |
36 | #define IEEE80211_AUTH_MAX_TRIES 3 | 37 | #define IEEE80211_AUTH_MAX_TRIES 3 |
@@ -408,8 +409,9 @@ static void ieee80211_sta_send_associnfo(struct net_device *dev, | |||
408 | 409 | ||
409 | static void ieee80211_set_associated(struct net_device *dev, | 410 | static void ieee80211_set_associated(struct net_device *dev, |
410 | struct ieee80211_if_sta *ifsta, | 411 | struct ieee80211_if_sta *ifsta, |
411 | unsigned int assoc) | 412 | bool assoc) |
412 | { | 413 | { |
414 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
413 | union iwreq_data wrqu; | 415 | union iwreq_data wrqu; |
414 | 416 | ||
415 | if (!!(ifsta->flags & IEEE80211_STA_ASSOCIATED) == assoc) | 417 | if (!!(ifsta->flags & IEEE80211_STA_ASSOCIATED) == assoc) |
@@ -447,6 +449,7 @@ static void ieee80211_set_associated(struct net_device *dev, | |||
447 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; | 449 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
448 | wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL); | 450 | wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL); |
449 | ifsta->last_probe = jiffies; | 451 | ifsta->last_probe = jiffies; |
452 | ieee80211_led_assoc(local, assoc); | ||
450 | } | 453 | } |
451 | 454 | ||
452 | static void ieee80211_set_disassoc(struct net_device *dev, | 455 | static void ieee80211_set_disassoc(struct net_device *dev, |