diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-3945-led.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945-led.c | 66 |
1 files changed, 42 insertions, 24 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-led.c b/drivers/net/wireless/iwlwifi/iwl-3945-led.c index ac22f59be9ef..225e5f889346 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945-led.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945-led.c | |||
@@ -44,6 +44,15 @@ | |||
44 | #include "iwl-core.h" | 44 | #include "iwl-core.h" |
45 | #include "iwl-dev.h" | 45 | #include "iwl-dev.h" |
46 | 46 | ||
47 | #ifdef CONFIG_IWLWIFI_DEBUG | ||
48 | static const char *led_type_str[] = { | ||
49 | __stringify(IWL_LED_TRG_TX), | ||
50 | __stringify(IWL_LED_TRG_RX), | ||
51 | __stringify(IWL_LED_TRG_ASSOC), | ||
52 | __stringify(IWL_LED_TRG_RADIO), | ||
53 | NULL | ||
54 | }; | ||
55 | #endif /* CONFIG_IWLWIFI_DEBUG */ | ||
47 | 56 | ||
48 | static const struct { | 57 | static const struct { |
49 | u16 brightness; | 58 | u16 brightness; |
@@ -61,7 +70,7 @@ static const struct { | |||
61 | {10, 110, 110}, | 70 | {10, 110, 110}, |
62 | {5, 130, 130}, | 71 | {5, 130, 130}, |
63 | {0, 167, 167}, | 72 | {0, 167, 167}, |
64 | /*SOLID_ON*/ | 73 | /* SOLID_ON */ |
65 | {-1, IWL_LED_SOLID, 0} | 74 | {-1, IWL_LED_SOLID, 0} |
66 | }; | 75 | }; |
67 | 76 | ||
@@ -143,6 +152,26 @@ static int iwl3945_led_off(struct iwl_priv *priv, int led_id) | |||
143 | } | 152 | } |
144 | 153 | ||
145 | /* | 154 | /* |
155 | * Set led on in case of association | ||
156 | * */ | ||
157 | static int iwl3945_led_associate(struct iwl_priv *priv, int led_id) | ||
158 | { | ||
159 | IWL_DEBUG_LED(priv, "Associated\n"); | ||
160 | |||
161 | priv->allow_blinking = 1; | ||
162 | return iwl3945_led_on(priv, led_id); | ||
163 | } | ||
164 | /* Set Led off in case of disassociation */ | ||
165 | static int iwl3945_led_disassociate(struct iwl_priv *priv, int led_id) | ||
166 | { | ||
167 | IWL_DEBUG_LED(priv, "Disassociated\n"); | ||
168 | |||
169 | priv->allow_blinking = 0; | ||
170 | |||
171 | return 0; | ||
172 | } | ||
173 | |||
174 | /* | ||
146 | * brightness call back function for Tx/Rx LED | 175 | * brightness call back function for Tx/Rx LED |
147 | */ | 176 | */ |
148 | static int iwl3945_led_associated(struct iwl_priv *priv, int led_id) | 177 | static int iwl3945_led_associated(struct iwl_priv *priv, int led_id) |
@@ -165,26 +194,21 @@ static void iwl3945_led_brightness_set(struct led_classdev *led_cdev, | |||
165 | enum led_brightness brightness) | 194 | enum led_brightness brightness) |
166 | { | 195 | { |
167 | struct iwl_led *led = container_of(led_cdev, | 196 | struct iwl_led *led = container_of(led_cdev, |
168 | struct iwl_led, led_dev); | 197 | struct iwl_led, led_dev); |
169 | struct iwl_priv *priv = led->priv; | 198 | struct iwl_priv *priv = led->priv; |
170 | 199 | ||
171 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) | 200 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
172 | return; | 201 | return; |
173 | 202 | ||
203 | IWL_DEBUG_LED(priv, "Led type = %s brightness = %d\n", | ||
204 | led_type_str[led->type], brightness); | ||
205 | |||
174 | switch (brightness) { | 206 | switch (brightness) { |
175 | case LED_FULL: | 207 | case LED_FULL: |
176 | if (led->type == IWL_LED_TRG_ASSOC) { | ||
177 | priv->allow_blinking = 1; | ||
178 | IWL_DEBUG_LED(priv, "MAC is associated\n"); | ||
179 | } | ||
180 | if (led->led_on) | 208 | if (led->led_on) |
181 | led->led_on(priv, IWL_LED_LINK); | 209 | led->led_on(priv, IWL_LED_LINK); |
182 | break; | 210 | break; |
183 | case LED_OFF: | 211 | case LED_OFF: |
184 | if (led->type == IWL_LED_TRG_ASSOC) { | ||
185 | priv->allow_blinking = 0; | ||
186 | IWL_DEBUG_LED(priv, "MAC is disassociated\n"); | ||
187 | } | ||
188 | if (led->led_off) | 212 | if (led->led_off) |
189 | led->led_off(priv, IWL_LED_LINK); | 213 | led->led_off(priv, IWL_LED_LINK); |
190 | break; | 214 | break; |
@@ -197,8 +221,6 @@ static void iwl3945_led_brightness_set(struct led_classdev *led_cdev, | |||
197 | } | 221 | } |
198 | } | 222 | } |
199 | 223 | ||
200 | |||
201 | |||
202 | /* | 224 | /* |
203 | * Register led class with the system | 225 | * Register led class with the system |
204 | */ | 226 | */ |
@@ -237,12 +259,12 @@ static int iwl3945_led_register_led(struct iwl_priv *priv, | |||
237 | static inline u8 get_blink_rate(struct iwl_priv *priv) | 259 | static inline u8 get_blink_rate(struct iwl_priv *priv) |
238 | { | 260 | { |
239 | int index; | 261 | int index; |
240 | u64 current_tpt = priv->rxtxpackets; | 262 | s64 tpt = priv->rxtxpackets; |
241 | s64 tpt = current_tpt - priv->led_tpt; | ||
242 | 263 | ||
243 | if (tpt < 0) | 264 | if (tpt < 0) |
244 | tpt = -tpt; | 265 | tpt = -tpt; |
245 | priv->led_tpt = current_tpt; | 266 | |
267 | IWL_DEBUG_LED(priv, "tpt %lld \n", (long long)tpt); | ||
246 | 268 | ||
247 | if (!priv->allow_blinking) | 269 | if (!priv->allow_blinking) |
248 | index = IWL_MAX_BLINK_TBL; | 270 | index = IWL_MAX_BLINK_TBL; |
@@ -250,13 +272,9 @@ static inline u8 get_blink_rate(struct iwl_priv *priv) | |||
250 | for (index = 0; index < IWL_MAX_BLINK_TBL; index++) | 272 | for (index = 0; index < IWL_MAX_BLINK_TBL; index++) |
251 | if (tpt > (blink_tbl[index].brightness * IWL_1MB_RATE)) | 273 | if (tpt > (blink_tbl[index].brightness * IWL_1MB_RATE)) |
252 | break; | 274 | break; |
253 | return index; | ||
254 | } | ||
255 | 275 | ||
256 | static inline int is_rf_kill(struct iwl_priv *priv) | 276 | IWL_DEBUG_LED(priv, "LED BLINK IDX=%d\n", index); |
257 | { | 277 | return index; |
258 | return test_bit(STATUS_RF_KILL_HW, &priv->status) || | ||
259 | test_bit(STATUS_RF_KILL_SW, &priv->status); | ||
260 | } | 278 | } |
261 | 279 | ||
262 | /* | 280 | /* |
@@ -272,7 +290,7 @@ void iwl3945_led_background(struct iwl_priv *priv) | |||
272 | priv->last_blink_time = 0; | 290 | priv->last_blink_time = 0; |
273 | return; | 291 | return; |
274 | } | 292 | } |
275 | if (is_rf_kill(priv)) { | 293 | if (iwl_is_rfkill(priv)) { |
276 | priv->last_blink_time = 0; | 294 | priv->last_blink_time = 0; |
277 | return; | 295 | return; |
278 | } | 296 | } |
@@ -341,8 +359,8 @@ int iwl3945_led_register(struct iwl_priv *priv) | |||
341 | IWL_LED_TRG_ASSOC, 0, trigger); | 359 | IWL_LED_TRG_ASSOC, 0, trigger); |
342 | 360 | ||
343 | /* for assoc always turn led on */ | 361 | /* for assoc always turn led on */ |
344 | priv->led[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_on; | 362 | priv->led[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_associate; |
345 | priv->led[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_on; | 363 | priv->led[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_disassociate; |
346 | priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL; | 364 | priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL; |
347 | 365 | ||
348 | if (ret) | 366 | if (ret) |