blob: 8c29ded7d02c5408c26ae12585c46bf8bd7967c7 [file] [log] [blame]
Mohamed Abbasab53d8a2008-03-25 16:33:36 -07001/******************************************************************************
2 *
Reinette Chatre01f81622009-01-08 10:20:02 -08003 * Copyright(c) 2003 - 2009 Intel Corporation. All rights reserved.
Mohamed Abbasab53d8a2008-03-25 16:33:36 -07004 *
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
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
20 *
21 * Contact Information:
Winkler, Tomas759ef892008-12-09 11:28:58 -080022 * Intel Linux Wireless <ilw@linux.intel.com>
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070023 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 *
25 *****************************************************************************/
26
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -070027#ifdef CONFIG_IWLWIFI_LEDS
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070028
29#include <linux/kernel.h>
30#include <linux/module.h>
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070031#include <linux/init.h>
32#include <linux/pci.h>
33#include <linux/dma-mapping.h>
34#include <linux/delay.h>
35#include <linux/skbuff.h>
36#include <linux/netdevice.h>
37#include <linux/wireless.h>
38#include <net/mac80211.h>
39#include <linux/etherdevice.h>
40#include <asm/unaligned.h>
41
Tomas Winkler600c0e12008-12-19 10:37:04 +080042#include "iwl-commands.h"
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070043#include "iwl-3945.h"
Samuel Ortiz518099a2009-01-19 15:30:27 -080044#include "iwl-core.h"
45#include "iwl-dev.h"
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070046
Abhijeet Kolekar749e0912009-05-21 13:44:21 -070047#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 */
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070056
57static const struct {
58 u16 brightness;
59 u8 on_time;
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +080060 u8 off_time;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070061} blink_tbl[] =
62{
63 {300, 25, 25},
64 {200, 40, 40},
65 {100, 55, 55},
66 {70, 65, 65},
67 {50, 75, 75},
68 {20, 85, 85},
69 {15, 95, 95 },
70 {10, 110, 110},
71 {5, 130, 130},
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +080072 {0, 167, 167},
Abhijeet Kolekar749e0912009-05-21 13:44:21 -070073 /* SOLID_ON */
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +080074 {-1, IWL_LED_SOLID, 0}
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070075};
76
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +080077#define IWL_1MB_RATE (128 * 1024)
78#define IWL_LED_THRESHOLD (16)
79#define IWL_MAX_BLINK_TBL (ARRAY_SIZE(blink_tbl) - 1) /*Exclude Solid on*/
80#define IWL_SOLID_BLINK_IDX (ARRAY_SIZE(blink_tbl) - 1)
81
Johannes Berg5696aea2009-07-24 11:13:06 -070082static void iwl3945_led_cmd_callback(struct iwl_priv *priv,
83 struct iwl_device_cmd *cmd,
84 struct sk_buff *skb)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070085{
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070086}
87
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +080088static inline int iwl3945_brightness_to_idx(enum led_brightness brightness)
89{
90 return fls(0x000000FF & (u32)brightness);
91}
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070092
93/* Send led command */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +080094static int iwl_send_led_cmd(struct iwl_priv *priv,
Tomas Winkler4c897252008-12-19 10:37:05 +080095 struct iwl_led_cmd *led_cmd)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070096{
Winkler, Tomasc2d79b42008-12-19 10:37:34 +080097 struct iwl_host_cmd cmd = {
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070098 .id = REPLY_LEDS_CMD,
Tomas Winkler4c897252008-12-19 10:37:05 +080099 .len = sizeof(struct iwl_led_cmd),
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700100 .data = led_cmd,
Johannes Bergc2acea82009-07-24 11:13:05 -0700101 .flags = CMD_ASYNC,
102 .callback = iwl3945_led_cmd_callback,
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700103 };
104
Samuel Ortiz518099a2009-01-19 15:30:27 -0800105 return iwl_send_cmd(priv, &cmd);
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700106}
107
108
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800109
110/* Set led on command */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800111static int iwl3945_led_pattern(struct iwl_priv *priv, int led_id,
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800112 unsigned int idx)
113{
Tomas Winkler4c897252008-12-19 10:37:05 +0800114 struct iwl_led_cmd led_cmd = {
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800115 .id = led_id,
116 .interval = IWL_DEF_LED_INTRVL
117 };
118
119 BUG_ON(idx > IWL_MAX_BLINK_TBL);
120
121 led_cmd.on = blink_tbl[idx].on_time;
122 led_cmd.off = blink_tbl[idx].off_time;
123
124 return iwl_send_led_cmd(priv, &led_cmd);
125}
126
127
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700128/* Set led on command */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800129static int iwl3945_led_on(struct iwl_priv *priv, int led_id)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700130{
Tomas Winkler4c897252008-12-19 10:37:05 +0800131 struct iwl_led_cmd led_cmd = {
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700132 .id = led_id,
133 .on = IWL_LED_SOLID,
134 .off = 0,
135 .interval = IWL_DEF_LED_INTRVL
136 };
137 return iwl_send_led_cmd(priv, &led_cmd);
138}
139
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700140/* Set led off command */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800141static int iwl3945_led_off(struct iwl_priv *priv, int led_id)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700142{
Tomas Winkler4c897252008-12-19 10:37:05 +0800143 struct iwl_led_cmd led_cmd = {
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700144 .id = led_id,
145 .on = 0,
146 .off = 0,
147 .interval = IWL_DEF_LED_INTRVL
148 };
Tomas Winklere1623442009-01-27 14:27:56 -0800149 IWL_DEBUG_LED(priv, "led off %d\n", led_id);
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700150 return iwl_send_led_cmd(priv, &led_cmd);
151}
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700152
153/*
Abhijeet Kolekar749e0912009-05-21 13:44:21 -0700154 * Set led on in case of association
155 * */
156static int iwl3945_led_associate(struct iwl_priv *priv, int led_id)
157{
158 IWL_DEBUG_LED(priv, "Associated\n");
159
160 priv->allow_blinking = 1;
161 return iwl3945_led_on(priv, led_id);
162}
163/* Set Led off in case of disassociation */
164static int iwl3945_led_disassociate(struct iwl_priv *priv, int led_id)
165{
166 IWL_DEBUG_LED(priv, "Disassociated\n");
167
168 priv->allow_blinking = 0;
Abhijeet Kolekar749e0912009-05-21 13:44:21 -0700169
170 return 0;
171}
172
173/*
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700174 * brightness call back function for Tx/Rx LED
175 */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800176static int iwl3945_led_associated(struct iwl_priv *priv, int led_id)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700177{
178 if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||
179 !test_bit(STATUS_READY, &priv->status))
180 return 0;
181
182
183 /* start counting Tx/Rx bytes */
184 if (!priv->last_blink_time && priv->allow_blinking)
185 priv->last_blink_time = jiffies;
186 return 0;
187}
188
189/*
190 * brightness call back for association and radio
191 */
192static void iwl3945_led_brightness_set(struct led_classdev *led_cdev,
193 enum led_brightness brightness)
194{
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700195 struct iwl_led *led = container_of(led_cdev,
Abhijeet Kolekar749e0912009-05-21 13:44:21 -0700196 struct iwl_led, led_dev);
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800197 struct iwl_priv *priv = led->priv;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700198
199 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
200 return;
201
Abhijeet Kolekar749e0912009-05-21 13:44:21 -0700202 IWL_DEBUG_LED(priv, "Led type = %s brightness = %d\n",
203 led_type_str[led->type], brightness);
204
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700205 switch (brightness) {
206 case LED_FULL:
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700207 if (led->led_on)
208 led->led_on(priv, IWL_LED_LINK);
209 break;
210 case LED_OFF:
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700211 if (led->led_off)
212 led->led_off(priv, IWL_LED_LINK);
213 break;
214 default:
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800215 if (led->led_pattern) {
216 int idx = iwl3945_brightness_to_idx(brightness);
217 led->led_pattern(priv, IWL_LED_LINK, idx);
218 }
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700219 break;
220 }
221}
222
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700223/*
224 * Register led class with the system
225 */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800226static int iwl3945_led_register_led(struct iwl_priv *priv,
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700227 struct iwl_led *led,
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700228 enum led_type type, u8 set_led,
Sven Wegener5cbbb372008-08-01 21:57:16 +0200229 char *trigger)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700230{
231 struct device *device = wiphy_dev(priv->hw->wiphy);
232 int ret;
233
Sven Wegener5cbbb372008-08-01 21:57:16 +0200234 led->led_dev.name = led->name;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700235 led->led_dev.brightness_set = iwl3945_led_brightness_set;
236 led->led_dev.default_trigger = trigger;
237
Marcin Slusarzb6b16192008-06-08 13:13:06 +0200238 led->priv = priv;
239 led->type = type;
240
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700241 ret = led_classdev_register(device, &led->led_dev);
242 if (ret) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800243 IWL_ERR(priv, "Error: failed to register led handler.\n");
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700244 return ret;
245 }
246
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700247 led->registered = 1;
248
249 if (set_led && led->led_on)
250 led->led_on(priv, IWL_LED_LINK);
251 return 0;
252}
253
254
255/*
256 * calculate blink rate according to last 2 sec Tx/Rx activities
257 */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800258static inline u8 get_blink_rate(struct iwl_priv *priv)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700259{
260 int index;
Abhijeet Kolekar749e0912009-05-21 13:44:21 -0700261 s64 tpt = priv->rxtxpackets;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700262
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800263 if (tpt < 0)
264 tpt = -tpt;
Abhijeet Kolekar749e0912009-05-21 13:44:21 -0700265
266 IWL_DEBUG_LED(priv, "tpt %lld \n", (long long)tpt);
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800267
268 if (!priv->allow_blinking)
269 index = IWL_MAX_BLINK_TBL;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700270 else
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800271 for (index = 0; index < IWL_MAX_BLINK_TBL; index++)
272 if (tpt > (blink_tbl[index].brightness * IWL_1MB_RATE))
273 break;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700274
Abhijeet Kolekar749e0912009-05-21 13:44:21 -0700275 IWL_DEBUG_LED(priv, "LED BLINK IDX=%d\n", index);
276 return index;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700277}
278
279/*
280 * this function called from handler. Since setting Led command can
281 * happen very frequent we postpone led command to be called from
282 * REPLY handler so we know ucode is up
283 */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800284void iwl3945_led_background(struct iwl_priv *priv)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700285{
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800286 u8 blink_idx;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700287
288 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
289 priv->last_blink_time = 0;
290 return;
291 }
Abhijeet Kolekar749e0912009-05-21 13:44:21 -0700292 if (iwl_is_rfkill(priv)) {
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700293 priv->last_blink_time = 0;
294 return;
295 }
296
297 if (!priv->allow_blinking) {
298 priv->last_blink_time = 0;
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800299 if (priv->last_blink_rate != IWL_SOLID_BLINK_IDX) {
300 priv->last_blink_rate = IWL_SOLID_BLINK_IDX;
301 iwl3945_led_pattern(priv, IWL_LED_LINK,
302 IWL_SOLID_BLINK_IDX);
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700303 }
304 return;
305 }
306 if (!priv->last_blink_time ||
307 !time_after(jiffies, priv->last_blink_time +
308 msecs_to_jiffies(1000)))
309 return;
310
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800311 blink_idx = get_blink_rate(priv);
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700312
313 /* call only if blink rate change */
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800314 if (blink_idx != priv->last_blink_rate)
315 iwl3945_led_pattern(priv, IWL_LED_LINK, blink_idx);
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700316
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800317 priv->last_blink_time = jiffies;
318 priv->last_blink_rate = blink_idx;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700319 priv->rxtxpackets = 0;
320}
321
322
323/* Register all led handler */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800324int iwl3945_led_register(struct iwl_priv *priv)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700325{
326 char *trigger;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700327 int ret;
328
329 priv->last_blink_rate = 0;
330 priv->rxtxpackets = 0;
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800331 priv->led_tpt = 0;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700332 priv->last_blink_time = 0;
333 priv->allow_blinking = 0;
334
335 trigger = ieee80211_get_radio_led_name(priv->hw);
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700336 snprintf(priv->led[IWL_LED_TRG_RADIO].name,
337 sizeof(priv->led[IWL_LED_TRG_RADIO].name), "iwl-%s::radio",
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700338 wiphy_name(priv->hw->wiphy));
339
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700340 priv->led[IWL_LED_TRG_RADIO].led_on = iwl3945_led_on;
341 priv->led[IWL_LED_TRG_RADIO].led_off = iwl3945_led_off;
342 priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700343
344 ret = iwl3945_led_register_led(priv,
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700345 &priv->led[IWL_LED_TRG_RADIO],
Sven Wegener5cbbb372008-08-01 21:57:16 +0200346 IWL_LED_TRG_RADIO, 1, trigger);
347
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700348 if (ret)
349 goto exit_fail;
350
351 trigger = ieee80211_get_assoc_led_name(priv->hw);
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700352 snprintf(priv->led[IWL_LED_TRG_ASSOC].name,
353 sizeof(priv->led[IWL_LED_TRG_ASSOC].name), "iwl-%s::assoc",
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700354 wiphy_name(priv->hw->wiphy));
355
356 ret = iwl3945_led_register_led(priv,
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700357 &priv->led[IWL_LED_TRG_ASSOC],
Sven Wegener5cbbb372008-08-01 21:57:16 +0200358 IWL_LED_TRG_ASSOC, 0, trigger);
359
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700360 /* for assoc always turn led on */
Abhijeet Kolekar749e0912009-05-21 13:44:21 -0700361 priv->led[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_associate;
362 priv->led[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_disassociate;
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700363 priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700364
365 if (ret)
366 goto exit_fail;
367
368 trigger = ieee80211_get_rx_led_name(priv->hw);
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700369 snprintf(priv->led[IWL_LED_TRG_RX].name,
370 sizeof(priv->led[IWL_LED_TRG_RX].name), "iwl-%s::RX",
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700371 wiphy_name(priv->hw->wiphy));
372
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700373 ret = iwl3945_led_register_led(priv,
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700374 &priv->led[IWL_LED_TRG_RX],
Sven Wegener5cbbb372008-08-01 21:57:16 +0200375 IWL_LED_TRG_RX, 0, trigger);
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700376
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700377 priv->led[IWL_LED_TRG_RX].led_on = iwl3945_led_associated;
378 priv->led[IWL_LED_TRG_RX].led_off = iwl3945_led_associated;
379 priv->led[IWL_LED_TRG_RX].led_pattern = iwl3945_led_pattern;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700380
381 if (ret)
382 goto exit_fail;
383
384 trigger = ieee80211_get_tx_led_name(priv->hw);
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700385 snprintf(priv->led[IWL_LED_TRG_TX].name,
386 sizeof(priv->led[IWL_LED_TRG_TX].name), "iwl-%s::TX",
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700387 wiphy_name(priv->hw->wiphy));
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800388
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700389 ret = iwl3945_led_register_led(priv,
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700390 &priv->led[IWL_LED_TRG_TX],
Sven Wegener5cbbb372008-08-01 21:57:16 +0200391 IWL_LED_TRG_TX, 0, trigger);
392
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700393 priv->led[IWL_LED_TRG_TX].led_on = iwl3945_led_associated;
394 priv->led[IWL_LED_TRG_TX].led_off = iwl3945_led_associated;
395 priv->led[IWL_LED_TRG_TX].led_pattern = iwl3945_led_pattern;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700396
397 if (ret)
398 goto exit_fail;
399
400 return 0;
401
402exit_fail:
403 iwl3945_led_unregister(priv);
404 return ret;
405}
406
407
408/* unregister led class */
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700409static void iwl3945_led_unregister_led(struct iwl_led *led, u8 set_led)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700410{
411 if (!led->registered)
412 return;
413
414 led_classdev_unregister(&led->led_dev);
415
416 if (set_led)
417 led->led_dev.brightness_set(&led->led_dev, LED_OFF);
418 led->registered = 0;
419}
420
421/* Unregister all led handlers */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800422void iwl3945_led_unregister(struct iwl_priv *priv)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700423{
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700424 iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_ASSOC], 0);
425 iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_RX], 0);
426 iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_TX], 0);
427 iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_RADIO], 1);
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700428}
429
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700430#endif