Commit | Line | Data |
---|---|---|
68c0bdff HG |
1 | /******************************************************************************* |
2 | * Agere Systems Inc. | |
3 | * Wireless device driver for Linux (wlags49). | |
4 | * | |
5 | * Copyright (c) 1998-2003 Agere Systems Inc. | |
6 | * All rights reserved. | |
7 | * http://www.agere.com | |
8 | * | |
9 | * Initially developed by TriplePoint, Inc. | |
10 | * http://www.triplepoint.com | |
11 | * | |
12 | *------------------------------------------------------------------------------ | |
13 | * | |
14 | * This file contains processing and initialization specific to Card Services | |
15 | * devices (PCMCIA, CF). | |
16 | * | |
17 | *------------------------------------------------------------------------------ | |
18 | * | |
19 | * SOFTWARE LICENSE | |
20 | * | |
21 | * This software is provided subject to the following terms and conditions, | |
22 | * which you should read carefully before using the software. Using this | |
23 | * software indicates your acceptance of these terms and conditions. If you do | |
24 | * not agree with these terms and conditions, do not use the software. | |
25 | * | |
8cd5778b | 26 | * Copyright (c) 2003 Agere Systems Inc. |
68c0bdff HG |
27 | * All rights reserved. |
28 | * | |
29 | * Redistribution and use in source or binary forms, with or without | |
30 | * modifications, are permitted provided that the following conditions are met: | |
31 | * | |
32 | * . Redistributions of source code must retain the above copyright notice, this | |
33 | * list of conditions and the following Disclaimer as comments in the code as | |
34 | * well as in the documentation and/or other materials provided with the | |
35 | * distribution. | |
36 | * | |
37 | * . Redistributions in binary form must reproduce the above copyright notice, | |
38 | * this list of conditions and the following Disclaimer in the documentation | |
39 | * and/or other materials provided with the distribution. | |
40 | * | |
41 | * . Neither the name of Agere Systems Inc. nor the names of the contributors | |
42 | * may be used to endorse or promote products derived from this software | |
43 | * without specific prior written permission. | |
44 | * | |
45 | * Disclaimer | |
46 | * | |
8cd5778b | 47 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
68c0bdff HG |
48 | * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF |
49 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY | |
50 | * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN | |
51 | * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY | |
52 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
53 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
54 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
55 | * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT | |
56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |
57 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | |
58 | * DAMAGE. | |
59 | * | |
60 | ******************************************************************************/ | |
61 | ||
68c0bdff HG |
62 | /******************************************************************************* |
63 | * include files | |
64 | ******************************************************************************/ | |
65 | #include <wl_version.h> | |
66 | ||
67 | #include <linux/kernel.h> | |
68 | #include <linux/sched.h> | |
69 | #include <linux/ptrace.h> | |
68c0bdff HG |
70 | #include <linux/ctype.h> |
71 | #include <linux/string.h> | |
72 | #include <linux/timer.h> | |
73 | #include <linux/interrupt.h> | |
74 | #include <linux/in.h> | |
75 | #include <linux/delay.h> | |
76 | #include <asm/io.h> | |
77 | #include <asm/system.h> | |
78 | #include <asm/bitops.h> | |
79 | ||
80 | #include <linux/netdevice.h> | |
81 | #include <linux/etherdevice.h> | |
82 | #include <linux/skbuff.h> | |
83 | #include <linux/if_arp.h> | |
84 | #include <linux/ioport.h> | |
85 | ||
68c0bdff HG |
86 | #include <pcmcia/cistpl.h> |
87 | #include <pcmcia/cisreg.h> | |
88 | #include <pcmcia/ciscode.h> | |
89 | #include <pcmcia/ds.h> | |
90 | #include <debug.h> | |
91 | ||
92 | #include <hcf.h> | |
93 | #include <dhf.h> | |
94 | #include <hcfdef.h> | |
95 | ||
96 | #include <wl_if.h> | |
97 | #include <wl_internal.h> | |
98 | #include <wl_util.h> | |
99 | #include <wl_main.h> | |
100 | #include <wl_netdev.h> | |
101 | #include <wl_cs.h> | |
102 | #include <wl_sysfs.h> | |
103 | ||
104 | ||
68c0bdff HG |
105 | /******************************************************************************* |
106 | * global definitions | |
107 | ******************************************************************************/ | |
108 | #if DBG | |
109 | extern dbg_info_t *DbgInfo; | |
110 | #endif /* DBG */ | |
111 | ||
112 | ||
113 | /******************************************************************************* | |
114 | * wl_adapter_attach() | |
115 | ******************************************************************************* | |
116 | * | |
117 | * DESCRIPTION: | |
118 | * | |
119 | * Creates an instance of the driver, allocating local data structures for | |
120 | * one device. The device is registered with Card Services. | |
121 | * | |
122 | * PARAMETERS: | |
123 | * | |
124 | * none | |
125 | * | |
126 | * RETURNS: | |
127 | * | |
128 | * pointer to an allocated dev_link_t structure | |
129 | * NULL on failure | |
130 | * | |
131 | ******************************************************************************/ | |
132 | static int wl_adapter_attach(struct pcmcia_device *link) | |
133 | { | |
6d98be39 PS |
134 | struct net_device *dev; |
135 | struct wl_private *lp; | |
194a636d | 136 | /*--------------------------------------------------------------------*/ |
6d98be39 PS |
137 | |
138 | DBG_FUNC("wl_adapter_attach"); | |
139 | DBG_ENTER(DbgInfo); | |
140 | ||
141 | dev = wl_device_alloc(); | |
142 | if (dev == NULL) { | |
143 | DBG_ERROR(DbgInfo, "wl_device_alloc returned NULL\n"); | |
144 | return -ENOMEM; | |
145 | } | |
146 | ||
1685e633 LT |
147 | link->resource[0]->end = HCF_NUM_IO_PORTS; |
148 | link->resource[0]->flags= IO_DATA_PATH_WIDTH_16; | |
1ac71e5a | 149 | link->config_flags |= CONF_ENABLE_IRQ; |
7feabb64 DB |
150 | link->config_index = 5; |
151 | link->config_regs = PRESENT_OPTION; | |
6d98be39 PS |
152 | |
153 | link->priv = dev; | |
154 | lp = wl_priv(dev); | |
155 | lp->link = link; | |
156 | ||
157 | wl_adapter_insert(link); | |
158 | ||
159 | DBG_LEAVE(DbgInfo); | |
160 | return 0; | |
194a636d | 161 | } /* wl_adapter_attach */ |
68c0bdff HG |
162 | /*============================================================================*/ |
163 | ||
164 | ||
165 | ||
166 | /******************************************************************************* | |
167 | * wl_adapter_detach() | |
168 | ******************************************************************************* | |
169 | * | |
170 | * DESCRIPTION: | |
171 | * | |
172 | * This deletes a driver "instance". The device is de-registered with Card | |
173 | * Services. If it has been released, then the net device is unregistered, and | |
174 | * all local data structures are freed. Otherwise, the structures will be | |
175 | * freed when the device is released. | |
176 | * | |
177 | * PARAMETERS: | |
178 | * | |
179 | * link - pointer to the dev_link_t structure representing the device to | |
180 | * detach | |
181 | * | |
182 | * RETURNS: | |
183 | * | |
184 | * N/A | |
185 | * | |
186 | ******************************************************************************/ | |
187 | static void wl_adapter_detach(struct pcmcia_device *link) | |
188 | { | |
6d98be39 | 189 | struct net_device *dev = link->priv; |
194a636d | 190 | /*--------------------------------------------------------------------*/ |
68c0bdff | 191 | |
6d98be39 PS |
192 | DBG_FUNC("wl_adapter_detach"); |
193 | DBG_ENTER(DbgInfo); | |
194 | DBG_PARAM(DbgInfo, "link", "0x%p", link); | |
68c0bdff | 195 | |
6d98be39 | 196 | wl_adapter_release(link); |
68c0bdff | 197 | |
6d98be39 PS |
198 | if (dev) { |
199 | unregister_wlags_sysfs(dev); | |
200 | unregister_netdev(dev); | |
201 | } | |
68c0bdff | 202 | |
6d98be39 | 203 | wl_device_dealloc(dev); |
68c0bdff | 204 | |
6d98be39 | 205 | DBG_LEAVE(DbgInfo); |
194a636d | 206 | } /* wl_adapter_detach */ |
68c0bdff HG |
207 | /*============================================================================*/ |
208 | ||
209 | ||
210 | /******************************************************************************* | |
211 | * wl_adapter_release() | |
212 | ******************************************************************************* | |
213 | * | |
214 | * DESCRIPTION: | |
215 | * | |
216 | * After a card is removed, this routine will release the PCMCIA | |
217 | * configuration. If the device is still open, this will be postponed until it | |
218 | * is closed. | |
219 | * | |
220 | * PARAMETERS: | |
221 | * | |
222 | * arg - a u_long representing a pointer to a dev_link_t structure for the | |
223 | * device to be released. | |
224 | * | |
225 | * RETURNS: | |
226 | * | |
227 | * N/A | |
228 | * | |
229 | ******************************************************************************/ | |
aa605fa4 | 230 | void wl_adapter_release(struct pcmcia_device *link) |
68c0bdff | 231 | { |
6d98be39 PS |
232 | DBG_FUNC("wl_adapter_release"); |
233 | DBG_ENTER(DbgInfo); | |
234 | DBG_PARAM(DbgInfo, "link", "0x%p", link); | |
68c0bdff | 235 | |
6d98be39 PS |
236 | /* Stop hardware */ |
237 | wl_remove(link->priv); | |
68c0bdff | 238 | |
6d98be39 | 239 | pcmcia_disable_device(link); |
68c0bdff | 240 | |
6d98be39 | 241 | DBG_LEAVE(DbgInfo); |
194a636d | 242 | } /* wl_adapter_release */ |
68c0bdff HG |
243 | /*============================================================================*/ |
244 | ||
245 | static int wl_adapter_suspend(struct pcmcia_device *link) | |
246 | { | |
6d98be39 | 247 | struct net_device *dev = link->priv; |
68c0bdff | 248 | |
194a636d | 249 | /* if (link->open) { */ |
68c0bdff HG |
250 | netif_device_detach(dev); |
251 | wl_suspend(dev); | |
194a636d PS |
252 | /* CHECK! pcmcia_release_configuration(link->handle); */ |
253 | /* } */ | |
68c0bdff | 254 | |
6d98be39 | 255 | return 0; |
194a636d | 256 | } /* wl_adapter_suspend */ |
68c0bdff HG |
257 | |
258 | static int wl_adapter_resume(struct pcmcia_device *link) | |
259 | { | |
260 | struct net_device *dev = link->priv; | |
261 | ||
262 | wl_resume(dev); | |
263 | ||
aa605fa4 | 264 | netif_device_attach(dev); |
68c0bdff HG |
265 | |
266 | return 0; | |
194a636d | 267 | } /* wl_adapter_resume */ |
68c0bdff HG |
268 | |
269 | /******************************************************************************* | |
270 | * wl_adapter_insert() | |
271 | ******************************************************************************* | |
272 | * | |
273 | * DESCRIPTION: | |
274 | * | |
275 | * wl_adapter_insert() is scheduled to run after a CARD_INSERTION event is | |
276 | * received, to configure the PCMCIA socket, and to make the ethernet device | |
277 | * available to the system. | |
278 | * | |
279 | * PARAMETERS: | |
280 | * | |
281 | * link - pointer to the dev_link_t structure representing the device to | |
282 | * insert | |
283 | * | |
284 | * RETURNS: | |
285 | * | |
286 | * N/A | |
287 | * | |
288 | ******************************************************************************/ | |
aa605fa4 | 289 | void wl_adapter_insert(struct pcmcia_device *link) |
68c0bdff | 290 | { |
6d98be39 PS |
291 | struct net_device *dev; |
292 | int i; | |
293 | int ret; | |
194a636d | 294 | /*--------------------------------------------------------------------*/ |
68c0bdff | 295 | |
6d98be39 PS |
296 | DBG_FUNC("wl_adapter_insert"); |
297 | DBG_ENTER(DbgInfo); | |
298 | DBG_PARAM(DbgInfo, "link", "0x%p", link); | |
68c0bdff | 299 | |
6d98be39 | 300 | dev = link->priv; |
68c0bdff | 301 | |
6d98be39 | 302 | /* Do we need to allocate an interrupt? */ |
1ac71e5a | 303 | link->config_flags |= CONF_ENABLE_IRQ; |
1685e633 | 304 | link->io_lines = 6; |
68c0bdff | 305 | |
1685e633 | 306 | ret = pcmcia_request_io(link); |
6d98be39 PS |
307 | if (ret != 0) |
308 | goto failed; | |
93822ad1 | 309 | |
6d98be39 PS |
310 | ret = pcmcia_request_irq(link, (void *) wl_isr); |
311 | if (ret != 0) | |
312 | goto failed; | |
68c0bdff | 313 | |
1ac71e5a | 314 | ret = pcmcia_enable_device(link); |
6d98be39 PS |
315 | if (ret != 0) |
316 | goto failed; | |
68c0bdff | 317 | |
6d98be39 | 318 | dev->irq = link->irq; |
1685e633 | 319 | dev->base_addr = link->resource[0]->start; |
68c0bdff | 320 | |
6d98be39 PS |
321 | SET_NETDEV_DEV(dev, &link->dev); |
322 | if (register_netdev(dev) != 0) { | |
323 | printk("%s: register_netdev() failed\n", MODULE_NAME); | |
324 | goto failed; | |
325 | } | |
93822ad1 | 326 | |
6d98be39 | 327 | register_wlags_sysfs(dev); |
68c0bdff | 328 | |
6d98be39 PS |
329 | printk(KERN_INFO "%s: Wireless, io_addr %#03lx, irq %d, ""mac_address ", |
330 | dev->name, dev->base_addr, dev->irq); | |
194a636d | 331 | for (i = 0; i < ETH_ALEN; i++) |
6d98be39 | 332 | printk("%02X%c", dev->dev_addr[i], ((i < (ETH_ALEN-1)) ? ':' : '\n')); |
68c0bdff | 333 | |
6d98be39 PS |
334 | DBG_LEAVE(DbgInfo); |
335 | return; | |
68c0bdff | 336 | |
68c0bdff | 337 | failed: |
6d98be39 | 338 | wl_adapter_release(link); |
68c0bdff | 339 | |
6d98be39 PS |
340 | DBG_LEAVE(DbgInfo); |
341 | return; | |
194a636d | 342 | } /* wl_adapter_insert */ |
68c0bdff HG |
343 | /*============================================================================*/ |
344 | ||
345 | ||
346 | /******************************************************************************* | |
347 | * wl_adapter_open() | |
348 | ******************************************************************************* | |
349 | * | |
350 | * DESCRIPTION: | |
351 | * | |
352 | * Open the device. | |
353 | * | |
354 | * PARAMETERS: | |
355 | * | |
356 | * dev - a pointer to a net_device structure representing the network | |
357 | * device to open. | |
358 | * | |
359 | * RETURNS: | |
360 | * | |
361 | * 0 on success | |
362 | * errno value otherwise | |
363 | * | |
364 | ******************************************************************************/ | |
aa605fa4 | 365 | int wl_adapter_open(struct net_device *dev) |
68c0bdff | 366 | { |
6d98be39 PS |
367 | struct wl_private *lp = wl_priv(dev); |
368 | struct pcmcia_device *link = lp->link; | |
369 | int result = 0; | |
370 | int hcf_status = HCF_SUCCESS; | |
194a636d | 371 | /*--------------------------------------------------------------------*/ |
68c0bdff | 372 | |
6d98be39 PS |
373 | DBG_FUNC("wl_adapter_open"); |
374 | DBG_ENTER(DbgInfo); | |
aa605fa4 | 375 | DBG_PRINT("%s\n", VERSION_INFO); |
6d98be39 | 376 | DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev); |
68c0bdff | 377 | |
194a636d | 378 | if (!pcmcia_dev_present(link)) { |
6d98be39 PS |
379 | DBG_LEAVE(DbgInfo); |
380 | return -ENODEV; | |
381 | } | |
68c0bdff | 382 | |
6d98be39 | 383 | link->open++; |
68c0bdff | 384 | |
6d98be39 | 385 | hcf_status = wl_open(dev); |
68c0bdff | 386 | |
6d98be39 PS |
387 | if (hcf_status != HCF_SUCCESS) { |
388 | link->open--; | |
389 | result = -ENODEV; | |
390 | } | |
68c0bdff | 391 | |
6d98be39 PS |
392 | DBG_LEAVE(DbgInfo); |
393 | return result; | |
194a636d | 394 | } /* wl_adapter_open */ |
68c0bdff HG |
395 | /*============================================================================*/ |
396 | ||
397 | ||
398 | /******************************************************************************* | |
399 | * wl_adapter_close() | |
400 | ******************************************************************************* | |
401 | * | |
402 | * DESCRIPTION: | |
403 | * | |
404 | * Close the device. | |
405 | * | |
406 | * PARAMETERS: | |
407 | * | |
408 | * dev - a pointer to a net_device structure representing the network | |
409 | * device to close. | |
410 | * | |
411 | * RETURNS: | |
412 | * | |
413 | * 0 on success | |
414 | * errno value otherwise | |
415 | * | |
416 | ******************************************************************************/ | |
aa605fa4 | 417 | int wl_adapter_close(struct net_device *dev) |
68c0bdff | 418 | { |
6d98be39 PS |
419 | struct wl_private *lp = wl_priv(dev); |
420 | struct pcmcia_device *link = lp->link; | |
194a636d | 421 | /*--------------------------------------------------------------------*/ |
68c0bdff | 422 | |
6d98be39 PS |
423 | DBG_FUNC("wl_adapter_close"); |
424 | DBG_ENTER(DbgInfo); | |
425 | DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev); | |
68c0bdff | 426 | |
6d98be39 PS |
427 | if (link == NULL) { |
428 | DBG_LEAVE(DbgInfo); | |
429 | return -ENODEV; | |
430 | } | |
68c0bdff | 431 | |
6d98be39 PS |
432 | DBG_TRACE(DbgInfo, "%s: Shutting down adapter.\n", dev->name); |
433 | wl_close(dev); | |
68c0bdff | 434 | |
6d98be39 | 435 | link->open--; |
68c0bdff | 436 | |
6d98be39 PS |
437 | DBG_LEAVE(DbgInfo); |
438 | return 0; | |
194a636d | 439 | } /* wl_adapter_close */ |
68c0bdff HG |
440 | /*============================================================================*/ |
441 | ||
442 | static struct pcmcia_device_id wl_adapter_ids[] = { | |
194a636d | 443 | #if !((HCF_TYPE) & HCF_TYPE_HII5) |
68c0bdff HG |
444 | PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0003), |
445 | PCMCIA_DEVICE_PROD_ID12("Agere Systems", "Wireless PC Card Model 0110", | |
6d98be39 | 446 | 0x33103a9b, 0xe175b0dd), |
68c0bdff HG |
447 | #else |
448 | PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0004), | |
449 | PCMCIA_DEVICE_PROD_ID12("Linksys", "WCF54G_Wireless-G_CompactFlash_Card", | |
6d98be39 | 450 | 0x0733cc81, 0x98a599e1), |
194a636d | 451 | #endif /* (HCF_TYPE) & HCF_TYPE_HII5 */ |
68c0bdff | 452 | PCMCIA_DEVICE_NULL, |
6d98be39 | 453 | }; |
68c0bdff HG |
454 | MODULE_DEVICE_TABLE(pcmcia, wl_adapter_ids); |
455 | ||
456 | static struct pcmcia_driver wlags49_driver = { | |
6d98be39 | 457 | .owner = THIS_MODULE, |
2e9b981a | 458 | .name = DRIVER_NAME, |
6d98be39 PS |
459 | .probe = wl_adapter_attach, |
460 | .remove = wl_adapter_detach, | |
461 | .id_table = wl_adapter_ids, | |
462 | .suspend = wl_adapter_suspend, | |
463 | .resume = wl_adapter_resume, | |
68c0bdff HG |
464 | }; |
465 | ||
466 | ||
467 | ||
468 | /******************************************************************************* | |
469 | * wl_adapter_init_module() | |
470 | ******************************************************************************* | |
471 | * | |
472 | * DESCRIPTION: | |
473 | * | |
474 | * Called by init_module() to perform PCMCIA driver initialization. | |
475 | * | |
476 | * PARAMETERS: | |
477 | * | |
478 | * N/A | |
479 | * | |
480 | * RETURNS: | |
481 | * | |
482 | * 0 on success | |
483 | * -1 on error | |
484 | * | |
485 | ******************************************************************************/ | |
aa605fa4 | 486 | int wl_adapter_init_module(void) |
68c0bdff | 487 | { |
6d98be39 | 488 | int ret; |
194a636d | 489 | /*--------------------------------------------------------------------*/ |
68c0bdff | 490 | |
6d98be39 PS |
491 | DBG_FUNC("wl_adapter_init_module"); |
492 | DBG_ENTER(DbgInfo); | |
493 | DBG_TRACE(DbgInfo, "wl_adapter_init_module() -- PCMCIA\n"); | |
68c0bdff | 494 | |
6d98be39 | 495 | ret = pcmcia_register_driver(&wlags49_driver); |
68c0bdff | 496 | |
6d98be39 PS |
497 | DBG_LEAVE(DbgInfo); |
498 | return ret; | |
194a636d | 499 | } /* wl_adapter_init_module */ |
68c0bdff HG |
500 | /*============================================================================*/ |
501 | ||
502 | ||
503 | /******************************************************************************* | |
504 | * wl_adapter_cleanup_module() | |
505 | ******************************************************************************* | |
506 | * | |
507 | * DESCRIPTION: | |
508 | * | |
509 | * Called by cleanup_module() to perform driver uninitialization. | |
510 | * | |
511 | * PARAMETERS: | |
512 | * | |
513 | * N/A | |
514 | * | |
515 | * RETURNS: | |
516 | * | |
517 | * N/A | |
518 | * | |
519 | ******************************************************************************/ | |
aa605fa4 | 520 | void wl_adapter_cleanup_module(void) |
68c0bdff | 521 | { |
6d98be39 PS |
522 | DBG_FUNC("wl_adapter_cleanup_module"); |
523 | DBG_ENTER(DbgInfo); | |
524 | DBG_TRACE(DbgInfo, "wl_adapter_cleanup_module() -- PCMCIA\n"); | |
68c0bdff HG |
525 | |
526 | ||
6d98be39 | 527 | pcmcia_unregister_driver(&wlags49_driver); |
68c0bdff | 528 | |
6d98be39 PS |
529 | DBG_LEAVE(DbgInfo); |
530 | return; | |
194a636d | 531 | } /* wl_adapter_cleanup_module */ |
68c0bdff HG |
532 | /*============================================================================*/ |
533 | ||
534 | ||
535 | /******************************************************************************* | |
536 | * wl_adapter_is_open() | |
537 | ******************************************************************************* | |
538 | * | |
539 | * DESCRIPTION: | |
540 | * | |
541 | * Check with Card Services to determine if this device is open. | |
542 | * | |
543 | * PARAMETERS: | |
544 | * | |
545 | * dev - a pointer to the net_device structure whose open status will be | |
546 | * checked | |
547 | * | |
548 | * RETURNS: | |
549 | * | |
550 | * nonzero if device is open | |
551 | * 0 otherwise | |
552 | * | |
553 | ******************************************************************************/ | |
aa605fa4 | 554 | int wl_adapter_is_open(struct net_device *dev) |
68c0bdff | 555 | { |
6d98be39 PS |
556 | struct wl_private *lp = wl_priv(dev); |
557 | struct pcmcia_device *link = lp->link; | |
68c0bdff | 558 | |
194a636d | 559 | if (!pcmcia_dev_present(link)) |
6d98be39 | 560 | return 0; |
68c0bdff | 561 | |
194a636d PS |
562 | return link->open; |
563 | } /* wl_adapter_is_open */ | |
68c0bdff HG |
564 | /*============================================================================*/ |
565 | ||
566 | ||
567 | #if DBG | |
568 | ||
569 | /******************************************************************************* | |
570 | * DbgEvent() | |
571 | ******************************************************************************* | |
572 | * | |
573 | * DESCRIPTION: | |
574 | * | |
575 | * Converts the card serivces events to text for debugging. | |
576 | * | |
577 | * PARAMETERS: | |
578 | * | |
579 | * mask - a integer representing the error(s) being reported by Card | |
580 | * Services. | |
581 | * | |
582 | * RETURNS: | |
583 | * | |
584 | * a pointer to a string describing the error(s) | |
585 | * | |
586 | ******************************************************************************/ | |
194a636d | 587 | const char *DbgEvent(int mask) |
68c0bdff | 588 | { |
6d98be39 PS |
589 | static char DbgBuffer[256]; |
590 | char *pBuf; | |
194a636d | 591 | /*--------------------------------------------------------------------*/ |
68c0bdff | 592 | |
6d98be39 PS |
593 | pBuf = DbgBuffer; |
594 | *pBuf = '\0'; | |
68c0bdff HG |
595 | |
596 | ||
6d98be39 PS |
597 | if (mask & CS_EVENT_WRITE_PROTECT) |
598 | strcat(pBuf, "WRITE_PROTECT "); | |
68c0bdff | 599 | |
6d98be39 PS |
600 | if (mask & CS_EVENT_CARD_LOCK) |
601 | strcat(pBuf, "CARD_LOCK "); | |
68c0bdff | 602 | |
6d98be39 PS |
603 | if (mask & CS_EVENT_CARD_INSERTION) |
604 | strcat(pBuf, "CARD_INSERTION "); | |
68c0bdff | 605 | |
6d98be39 PS |
606 | if (mask & CS_EVENT_CARD_REMOVAL) |
607 | strcat(pBuf, "CARD_REMOVAL "); | |
68c0bdff | 608 | |
6d98be39 PS |
609 | if (mask & CS_EVENT_BATTERY_DEAD) |
610 | strcat(pBuf, "BATTERY_DEAD "); | |
68c0bdff | 611 | |
6d98be39 PS |
612 | if (mask & CS_EVENT_BATTERY_LOW) |
613 | strcat(pBuf, "BATTERY_LOW "); | |
68c0bdff | 614 | |
6d98be39 PS |
615 | if (mask & CS_EVENT_READY_CHANGE) |
616 | strcat(pBuf, "READY_CHANGE "); | |
68c0bdff | 617 | |
6d98be39 PS |
618 | if (mask & CS_EVENT_CARD_DETECT) |
619 | strcat(pBuf, "CARD_DETECT "); | |
68c0bdff | 620 | |
6d98be39 PS |
621 | if (mask & CS_EVENT_RESET_REQUEST) |
622 | strcat(pBuf, "RESET_REQUEST "); | |
68c0bdff | 623 | |
6d98be39 PS |
624 | if (mask & CS_EVENT_RESET_PHYSICAL) |
625 | strcat(pBuf, "RESET_PHYSICAL "); | |
68c0bdff | 626 | |
6d98be39 PS |
627 | if (mask & CS_EVENT_CARD_RESET) |
628 | strcat(pBuf, "CARD_RESET "); | |
68c0bdff | 629 | |
6d98be39 PS |
630 | if (mask & CS_EVENT_REGISTRATION_COMPLETE) |
631 | strcat(pBuf, "REGISTRATION_COMPLETE "); | |
68c0bdff | 632 | |
194a636d PS |
633 | /* if (mask & CS_EVENT_RESET_COMPLETE) |
634 | strcat(pBuf, "RESET_COMPLETE "); */ | |
68c0bdff | 635 | |
6d98be39 PS |
636 | if (mask & CS_EVENT_PM_SUSPEND) |
637 | strcat(pBuf, "PM_SUSPEND "); | |
68c0bdff | 638 | |
6d98be39 PS |
639 | if (mask & CS_EVENT_PM_RESUME) |
640 | strcat(pBuf, "PM_RESUME "); | |
68c0bdff | 641 | |
6d98be39 PS |
642 | if (mask & CS_EVENT_INSERTION_REQUEST) |
643 | strcat(pBuf, "INSERTION_REQUEST "); | |
68c0bdff | 644 | |
6d98be39 PS |
645 | if (mask & CS_EVENT_EJECTION_REQUEST) |
646 | strcat(pBuf, "EJECTION_REQUEST "); | |
68c0bdff | 647 | |
6d98be39 PS |
648 | if (mask & CS_EVENT_MTD_REQUEST) |
649 | strcat(pBuf, "MTD_REQUEST "); | |
68c0bdff | 650 | |
6d98be39 PS |
651 | if (mask & CS_EVENT_ERASE_COMPLETE) |
652 | strcat(pBuf, "ERASE_COMPLETE "); | |
68c0bdff | 653 | |
6d98be39 PS |
654 | if (mask & CS_EVENT_REQUEST_ATTENTION) |
655 | strcat(pBuf, "REQUEST_ATTENTION "); | |
68c0bdff | 656 | |
6d98be39 PS |
657 | if (mask & CS_EVENT_CB_DETECT) |
658 | strcat(pBuf, "CB_DETECT "); | |
68c0bdff | 659 | |
6d98be39 PS |
660 | if (mask & CS_EVENT_3VCARD) |
661 | strcat(pBuf, "3VCARD "); | |
68c0bdff | 662 | |
6d98be39 PS |
663 | if (mask & CS_EVENT_XVCARD) |
664 | strcat(pBuf, "XVCARD "); | |
68c0bdff HG |
665 | |
666 | ||
6d98be39 PS |
667 | if (*pBuf) { |
668 | pBuf[strlen(pBuf) - 1] = '\0'; | |
669 | } else { | |
194a636d | 670 | if (mask != 0x0) |
6d98be39 | 671 | sprintf(pBuf, "<<0x%08x>>", mask); |
6d98be39 | 672 | } |
68c0bdff | 673 | |
6d98be39 | 674 | return pBuf; |
194a636d | 675 | } /* DbgEvent */ |
68c0bdff HG |
676 | /*============================================================================*/ |
677 | ||
678 | #endif /* DBG */ |