diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-led.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-led.c | 73 |
1 files changed, 44 insertions, 29 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c index 899d7a2567a8..cb11c4a4d691 100644 --- a/drivers/net/wireless/iwlwifi/iwl-led.c +++ b/drivers/net/wireless/iwlwifi/iwl-led.c | |||
@@ -161,12 +161,32 @@ int iwl4965_led_off(struct iwl_priv *priv, int led_id) | |||
161 | /* Set led register off */ | 161 | /* Set led register off */ |
162 | static int iwl4965_led_off_reg(struct iwl_priv *priv, int led_id) | 162 | static int iwl4965_led_off_reg(struct iwl_priv *priv, int led_id) |
163 | { | 163 | { |
164 | IWL_DEBUG_LED("radio off\n"); | 164 | IWL_DEBUG_LED("LED Reg off\n"); |
165 | iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_OFF); | 165 | iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_OFF); |
166 | return 0; | 166 | return 0; |
167 | } | 167 | } |
168 | 168 | ||
169 | /* | 169 | /* |
170 | * Set led register in case of disassociation according to rfkill state | ||
171 | */ | ||
172 | static int iwl_led_associate(struct iwl_priv *priv, int led_id) | ||
173 | { | ||
174 | IWL_DEBUG_LED("Associated\n"); | ||
175 | priv->allow_blinking = 1; | ||
176 | return iwl4965_led_on_reg(priv, led_id); | ||
177 | } | ||
178 | static int iwl_led_disassociate(struct iwl_priv *priv, int led_id) | ||
179 | { | ||
180 | priv->allow_blinking = 0; | ||
181 | if (iwl_is_rfkill(priv)) | ||
182 | iwl4965_led_off_reg(priv, led_id); | ||
183 | else | ||
184 | iwl4965_led_on_reg(priv, led_id); | ||
185 | |||
186 | return 0; | ||
187 | } | ||
188 | |||
189 | /* | ||
170 | * brightness call back function for Tx/Rx LED | 190 | * brightness call back function for Tx/Rx LED |
171 | */ | 191 | */ |
172 | static int iwl_led_associated(struct iwl_priv *priv, int led_id) | 192 | static int iwl_led_associated(struct iwl_priv *priv, int led_id) |
@@ -199,16 +219,10 @@ static void iwl_led_brightness_set(struct led_classdev *led_cdev, | |||
199 | led_type_str[led->type], brightness); | 219 | led_type_str[led->type], brightness); |
200 | switch (brightness) { | 220 | switch (brightness) { |
201 | case LED_FULL: | 221 | case LED_FULL: |
202 | if (led->type == IWL_LED_TRG_ASSOC) | ||
203 | priv->allow_blinking = 1; | ||
204 | |||
205 | if (led->led_on) | 222 | if (led->led_on) |
206 | led->led_on(priv, IWL_LED_LINK); | 223 | led->led_on(priv, IWL_LED_LINK); |
207 | break; | 224 | break; |
208 | case LED_OFF: | 225 | case LED_OFF: |
209 | if (led->type == IWL_LED_TRG_ASSOC) | ||
210 | priv->allow_blinking = 0; | ||
211 | |||
212 | if (led->led_off) | 226 | if (led->led_off) |
213 | led->led_off(priv, IWL_LED_LINK); | 227 | led->led_off(priv, IWL_LED_LINK); |
214 | break; | 228 | break; |
@@ -228,12 +242,12 @@ static void iwl_led_brightness_set(struct led_classdev *led_cdev, | |||
228 | */ | 242 | */ |
229 | static int iwl_leds_register_led(struct iwl_priv *priv, struct iwl_led *led, | 243 | static int iwl_leds_register_led(struct iwl_priv *priv, struct iwl_led *led, |
230 | enum led_type type, u8 set_led, | 244 | enum led_type type, u8 set_led, |
231 | const char *name, char *trigger) | 245 | char *trigger) |
232 | { | 246 | { |
233 | struct device *device = wiphy_dev(priv->hw->wiphy); | 247 | struct device *device = wiphy_dev(priv->hw->wiphy); |
234 | int ret; | 248 | int ret; |
235 | 249 | ||
236 | led->led_dev.name = name; | 250 | led->led_dev.name = led->name; |
237 | led->led_dev.brightness_set = iwl_led_brightness_set; | 251 | led->led_dev.brightness_set = iwl_led_brightness_set; |
238 | led->led_dev.default_trigger = trigger; | 252 | led->led_dev.default_trigger = trigger; |
239 | 253 | ||
@@ -268,7 +282,9 @@ static int iwl_get_blink_rate(struct iwl_priv *priv) | |||
268 | if (tpt < 0) /* wrapparound */ | 282 | if (tpt < 0) /* wrapparound */ |
269 | tpt = -tpt; | 283 | tpt = -tpt; |
270 | 284 | ||
271 | IWL_DEBUG_LED("tpt %lld current_tpt %lld\n", tpt, current_tpt); | 285 | IWL_DEBUG_LED("tpt %lld current_tpt %llu\n", |
286 | (long long)tpt, | ||
287 | (unsigned long long)current_tpt); | ||
272 | priv->led_tpt = current_tpt; | 288 | priv->led_tpt = current_tpt; |
273 | 289 | ||
274 | if (!priv->allow_blinking) | 290 | if (!priv->allow_blinking) |
@@ -282,12 +298,6 @@ static int iwl_get_blink_rate(struct iwl_priv *priv) | |||
282 | return i; | 298 | return i; |
283 | } | 299 | } |
284 | 300 | ||
285 | static inline int is_rf_kill(struct iwl_priv *priv) | ||
286 | { | ||
287 | return test_bit(STATUS_RF_KILL_HW, &priv->status) || | ||
288 | test_bit(STATUS_RF_KILL_SW, &priv->status); | ||
289 | } | ||
290 | |||
291 | /* | 301 | /* |
292 | * this function called from handler. Since setting Led command can | 302 | * this function called from handler. Since setting Led command can |
293 | * happen very frequent we postpone led command to be called from | 303 | * happen very frequent we postpone led command to be called from |
@@ -301,7 +311,7 @@ void iwl_leds_background(struct iwl_priv *priv) | |||
301 | priv->last_blink_time = 0; | 311 | priv->last_blink_time = 0; |
302 | return; | 312 | return; |
303 | } | 313 | } |
304 | if (is_rf_kill(priv)) { | 314 | if (iwl_is_rfkill(priv)) { |
305 | priv->last_blink_time = 0; | 315 | priv->last_blink_time = 0; |
306 | return; | 316 | return; |
307 | } | 317 | } |
@@ -335,7 +345,6 @@ EXPORT_SYMBOL(iwl_leds_background); | |||
335 | int iwl_leds_register(struct iwl_priv *priv) | 345 | int iwl_leds_register(struct iwl_priv *priv) |
336 | { | 346 | { |
337 | char *trigger; | 347 | char *trigger; |
338 | char name[32]; | ||
339 | int ret; | 348 | int ret; |
340 | 349 | ||
341 | priv->last_blink_rate = 0; | 350 | priv->last_blink_rate = 0; |
@@ -344,7 +353,8 @@ int iwl_leds_register(struct iwl_priv *priv) | |||
344 | priv->allow_blinking = 0; | 353 | priv->allow_blinking = 0; |
345 | 354 | ||
346 | trigger = ieee80211_get_radio_led_name(priv->hw); | 355 | trigger = ieee80211_get_radio_led_name(priv->hw); |
347 | snprintf(name, sizeof(name), "iwl-%s:radio", | 356 | snprintf(priv->led[IWL_LED_TRG_RADIO].name, |
357 | sizeof(priv->led[IWL_LED_TRG_RADIO].name), "iwl-%s:radio", | ||
348 | wiphy_name(priv->hw->wiphy)); | 358 | wiphy_name(priv->hw->wiphy)); |
349 | 359 | ||
350 | priv->led[IWL_LED_TRG_RADIO].led_on = iwl4965_led_on_reg; | 360 | priv->led[IWL_LED_TRG_RADIO].led_on = iwl4965_led_on_reg; |
@@ -352,31 +362,33 @@ int iwl_leds_register(struct iwl_priv *priv) | |||
352 | priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL; | 362 | priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL; |
353 | 363 | ||
354 | ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RADIO], | 364 | ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RADIO], |
355 | IWL_LED_TRG_RADIO, 1, name, trigger); | 365 | IWL_LED_TRG_RADIO, 1, trigger); |
356 | if (ret) | 366 | if (ret) |
357 | goto exit_fail; | 367 | goto exit_fail; |
358 | 368 | ||
359 | trigger = ieee80211_get_assoc_led_name(priv->hw); | 369 | trigger = ieee80211_get_assoc_led_name(priv->hw); |
360 | snprintf(name, sizeof(name), "iwl-%s:assoc", | 370 | snprintf(priv->led[IWL_LED_TRG_ASSOC].name, |
371 | sizeof(priv->led[IWL_LED_TRG_ASSOC].name), "iwl-%s:assoc", | ||
361 | wiphy_name(priv->hw->wiphy)); | 372 | wiphy_name(priv->hw->wiphy)); |
362 | 373 | ||
363 | ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_ASSOC], | 374 | ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_ASSOC], |
364 | IWL_LED_TRG_ASSOC, 0, name, trigger); | 375 | IWL_LED_TRG_ASSOC, 0, trigger); |
365 | 376 | ||
366 | /* for assoc always turn led on */ | 377 | /* for assoc always turn led on */ |
367 | priv->led[IWL_LED_TRG_ASSOC].led_on = iwl4965_led_on_reg; | 378 | priv->led[IWL_LED_TRG_ASSOC].led_on = iwl_led_associate; |
368 | priv->led[IWL_LED_TRG_ASSOC].led_off = iwl4965_led_on_reg; | 379 | priv->led[IWL_LED_TRG_ASSOC].led_off = iwl_led_disassociate; |
369 | priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL; | 380 | priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL; |
370 | 381 | ||
371 | if (ret) | 382 | if (ret) |
372 | goto exit_fail; | 383 | goto exit_fail; |
373 | 384 | ||
374 | trigger = ieee80211_get_rx_led_name(priv->hw); | 385 | trigger = ieee80211_get_rx_led_name(priv->hw); |
375 | snprintf(name, sizeof(name), "iwl-%s:RX", wiphy_name(priv->hw->wiphy)); | 386 | snprintf(priv->led[IWL_LED_TRG_RX].name, |
376 | 387 | sizeof(priv->led[IWL_LED_TRG_RX].name), "iwl-%s:RX", | |
388 | wiphy_name(priv->hw->wiphy)); | ||
377 | 389 | ||
378 | ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RX], | 390 | ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RX], |
379 | IWL_LED_TRG_RX, 0, name, trigger); | 391 | IWL_LED_TRG_RX, 0, trigger); |
380 | 392 | ||
381 | priv->led[IWL_LED_TRG_RX].led_on = iwl_led_associated; | 393 | priv->led[IWL_LED_TRG_RX].led_on = iwl_led_associated; |
382 | priv->led[IWL_LED_TRG_RX].led_off = iwl_led_associated; | 394 | priv->led[IWL_LED_TRG_RX].led_off = iwl_led_associated; |
@@ -386,9 +398,12 @@ int iwl_leds_register(struct iwl_priv *priv) | |||
386 | goto exit_fail; | 398 | goto exit_fail; |
387 | 399 | ||
388 | trigger = ieee80211_get_tx_led_name(priv->hw); | 400 | trigger = ieee80211_get_tx_led_name(priv->hw); |
389 | snprintf(name, sizeof(name), "iwl-%s:TX", wiphy_name(priv->hw->wiphy)); | 401 | snprintf(priv->led[IWL_LED_TRG_TX].name, |
402 | sizeof(priv->led[IWL_LED_TRG_TX].name), "iwl-%s:TX", | ||
403 | wiphy_name(priv->hw->wiphy)); | ||
404 | |||
390 | ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_TX], | 405 | ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_TX], |
391 | IWL_LED_TRG_TX, 0, name, trigger); | 406 | IWL_LED_TRG_TX, 0, trigger); |
392 | 407 | ||
393 | priv->led[IWL_LED_TRG_TX].led_on = iwl_led_associated; | 408 | priv->led[IWL_LED_TRG_TX].led_on = iwl_led_associated; |
394 | priv->led[IWL_LED_TRG_TX].led_off = iwl_led_associated; | 409 | priv->led[IWL_LED_TRG_TX].led_off = iwl_led_associated; |