aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-3945-led.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-3945-led.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-led.c109
1 files changed, 54 insertions, 55 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-led.c b/drivers/net/wireless/iwlwifi/iwl-3945-led.c
index 4c638909a7db..fab137365000 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-led.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-led.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2009 Intel Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -38,8 +38,10 @@
38#include <linux/etherdevice.h> 38#include <linux/etherdevice.h>
39#include <asm/unaligned.h> 39#include <asm/unaligned.h>
40 40
41#include "iwl-commands.h"
41#include "iwl-3945.h" 42#include "iwl-3945.h"
42#include "iwl-helpers.h" 43#include "iwl-core.h"
44#include "iwl-dev.h"
43 45
44 46
45static const struct { 47static const struct {
@@ -67,8 +69,8 @@ static const struct {
67#define IWL_MAX_BLINK_TBL (ARRAY_SIZE(blink_tbl) - 1) /*Exclude Solid on*/ 69#define IWL_MAX_BLINK_TBL (ARRAY_SIZE(blink_tbl) - 1) /*Exclude Solid on*/
68#define IWL_SOLID_BLINK_IDX (ARRAY_SIZE(blink_tbl) - 1) 70#define IWL_SOLID_BLINK_IDX (ARRAY_SIZE(blink_tbl) - 1)
69 71
70static int iwl3945_led_cmd_callback(struct iwl3945_priv *priv, 72static int iwl3945_led_cmd_callback(struct iwl_priv *priv,
71 struct iwl3945_cmd *cmd, 73 struct iwl_cmd *cmd,
72 struct sk_buff *skb) 74 struct sk_buff *skb)
73{ 75{
74 return 1; 76 return 1;
@@ -80,27 +82,27 @@ static inline int iwl3945_brightness_to_idx(enum led_brightness brightness)
80} 82}
81 83
82/* Send led command */ 84/* Send led command */
83static int iwl_send_led_cmd(struct iwl3945_priv *priv, 85static int iwl_send_led_cmd(struct iwl_priv *priv,
84 struct iwl3945_led_cmd *led_cmd) 86 struct iwl_led_cmd *led_cmd)
85{ 87{
86 struct iwl3945_host_cmd cmd = { 88 struct iwl_host_cmd cmd = {
87 .id = REPLY_LEDS_CMD, 89 .id = REPLY_LEDS_CMD,
88 .len = sizeof(struct iwl3945_led_cmd), 90 .len = sizeof(struct iwl_led_cmd),
89 .data = led_cmd, 91 .data = led_cmd,
90 .meta.flags = CMD_ASYNC, 92 .meta.flags = CMD_ASYNC,
91 .meta.u.callback = iwl3945_led_cmd_callback, 93 .meta.u.callback = iwl3945_led_cmd_callback,
92 }; 94 };
93 95
94 return iwl3945_send_cmd(priv, &cmd); 96 return iwl_send_cmd(priv, &cmd);
95} 97}
96 98
97 99
98 100
99/* Set led on command */ 101/* Set led on command */
100static int iwl3945_led_pattern(struct iwl3945_priv *priv, int led_id, 102static int iwl3945_led_pattern(struct iwl_priv *priv, int led_id,
101 unsigned int idx) 103 unsigned int idx)
102{ 104{
103 struct iwl3945_led_cmd led_cmd = { 105 struct iwl_led_cmd led_cmd = {
104 .id = led_id, 106 .id = led_id,
105 .interval = IWL_DEF_LED_INTRVL 107 .interval = IWL_DEF_LED_INTRVL
106 }; 108 };
@@ -114,11 +116,10 @@ static int iwl3945_led_pattern(struct iwl3945_priv *priv, int led_id,
114} 116}
115 117
116 118
117#if 1
118/* Set led on command */ 119/* Set led on command */
119static int iwl3945_led_on(struct iwl3945_priv *priv, int led_id) 120static int iwl3945_led_on(struct iwl_priv *priv, int led_id)
120{ 121{
121 struct iwl3945_led_cmd led_cmd = { 122 struct iwl_led_cmd led_cmd = {
122 .id = led_id, 123 .id = led_id,
123 .on = IWL_LED_SOLID, 124 .on = IWL_LED_SOLID,
124 .off = 0, 125 .off = 0,
@@ -128,9 +129,9 @@ static int iwl3945_led_on(struct iwl3945_priv *priv, int led_id)
128} 129}
129 130
130/* Set led off command */ 131/* Set led off command */
131static int iwl3945_led_off(struct iwl3945_priv *priv, int led_id) 132static int iwl3945_led_off(struct iwl_priv *priv, int led_id)
132{ 133{
133 struct iwl3945_led_cmd led_cmd = { 134 struct iwl_led_cmd led_cmd = {
134 .id = led_id, 135 .id = led_id,
135 .on = 0, 136 .on = 0,
136 .off = 0, 137 .off = 0,
@@ -139,13 +140,11 @@ static int iwl3945_led_off(struct iwl3945_priv *priv, int led_id)
139 IWL_DEBUG_LED("led off %d\n", led_id); 140 IWL_DEBUG_LED("led off %d\n", led_id);
140 return iwl_send_led_cmd(priv, &led_cmd); 141 return iwl_send_led_cmd(priv, &led_cmd);
141} 142}
142#endif
143
144 143
145/* 144/*
146 * brightness call back function for Tx/Rx LED 145 * brightness call back function for Tx/Rx LED
147 */ 146 */
148static int iwl3945_led_associated(struct iwl3945_priv *priv, int led_id) 147static int iwl3945_led_associated(struct iwl_priv *priv, int led_id)
149{ 148{
150 if (test_bit(STATUS_EXIT_PENDING, &priv->status) || 149 if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||
151 !test_bit(STATUS_READY, &priv->status)) 150 !test_bit(STATUS_READY, &priv->status))
@@ -166,7 +165,7 @@ static void iwl3945_led_brightness_set(struct led_classdev *led_cdev,
166{ 165{
167 struct iwl3945_led *led = container_of(led_cdev, 166 struct iwl3945_led *led = container_of(led_cdev,
168 struct iwl3945_led, led_dev); 167 struct iwl3945_led, led_dev);
169 struct iwl3945_priv *priv = led->priv; 168 struct iwl_priv *priv = led->priv;
170 169
171 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 170 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
172 return; 171 return;
@@ -202,7 +201,7 @@ static void iwl3945_led_brightness_set(struct led_classdev *led_cdev,
202/* 201/*
203 * Register led class with the system 202 * Register led class with the system
204 */ 203 */
205static int iwl3945_led_register_led(struct iwl3945_priv *priv, 204static int iwl3945_led_register_led(struct iwl_priv *priv,
206 struct iwl3945_led *led, 205 struct iwl3945_led *led,
207 enum led_type type, u8 set_led, 206 enum led_type type, u8 set_led,
208 char *trigger) 207 char *trigger)
@@ -219,7 +218,7 @@ static int iwl3945_led_register_led(struct iwl3945_priv *priv,
219 218
220 ret = led_classdev_register(device, &led->led_dev); 219 ret = led_classdev_register(device, &led->led_dev);
221 if (ret) { 220 if (ret) {
222 IWL_ERROR("Error: failed to register led handler.\n"); 221 IWL_ERR(priv, "Error: failed to register led handler.\n");
223 return ret; 222 return ret;
224 } 223 }
225 224
@@ -234,7 +233,7 @@ static int iwl3945_led_register_led(struct iwl3945_priv *priv,
234/* 233/*
235 * calculate blink rate according to last 2 sec Tx/Rx activities 234 * calculate blink rate according to last 2 sec Tx/Rx activities
236 */ 235 */
237static inline u8 get_blink_rate(struct iwl3945_priv *priv) 236static inline u8 get_blink_rate(struct iwl_priv *priv)
238{ 237{
239 int index; 238 int index;
240 u64 current_tpt = priv->rxtxpackets; 239 u64 current_tpt = priv->rxtxpackets;
@@ -253,7 +252,7 @@ static inline u8 get_blink_rate(struct iwl3945_priv *priv)
253 return index; 252 return index;
254} 253}
255 254
256static inline int is_rf_kill(struct iwl3945_priv *priv) 255static inline int is_rf_kill(struct iwl_priv *priv)
257{ 256{
258 return test_bit(STATUS_RF_KILL_HW, &priv->status) || 257 return test_bit(STATUS_RF_KILL_HW, &priv->status) ||
259 test_bit(STATUS_RF_KILL_SW, &priv->status); 258 test_bit(STATUS_RF_KILL_SW, &priv->status);
@@ -264,7 +263,7 @@ static inline int is_rf_kill(struct iwl3945_priv *priv)
264 * happen very frequent we postpone led command to be called from 263 * happen very frequent we postpone led command to be called from
265 * REPLY handler so we know ucode is up 264 * REPLY handler so we know ucode is up
266 */ 265 */
267void iwl3945_led_background(struct iwl3945_priv *priv) 266void iwl3945_led_background(struct iwl_priv *priv)
268{ 267{
269 u8 blink_idx; 268 u8 blink_idx;
270 269
@@ -304,7 +303,7 @@ void iwl3945_led_background(struct iwl3945_priv *priv)
304 303
305 304
306/* Register all led handler */ 305/* Register all led handler */
307int iwl3945_led_register(struct iwl3945_priv *priv) 306int iwl3945_led_register(struct iwl_priv *priv)
308{ 307{
309 char *trigger; 308 char *trigger;
310 int ret; 309 int ret;
@@ -316,66 +315,66 @@ int iwl3945_led_register(struct iwl3945_priv *priv)
316 priv->allow_blinking = 0; 315 priv->allow_blinking = 0;
317 316
318 trigger = ieee80211_get_radio_led_name(priv->hw); 317 trigger = ieee80211_get_radio_led_name(priv->hw);
319 snprintf(priv->led[IWL_LED_TRG_RADIO].name, 318 snprintf(priv->led39[IWL_LED_TRG_RADIO].name,
320 sizeof(priv->led[IWL_LED_TRG_RADIO].name), "iwl-%s:radio", 319 sizeof(priv->led39[IWL_LED_TRG_RADIO].name), "iwl-%s:radio",
321 wiphy_name(priv->hw->wiphy)); 320 wiphy_name(priv->hw->wiphy));
322 321
323 priv->led[IWL_LED_TRG_RADIO].led_on = iwl3945_led_on; 322 priv->led39[IWL_LED_TRG_RADIO].led_on = iwl3945_led_on;
324 priv->led[IWL_LED_TRG_RADIO].led_off = iwl3945_led_off; 323 priv->led39[IWL_LED_TRG_RADIO].led_off = iwl3945_led_off;
325 priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL; 324 priv->led39[IWL_LED_TRG_RADIO].led_pattern = NULL;
326 325
327 ret = iwl3945_led_register_led(priv, 326 ret = iwl3945_led_register_led(priv,
328 &priv->led[IWL_LED_TRG_RADIO], 327 &priv->led39[IWL_LED_TRG_RADIO],
329 IWL_LED_TRG_RADIO, 1, trigger); 328 IWL_LED_TRG_RADIO, 1, trigger);
330 329
331 if (ret) 330 if (ret)
332 goto exit_fail; 331 goto exit_fail;
333 332
334 trigger = ieee80211_get_assoc_led_name(priv->hw); 333 trigger = ieee80211_get_assoc_led_name(priv->hw);
335 snprintf(priv->led[IWL_LED_TRG_ASSOC].name, 334 snprintf(priv->led39[IWL_LED_TRG_ASSOC].name,
336 sizeof(priv->led[IWL_LED_TRG_ASSOC].name), "iwl-%s:assoc", 335 sizeof(priv->led39[IWL_LED_TRG_ASSOC].name), "iwl-%s:assoc",
337 wiphy_name(priv->hw->wiphy)); 336 wiphy_name(priv->hw->wiphy));
338 337
339 ret = iwl3945_led_register_led(priv, 338 ret = iwl3945_led_register_led(priv,
340 &priv->led[IWL_LED_TRG_ASSOC], 339 &priv->led39[IWL_LED_TRG_ASSOC],
341 IWL_LED_TRG_ASSOC, 0, trigger); 340 IWL_LED_TRG_ASSOC, 0, trigger);
342 341
343 /* for assoc always turn led on */ 342 /* for assoc always turn led on */
344 priv->led[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_on; 343 priv->led39[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_on;
345 priv->led[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_on; 344 priv->led39[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_on;
346 priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL; 345 priv->led39[IWL_LED_TRG_ASSOC].led_pattern = NULL;
347 346
348 if (ret) 347 if (ret)
349 goto exit_fail; 348 goto exit_fail;
350 349
351 trigger = ieee80211_get_rx_led_name(priv->hw); 350 trigger = ieee80211_get_rx_led_name(priv->hw);
352 snprintf(priv->led[IWL_LED_TRG_RX].name, 351 snprintf(priv->led39[IWL_LED_TRG_RX].name,
353 sizeof(priv->led[IWL_LED_TRG_RX].name), "iwl-%s:RX", 352 sizeof(priv->led39[IWL_LED_TRG_RX].name), "iwl-%s:RX",
354 wiphy_name(priv->hw->wiphy)); 353 wiphy_name(priv->hw->wiphy));
355 354
356 ret = iwl3945_led_register_led(priv, 355 ret = iwl3945_led_register_led(priv,
357 &priv->led[IWL_LED_TRG_RX], 356 &priv->led39[IWL_LED_TRG_RX],
358 IWL_LED_TRG_RX, 0, trigger); 357 IWL_LED_TRG_RX, 0, trigger);
359 358
360 priv->led[IWL_LED_TRG_RX].led_on = iwl3945_led_associated; 359 priv->led39[IWL_LED_TRG_RX].led_on = iwl3945_led_associated;
361 priv->led[IWL_LED_TRG_RX].led_off = iwl3945_led_associated; 360 priv->led39[IWL_LED_TRG_RX].led_off = iwl3945_led_associated;
362 priv->led[IWL_LED_TRG_RX].led_pattern = iwl3945_led_pattern; 361 priv->led39[IWL_LED_TRG_RX].led_pattern = iwl3945_led_pattern;
363 362
364 if (ret) 363 if (ret)
365 goto exit_fail; 364 goto exit_fail;
366 365
367 trigger = ieee80211_get_tx_led_name(priv->hw); 366 trigger = ieee80211_get_tx_led_name(priv->hw);
368 snprintf(priv->led[IWL_LED_TRG_TX].name, 367 snprintf(priv->led39[IWL_LED_TRG_TX].name,
369 sizeof(priv->led[IWL_LED_TRG_TX].name), "iwl-%s:TX", 368 sizeof(priv->led39[IWL_LED_TRG_TX].name), "iwl-%s:TX",
370 wiphy_name(priv->hw->wiphy)); 369 wiphy_name(priv->hw->wiphy));
371 370
372 ret = iwl3945_led_register_led(priv, 371 ret = iwl3945_led_register_led(priv,
373 &priv->led[IWL_LED_TRG_TX], 372 &priv->led39[IWL_LED_TRG_TX],
374 IWL_LED_TRG_TX, 0, trigger); 373 IWL_LED_TRG_TX, 0, trigger);
375 374
376 priv->led[IWL_LED_TRG_TX].led_on = iwl3945_led_associated; 375 priv->led39[IWL_LED_TRG_TX].led_on = iwl3945_led_associated;
377 priv->led[IWL_LED_TRG_TX].led_off = iwl3945_led_associated; 376 priv->led39[IWL_LED_TRG_TX].led_off = iwl3945_led_associated;
378 priv->led[IWL_LED_TRG_TX].led_pattern = iwl3945_led_pattern; 377 priv->led39[IWL_LED_TRG_TX].led_pattern = iwl3945_led_pattern;
379 378
380 if (ret) 379 if (ret)
381 goto exit_fail; 380 goto exit_fail;
@@ -402,11 +401,11 @@ static void iwl3945_led_unregister_led(struct iwl3945_led *led, u8 set_led)
402} 401}
403 402
404/* Unregister all led handlers */ 403/* Unregister all led handlers */
405void iwl3945_led_unregister(struct iwl3945_priv *priv) 404void iwl3945_led_unregister(struct iwl_priv *priv)
406{ 405{
407 iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_ASSOC], 0); 406 iwl3945_led_unregister_led(&priv->led39[IWL_LED_TRG_ASSOC], 0);
408 iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_RX], 0); 407 iwl3945_led_unregister_led(&priv->led39[IWL_LED_TRG_RX], 0);
409 iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_TX], 0); 408 iwl3945_led_unregister_led(&priv->led39[IWL_LED_TRG_TX], 0);
410 iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_RADIO], 1); 409 iwl3945_led_unregister_led(&priv->led39[IWL_LED_TRG_RADIO], 1);
411} 410}
412 411