aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAbhijeet Kolekar <abhijeet.kolekar@intel.com>2009-05-21 16:44:21 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-05-22 14:06:02 -0400
commit749e091ee0065ed366cc26c115abc237e07ed786 (patch)
tree77ecf16d1e104bb323f27b8696cb9ffab7aaae87 /drivers
parent2c7e57981f24e9f8b732ecf1c01e16111d21b7a5 (diff)
iwl3945: improve 3945 leds
'tpt' is a delta throughput (number of packets) and is corelated to brightness of the LED. We already maintain a delta of packets in rxtxpackets. There is no need to calculate this delta again which was affecting the behaviour of LEDS. Also add two new callback functions for ASSOCIATED/DISASSOCIATED states where LED's will be *on* for associated state and *off* for disassociated state. This fixes http://www.intellinuxwireless.org/bugzilla/show_bug.cgi?id=1771. Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-led.c70
1 files changed, 46 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..bd7e520d98c2 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
48static 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
48static const struct { 57static 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,30 @@ 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 * */
157static 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 */
165static 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 if (iwl_is_rfkill(priv))
171 iwl3945_led_off(priv, led_id);
172 else
173 iwl3945_led_on(priv, led_id);
174
175 return 0;
176}
177
178/*
146 * brightness call back function for Tx/Rx LED 179 * brightness call back function for Tx/Rx LED
147 */ 180 */
148static int iwl3945_led_associated(struct iwl_priv *priv, int led_id) 181static int iwl3945_led_associated(struct iwl_priv *priv, int led_id)
@@ -165,26 +198,21 @@ static void iwl3945_led_brightness_set(struct led_classdev *led_cdev,
165 enum led_brightness brightness) 198 enum led_brightness brightness)
166{ 199{
167 struct iwl_led *led = container_of(led_cdev, 200 struct iwl_led *led = container_of(led_cdev,
168 struct iwl_led, led_dev); 201 struct iwl_led, led_dev);
169 struct iwl_priv *priv = led->priv; 202 struct iwl_priv *priv = led->priv;
170 203
171 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 204 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
172 return; 205 return;
173 206
207 IWL_DEBUG_LED(priv, "Led type = %s brightness = %d\n",
208 led_type_str[led->type], brightness);
209
174 switch (brightness) { 210 switch (brightness) {
175 case LED_FULL: 211 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) 212 if (led->led_on)
181 led->led_on(priv, IWL_LED_LINK); 213 led->led_on(priv, IWL_LED_LINK);
182 break; 214 break;
183 case LED_OFF: 215 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) 216 if (led->led_off)
189 led->led_off(priv, IWL_LED_LINK); 217 led->led_off(priv, IWL_LED_LINK);
190 break; 218 break;
@@ -197,8 +225,6 @@ static void iwl3945_led_brightness_set(struct led_classdev *led_cdev,
197 } 225 }
198} 226}
199 227
200
201
202/* 228/*
203 * Register led class with the system 229 * Register led class with the system
204 */ 230 */
@@ -237,12 +263,12 @@ static int iwl3945_led_register_led(struct iwl_priv *priv,
237static inline u8 get_blink_rate(struct iwl_priv *priv) 263static inline u8 get_blink_rate(struct iwl_priv *priv)
238{ 264{
239 int index; 265 int index;
240 u64 current_tpt = priv->rxtxpackets; 266 s64 tpt = priv->rxtxpackets;
241 s64 tpt = current_tpt - priv->led_tpt;
242 267
243 if (tpt < 0) 268 if (tpt < 0)
244 tpt = -tpt; 269 tpt = -tpt;
245 priv->led_tpt = current_tpt; 270
271 IWL_DEBUG_LED(priv, "tpt %lld \n", (long long)tpt);
246 272
247 if (!priv->allow_blinking) 273 if (!priv->allow_blinking)
248 index = IWL_MAX_BLINK_TBL; 274 index = IWL_MAX_BLINK_TBL;
@@ -250,13 +276,9 @@ static inline u8 get_blink_rate(struct iwl_priv *priv)
250 for (index = 0; index < IWL_MAX_BLINK_TBL; index++) 276 for (index = 0; index < IWL_MAX_BLINK_TBL; index++)
251 if (tpt > (blink_tbl[index].brightness * IWL_1MB_RATE)) 277 if (tpt > (blink_tbl[index].brightness * IWL_1MB_RATE))
252 break; 278 break;
253 return index;
254}
255 279
256static inline int is_rf_kill(struct iwl_priv *priv) 280 IWL_DEBUG_LED(priv, "LED BLINK IDX=%d\n", index);
257{ 281 return index;
258 return test_bit(STATUS_RF_KILL_HW, &priv->status) ||
259 test_bit(STATUS_RF_KILL_SW, &priv->status);
260} 282}
261 283
262/* 284/*
@@ -272,7 +294,7 @@ void iwl3945_led_background(struct iwl_priv *priv)
272 priv->last_blink_time = 0; 294 priv->last_blink_time = 0;
273 return; 295 return;
274 } 296 }
275 if (is_rf_kill(priv)) { 297 if (iwl_is_rfkill(priv)) {
276 priv->last_blink_time = 0; 298 priv->last_blink_time = 0;
277 return; 299 return;
278 } 300 }
@@ -341,8 +363,8 @@ int iwl3945_led_register(struct iwl_priv *priv)
341 IWL_LED_TRG_ASSOC, 0, trigger); 363 IWL_LED_TRG_ASSOC, 0, trigger);
342 364
343 /* for assoc always turn led on */ 365 /* for assoc always turn led on */
344 priv->led[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_on; 366 priv->led[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_associate;
345 priv->led[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_on; 367 priv->led[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_disassociate;
346 priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL; 368 priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL;
347 369
348 if (ret) 370 if (ret)