2 * Copyright 2006, Johannes Berg <johannes@sipsolutions.net>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
9 /* just for IFNAMSIZ */
13 void ieee80211_led_rx(struct ieee80211_local
*local
)
15 if (unlikely(!local
->rx_led
))
17 if (local
->rx_led_counter
++ % 2 == 0)
18 led_trigger_event(local
->rx_led
, LED_OFF
);
20 led_trigger_event(local
->rx_led
, LED_FULL
);
23 /* q is 1 if a packet was enqueued, 0 if it has been transmitted */
24 void ieee80211_led_tx(struct ieee80211_local
*local
, int q
)
26 if (unlikely(!local
->tx_led
))
28 /* not sure how this is supposed to work ... */
29 local
->tx_led_counter
+= 2*q
-1;
30 if (local
->tx_led_counter
% 2 == 0)
31 led_trigger_event(local
->tx_led
, LED_OFF
);
33 led_trigger_event(local
->tx_led
, LED_FULL
);
36 void ieee80211_led_assoc(struct ieee80211_local
*local
, bool associated
)
38 if (unlikely(!local
->assoc_led
))
41 led_trigger_event(local
->assoc_led
, LED_FULL
);
43 led_trigger_event(local
->assoc_led
, LED_OFF
);
46 void ieee80211_led_radio(struct ieee80211_local
*local
, bool enabled
)
48 if (unlikely(!local
->radio_led
))
51 led_trigger_event(local
->radio_led
, LED_FULL
);
53 led_trigger_event(local
->radio_led
, LED_OFF
);
56 void ieee80211_led_init(struct ieee80211_local
*local
)
58 local
->rx_led
= kzalloc(sizeof(struct led_trigger
), GFP_KERNEL
);
60 snprintf(local
->rx_led_name
, sizeof(local
->rx_led_name
),
61 "%srx", wiphy_name(local
->hw
.wiphy
));
62 local
->rx_led
->name
= local
->rx_led_name
;
63 if (led_trigger_register(local
->rx_led
)) {
69 local
->tx_led
= kzalloc(sizeof(struct led_trigger
), GFP_KERNEL
);
71 snprintf(local
->tx_led_name
, sizeof(local
->tx_led_name
),
72 "%stx", wiphy_name(local
->hw
.wiphy
));
73 local
->tx_led
->name
= local
->tx_led_name
;
74 if (led_trigger_register(local
->tx_led
)) {
80 local
->assoc_led
= kzalloc(sizeof(struct led_trigger
), GFP_KERNEL
);
81 if (local
->assoc_led
) {
82 snprintf(local
->assoc_led_name
, sizeof(local
->assoc_led_name
),
83 "%sassoc", wiphy_name(local
->hw
.wiphy
));
84 local
->assoc_led
->name
= local
->assoc_led_name
;
85 if (led_trigger_register(local
->assoc_led
)) {
86 kfree(local
->assoc_led
);
87 local
->assoc_led
= NULL
;
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
;
103 void ieee80211_led_exit(struct ieee80211_local
*local
)
105 if (local
->radio_led
) {
106 led_trigger_unregister(local
->radio_led
);
107 kfree(local
->radio_led
);
109 if (local
->assoc_led
) {
110 led_trigger_unregister(local
->assoc_led
);
111 kfree(local
->assoc_led
);
114 led_trigger_unregister(local
->tx_led
);
115 kfree(local
->tx_led
);
118 led_trigger_unregister(local
->rx_led
);
119 kfree(local
->rx_led
);
123 char *__ieee80211_get_radio_led_name(struct ieee80211_hw
*hw
)
125 struct ieee80211_local
*local
= hw_to_local(hw
);
127 if (local
->radio_led
)
128 return local
->radio_led_name
;
131 EXPORT_SYMBOL(__ieee80211_get_radio_led_name
);
133 char *__ieee80211_get_assoc_led_name(struct ieee80211_hw
*hw
)
135 struct ieee80211_local
*local
= hw_to_local(hw
);
137 if (local
->assoc_led
)
138 return local
->assoc_led_name
;
141 EXPORT_SYMBOL(__ieee80211_get_assoc_led_name
);
143 char *__ieee80211_get_tx_led_name(struct ieee80211_hw
*hw
)
145 struct ieee80211_local
*local
= hw_to_local(hw
);
148 return local
->tx_led_name
;
151 EXPORT_SYMBOL(__ieee80211_get_tx_led_name
);
153 char *__ieee80211_get_rx_led_name(struct ieee80211_hw
*hw
)
155 struct ieee80211_local
*local
= hw_to_local(hw
);
158 return local
->rx_led_name
;
161 EXPORT_SYMBOL(__ieee80211_get_rx_led_name
);