blob: bd7e520d98c2ecfd51d58bd2fdc4ff53ece72642 [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
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +080082static int iwl3945_led_cmd_callback(struct iwl_priv *priv,
Winkler, Tomasc2d79b42008-12-19 10:37:34 +080083 struct iwl_cmd *cmd,
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070084 struct sk_buff *skb)
85{
86 return 1;
87}
88
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +080089static inline int iwl3945_brightness_to_idx(enum led_brightness brightness)
90{
91 return fls(0x000000FF & (u32)brightness);
92}
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070093
94/* Send led command */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +080095static int iwl_send_led_cmd(struct iwl_priv *priv,
Tomas Winkler4c897252008-12-19 10:37:05 +080096 struct iwl_led_cmd *led_cmd)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070097{
Winkler, Tomasc2d79b42008-12-19 10:37:34 +080098 struct iwl_host_cmd cmd = {
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070099 .id = REPLY_LEDS_CMD,
Tomas Winkler4c897252008-12-19 10:37:05 +0800100 .len = sizeof(struct iwl_led_cmd),
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700101 .data = led_cmd,
102 .meta.flags = CMD_ASYNC,
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800103 .meta.u.callback = iwl3945_led_cmd_callback,
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700104 };
105
Samuel Ortiz518099a2009-01-19 15:30:27 -0800106 return iwl_send_cmd(priv, &cmd);
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700107}
108
109
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800110
111/* Set led on command */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800112static int iwl3945_led_pattern(struct iwl_priv *priv, int led_id,
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800113 unsigned int idx)
114{
Tomas Winkler4c897252008-12-19 10:37:05 +0800115 struct iwl_led_cmd led_cmd = {
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800116 .id = led_id,
117 .interval = IWL_DEF_LED_INTRVL
118 };
119
120 BUG_ON(idx > IWL_MAX_BLINK_TBL);
121
122 led_cmd.on = blink_tbl[idx].on_time;
123 led_cmd.off = blink_tbl[idx].off_time;
124
125 return iwl_send_led_cmd(priv, &led_cmd);
126}
127
128
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700129/* Set led on command */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800130static int iwl3945_led_on(struct iwl_priv *priv, int led_id)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700131{
Tomas Winkler4c897252008-12-19 10:37:05 +0800132 struct iwl_led_cmd led_cmd = {
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700133 .id = led_id,
134 .on = IWL_LED_SOLID,
135 .off = 0,
136 .interval = IWL_DEF_LED_INTRVL
137 };
138 return iwl_send_led_cmd(priv, &led_cmd);
139}
140
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700141/* Set led off command */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800142static int iwl3945_led_off(struct iwl_priv *priv, int led_id)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700143{
Tomas Winkler4c897252008-12-19 10:37:05 +0800144 struct iwl_led_cmd led_cmd = {
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700145 .id = led_id,
146 .on = 0,
147 .off = 0,
148 .interval = IWL_DEF_LED_INTRVL
149 };
Tomas Winklere1623442009-01-27 14:27:56 -0800150 IWL_DEBUG_LED(priv, "led off %d\n", led_id);
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700151 return iwl_send_led_cmd(priv, &led_cmd);
152}
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700153
154/*
Abhijeet Kolekar749e0912009-05-21 13:44:21 -0700155 * 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/*
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700179 * brightness call back function for Tx/Rx LED
180 */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800181static int iwl3945_led_associated(struct iwl_priv *priv, int led_id)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700182{
183 if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||
184 !test_bit(STATUS_READY, &priv->status))
185 return 0;
186
187
188 /* start counting Tx/Rx bytes */
189 if (!priv->last_blink_time && priv->allow_blinking)
190 priv->last_blink_time = jiffies;
191 return 0;
192}
193
194/*
195 * brightness call back for association and radio
196 */
197static void iwl3945_led_brightness_set(struct led_classdev *led_cdev,
198 enum led_brightness brightness)
199{
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700200 struct iwl_led *led = container_of(led_cdev,
Abhijeet Kolekar749e0912009-05-21 13:44:21 -0700201 struct iwl_led, led_dev);
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800202 struct iwl_priv *priv = led->priv;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700203
204 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
205 return;
206
Abhijeet Kolekar749e0912009-05-21 13:44:21 -0700207 IWL_DEBUG_LED(priv, "Led type = %s brightness = %d\n",
208 led_type_str[led->type], brightness);
209
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700210 switch (brightness) {
211 case LED_FULL:
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700212 if (led->led_on)
213 led->led_on(priv, IWL_LED_LINK);
214 break;
215 case LED_OFF:
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700216 if (led->led_off)
217 led->led_off(priv, IWL_LED_LINK);
218 break;
219 default:
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800220 if (led->led_pattern) {
221 int idx = iwl3945_brightness_to_idx(brightness);
222 led->led_pattern(priv, IWL_LED_LINK, idx);
223 }
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700224 break;
225 }
226}
227
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700228/*
229 * Register led class with the system
230 */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800231static int iwl3945_led_register_led(struct iwl_priv *priv,
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700232 struct iwl_led *led,
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700233 enum led_type type, u8 set_led,
Sven Wegener5cbbb372008-08-01 21:57:16 +0200234 char *trigger)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700235{
236 struct device *device = wiphy_dev(priv->hw->wiphy);
237 int ret;
238
Sven Wegener5cbbb372008-08-01 21:57:16 +0200239 led->led_dev.name = led->name;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700240 led->led_dev.brightness_set = iwl3945_led_brightness_set;
241 led->led_dev.default_trigger = trigger;
242
Marcin Slusarzb6b16192008-06-08 13:13:06 +0200243 led->priv = priv;
244 led->type = type;
245
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700246 ret = led_classdev_register(device, &led->led_dev);
247 if (ret) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800248 IWL_ERR(priv, "Error: failed to register led handler.\n");
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700249 return ret;
250 }
251
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700252 led->registered = 1;
253
254 if (set_led && led->led_on)
255 led->led_on(priv, IWL_LED_LINK);
256 return 0;
257}
258
259
260/*
261 * calculate blink rate according to last 2 sec Tx/Rx activities
262 */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800263static inline u8 get_blink_rate(struct iwl_priv *priv)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700264{
265 int index;
Abhijeet Kolekar749e0912009-05-21 13:44:21 -0700266 s64 tpt = priv->rxtxpackets;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700267
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800268 if (tpt < 0)
269 tpt = -tpt;
Abhijeet Kolekar749e0912009-05-21 13:44:21 -0700270
271 IWL_DEBUG_LED(priv, "tpt %lld \n", (long long)tpt);
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800272
273 if (!priv->allow_blinking)
274 index = IWL_MAX_BLINK_TBL;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700275 else
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800276 for (index = 0; index < IWL_MAX_BLINK_TBL; index++)
277 if (tpt > (blink_tbl[index].brightness * IWL_1MB_RATE))
278 break;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700279
Abhijeet Kolekar749e0912009-05-21 13:44:21 -0700280 IWL_DEBUG_LED(priv, "LED BLINK IDX=%d\n", index);
281 return index;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700282}
283
284/*
285 * this function called from handler. Since setting Led command can
286 * happen very frequent we postpone led command to be called from
287 * REPLY handler so we know ucode is up
288 */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800289void iwl3945_led_background(struct iwl_priv *priv)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700290{
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800291 u8 blink_idx;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700292
293 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
294 priv->last_blink_time = 0;
295 return;
296 }
Abhijeet Kolekar749e0912009-05-21 13:44:21 -0700297 if (iwl_is_rfkill(priv)) {
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700298 priv->last_blink_time = 0;
299 return;
300 }
301
302 if (!priv->allow_blinking) {
303 priv->last_blink_time = 0;
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800304 if (priv->last_blink_rate != IWL_SOLID_BLINK_IDX) {
305 priv->last_blink_rate = IWL_SOLID_BLINK_IDX;
306 iwl3945_led_pattern(priv, IWL_LED_LINK,
307 IWL_SOLID_BLINK_IDX);
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700308 }
309 return;
310 }
311 if (!priv->last_blink_time ||
312 !time_after(jiffies, priv->last_blink_time +
313 msecs_to_jiffies(1000)))
314 return;
315
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800316 blink_idx = get_blink_rate(priv);
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700317
318 /* call only if blink rate change */
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800319 if (blink_idx != priv->last_blink_rate)
320 iwl3945_led_pattern(priv, IWL_LED_LINK, blink_idx);
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700321
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800322 priv->last_blink_time = jiffies;
323 priv->last_blink_rate = blink_idx;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700324 priv->rxtxpackets = 0;
325}
326
327
328/* Register all led handler */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800329int iwl3945_led_register(struct iwl_priv *priv)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700330{
331 char *trigger;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700332 int ret;
333
334 priv->last_blink_rate = 0;
335 priv->rxtxpackets = 0;
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800336 priv->led_tpt = 0;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700337 priv->last_blink_time = 0;
338 priv->allow_blinking = 0;
339
340 trigger = ieee80211_get_radio_led_name(priv->hw);
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700341 snprintf(priv->led[IWL_LED_TRG_RADIO].name,
342 sizeof(priv->led[IWL_LED_TRG_RADIO].name), "iwl-%s::radio",
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700343 wiphy_name(priv->hw->wiphy));
344
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700345 priv->led[IWL_LED_TRG_RADIO].led_on = iwl3945_led_on;
346 priv->led[IWL_LED_TRG_RADIO].led_off = iwl3945_led_off;
347 priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700348
349 ret = iwl3945_led_register_led(priv,
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700350 &priv->led[IWL_LED_TRG_RADIO],
Sven Wegener5cbbb372008-08-01 21:57:16 +0200351 IWL_LED_TRG_RADIO, 1, trigger);
352
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700353 if (ret)
354 goto exit_fail;
355
356 trigger = ieee80211_get_assoc_led_name(priv->hw);
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700357 snprintf(priv->led[IWL_LED_TRG_ASSOC].name,
358 sizeof(priv->led[IWL_LED_TRG_ASSOC].name), "iwl-%s::assoc",
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700359 wiphy_name(priv->hw->wiphy));
360
361 ret = iwl3945_led_register_led(priv,
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700362 &priv->led[IWL_LED_TRG_ASSOC],
Sven Wegener5cbbb372008-08-01 21:57:16 +0200363 IWL_LED_TRG_ASSOC, 0, trigger);
364
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700365 /* for assoc always turn led on */
Abhijeet Kolekar749e0912009-05-21 13:44:21 -0700366 priv->led[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_associate;
367 priv->led[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_disassociate;
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700368 priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700369
370 if (ret)
371 goto exit_fail;
372
373 trigger = ieee80211_get_rx_led_name(priv->hw);
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700374 snprintf(priv->led[IWL_LED_TRG_RX].name,
375 sizeof(priv->led[IWL_LED_TRG_RX].name), "iwl-%s::RX",
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700376 wiphy_name(priv->hw->wiphy));
377
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700378 ret = iwl3945_led_register_led(priv,
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700379 &priv->led[IWL_LED_TRG_RX],
Sven Wegener5cbbb372008-08-01 21:57:16 +0200380 IWL_LED_TRG_RX, 0, trigger);
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700381
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700382 priv->led[IWL_LED_TRG_RX].led_on = iwl3945_led_associated;
383 priv->led[IWL_LED_TRG_RX].led_off = iwl3945_led_associated;
384 priv->led[IWL_LED_TRG_RX].led_pattern = iwl3945_led_pattern;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700385
386 if (ret)
387 goto exit_fail;
388
389 trigger = ieee80211_get_tx_led_name(priv->hw);
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700390 snprintf(priv->led[IWL_LED_TRG_TX].name,
391 sizeof(priv->led[IWL_LED_TRG_TX].name), "iwl-%s::TX",
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700392 wiphy_name(priv->hw->wiphy));
Abhijeet Kolekar9a9ad0c2008-07-11 11:53:41 +0800393
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700394 ret = iwl3945_led_register_led(priv,
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700395 &priv->led[IWL_LED_TRG_TX],
Sven Wegener5cbbb372008-08-01 21:57:16 +0200396 IWL_LED_TRG_TX, 0, trigger);
397
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700398 priv->led[IWL_LED_TRG_TX].led_on = iwl3945_led_associated;
399 priv->led[IWL_LED_TRG_TX].led_off = iwl3945_led_associated;
400 priv->led[IWL_LED_TRG_TX].led_pattern = iwl3945_led_pattern;
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700401
402 if (ret)
403 goto exit_fail;
404
405 return 0;
406
407exit_fail:
408 iwl3945_led_unregister(priv);
409 return ret;
410}
411
412
413/* unregister led class */
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700414static void iwl3945_led_unregister_led(struct iwl_led *led, u8 set_led)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700415{
416 if (!led->registered)
417 return;
418
419 led_classdev_unregister(&led->led_dev);
420
421 if (set_led)
422 led->led_dev.brightness_set(&led->led_dev, LED_OFF);
423 led->registered = 0;
424}
425
426/* Unregister all led handlers */
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800427void iwl3945_led_unregister(struct iwl_priv *priv)
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700428{
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700429 iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_ASSOC], 0);
430 iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_RX], 0);
431 iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_TX], 0);
432 iwl3945_led_unregister_led(&priv->led[IWL_LED_TRG_RADIO], 1);
Mohamed Abbasab53d8a2008-03-25 16:33:36 -0700433}
434
Abhijeet Kolekar5c8df2d2009-03-11 11:17:55 -0700435#endif