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 | ||
86 | #include <pcmcia/cs_types.h> | |
87 | #include <pcmcia/cs.h> | |
88 | #include <pcmcia/cistpl.h> | |
89 | #include <pcmcia/cisreg.h> | |
90 | #include <pcmcia/ciscode.h> | |
91 | #include <pcmcia/ds.h> | |
92 | #include <debug.h> | |
93 | ||
94 | #include <hcf.h> | |
95 | #include <dhf.h> | |
96 | #include <hcfdef.h> | |
97 | ||
98 | #include <wl_if.h> | |
99 | #include <wl_internal.h> | |
100 | #include <wl_util.h> | |
101 | #include <wl_main.h> | |
102 | #include <wl_netdev.h> | |
103 | #include <wl_cs.h> | |
104 | #include <wl_sysfs.h> | |
105 | ||
106 | ||
68c0bdff HG |
107 | /******************************************************************************* |
108 | * global definitions | |
109 | ******************************************************************************/ | |
110 | #if DBG | |
111 | extern dbg_info_t *DbgInfo; | |
112 | #endif /* DBG */ | |
113 | ||
114 | ||
115 | /******************************************************************************* | |
116 | * wl_adapter_attach() | |
117 | ******************************************************************************* | |
118 | * | |
119 | * DESCRIPTION: | |
120 | * | |
121 | * Creates an instance of the driver, allocating local data structures for | |
122 | * one device. The device is registered with Card Services. | |
123 | * | |
124 | * PARAMETERS: | |
125 | * | |
126 | * none | |
127 | * | |
128 | * RETURNS: | |
129 | * | |
130 | * pointer to an allocated dev_link_t structure | |
131 | * NULL on failure | |
132 | * | |
133 | ******************************************************************************/ | |
134 | static int wl_adapter_attach(struct pcmcia_device *link) | |
135 | { | |
6d98be39 PS |
136 | struct net_device *dev; |
137 | struct wl_private *lp; | |
194a636d | 138 | /*--------------------------------------------------------------------*/ |
6d98be39 PS |
139 | |
140 | DBG_FUNC("wl_adapter_attach"); | |
141 | DBG_ENTER(DbgInfo); | |
142 | ||
143 | dev = wl_device_alloc(); | |
144 | if (dev == NULL) { | |
145 | DBG_ERROR(DbgInfo, "wl_device_alloc returned NULL\n"); | |
146 | return -ENOMEM; | |
147 | } | |
148 | ||
149 | link->io.NumPorts1 = HCF_NUM_IO_PORTS; | |
150 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | |
151 | link->io.IOAddrLines = 6; | |
152 | link->conf.Attributes = CONF_ENABLE_IRQ; | |
153 | link->conf.IntType = INT_MEMORY_AND_IO; | |
154 | link->conf.ConfigIndex = 5; | |
155 | link->conf.Present = PRESENT_OPTION; | |
156 | ||
157 | link->priv = dev; | |
158 | lp = wl_priv(dev); | |
159 | lp->link = link; | |
160 | ||
161 | wl_adapter_insert(link); | |
162 | ||
163 | DBG_LEAVE(DbgInfo); | |
164 | return 0; | |
194a636d | 165 | } /* wl_adapter_attach */ |
68c0bdff HG |
166 | /*============================================================================*/ |
167 | ||
168 | ||
169 | ||
170 | /******************************************************************************* | |
171 | * wl_adapter_detach() | |
172 | ******************************************************************************* | |
173 | * | |
174 | * DESCRIPTION: | |
175 | * | |
176 | * This deletes a driver "instance". The device is de-registered with Card | |
177 | * Services. If it has been released, then the net device is unregistered, and | |
178 | * all local data structures are freed. Otherwise, the structures will be | |
179 | * freed when the device is released. | |
180 | * | |
181 | * PARAMETERS: | |
182 | * | |
183 | * link - pointer to the dev_link_t structure representing the device to | |
184 | * detach | |
185 | * | |
186 | * RETURNS: | |
187 | * | |
188 | * N/A | |
189 | * | |
190 | ******************************************************************************/ | |
191 | static void wl_adapter_detach(struct pcmcia_device *link) | |
192 | { | |
6d98be39 | 193 | struct net_device *dev = link->priv; |
194a636d | 194 | /*--------------------------------------------------------------------*/ |
68c0bdff | 195 | |
6d98be39 PS |
196 | DBG_FUNC("wl_adapter_detach"); |
197 | DBG_ENTER(DbgInfo); | |
198 | DBG_PARAM(DbgInfo, "link", "0x%p", link); | |
68c0bdff | 199 | |
6d98be39 | 200 | wl_adapter_release(link); |
68c0bdff | 201 | |
6d98be39 PS |
202 | if (dev) { |
203 | unregister_wlags_sysfs(dev); | |
204 | unregister_netdev(dev); | |
205 | } | |
68c0bdff | 206 | |
6d98be39 | 207 | wl_device_dealloc(dev); |
68c0bdff | 208 | |
6d98be39 | 209 | DBG_LEAVE(DbgInfo); |
194a636d | 210 | } /* wl_adapter_detach */ |
68c0bdff HG |
211 | /*============================================================================*/ |
212 | ||
213 | ||
214 | /******************************************************************************* | |
215 | * wl_adapter_release() | |
216 | ******************************************************************************* | |
217 | * | |
218 | * DESCRIPTION: | |
219 | * | |
220 | * After a card is removed, this routine will release the PCMCIA | |
221 | * configuration. If the device is still open, this will be postponed until it | |
222 | * is closed. | |
223 | * | |
224 | * PARAMETERS: | |
225 | * | |
226 | * arg - a u_long representing a pointer to a dev_link_t structure for the | |
227 | * device to be released. | |
228 | * | |
229 | * RETURNS: | |
230 | * | |
231 | * N/A | |
232 | * | |
233 | ******************************************************************************/ | |
aa605fa4 | 234 | void wl_adapter_release(struct pcmcia_device *link) |
68c0bdff | 235 | { |
6d98be39 PS |
236 | DBG_FUNC("wl_adapter_release"); |
237 | DBG_ENTER(DbgInfo); | |
238 | DBG_PARAM(DbgInfo, "link", "0x%p", link); | |
68c0bdff | 239 | |
6d98be39 PS |
240 | /* Stop hardware */ |
241 | wl_remove(link->priv); | |
68c0bdff | 242 | |
6d98be39 | 243 | pcmcia_disable_device(link); |
68c0bdff | 244 | |
6d98be39 | 245 | DBG_LEAVE(DbgInfo); |
194a636d | 246 | } /* wl_adapter_release */ |
68c0bdff HG |
247 | /*============================================================================*/ |
248 | ||
249 | static int wl_adapter_suspend(struct pcmcia_device *link) | |
250 | { | |
6d98be39 | 251 | struct net_device *dev = link->priv; |
68c0bdff | 252 | |
194a636d | 253 | /* if (link->open) { */ |
68c0bdff HG |
254 | netif_device_detach(dev); |
255 | wl_suspend(dev); | |
194a636d PS |
256 | /* CHECK! pcmcia_release_configuration(link->handle); */ |
257 | /* } */ | |
68c0bdff | 258 | |
6d98be39 | 259 | return 0; |
194a636d | 260 | } /* wl_adapter_suspend */ |
68c0bdff HG |
261 | |
262 | static int wl_adapter_resume(struct pcmcia_device *link) | |
263 | { | |
264 | struct net_device *dev = link->priv; | |
265 | ||
266 | wl_resume(dev); | |
267 | ||
aa605fa4 | 268 | netif_device_attach(dev); |
68c0bdff HG |
269 | |
270 | return 0; | |
194a636d | 271 | } /* wl_adapter_resume */ |
68c0bdff HG |
272 | |
273 | /******************************************************************************* | |
274 | * wl_adapter_insert() | |
275 | ******************************************************************************* | |
276 | * | |
277 | * DESCRIPTION: | |
278 | * | |
279 | * wl_adapter_insert() is scheduled to run after a CARD_INSERTION event is | |
280 | * received, to configure the PCMCIA socket, and to make the ethernet device | |
281 | * available to the system. | |
282 | * | |
283 | * PARAMETERS: | |
284 | * | |
285 | * link - pointer to the dev_link_t structure representing the device to | |
286 | * insert | |
287 | * | |
288 | * RETURNS: | |
289 | * | |
290 | * N/A | |
291 | * | |
292 | ******************************************************************************/ | |
aa605fa4 | 293 | void wl_adapter_insert(struct pcmcia_device *link) |
68c0bdff | 294 | { |
6d98be39 PS |
295 | struct net_device *dev; |
296 | int i; | |
297 | int ret; | |
194a636d | 298 | /*--------------------------------------------------------------------*/ |
68c0bdff | 299 | |
6d98be39 PS |
300 | DBG_FUNC("wl_adapter_insert"); |
301 | DBG_ENTER(DbgInfo); | |
302 | DBG_PARAM(DbgInfo, "link", "0x%p", link); | |
68c0bdff | 303 | |
6d98be39 | 304 | dev = link->priv; |
68c0bdff | 305 | |
6d98be39 PS |
306 | /* Do we need to allocate an interrupt? */ |
307 | link->conf.Attributes |= CONF_ENABLE_IRQ; | |
68c0bdff | 308 | |
6d98be39 PS |
309 | ret = pcmcia_request_io(link, &link->io); |
310 | if (ret != 0) | |
311 | goto failed; | |
93822ad1 | 312 | |
6d98be39 PS |
313 | ret = pcmcia_request_irq(link, (void *) wl_isr); |
314 | if (ret != 0) | |
315 | goto failed; | |
68c0bdff | 316 | |
6d98be39 PS |
317 | ret = pcmcia_request_configuration(link, &link->conf); |
318 | if (ret != 0) | |
319 | goto failed; | |
68c0bdff | 320 | |
6d98be39 PS |
321 | dev->irq = link->irq; |
322 | dev->base_addr = link->io.BasePort1; | |
68c0bdff | 323 | |
6d98be39 PS |
324 | SET_NETDEV_DEV(dev, &link->dev); |
325 | if (register_netdev(dev) != 0) { | |
326 | printk("%s: register_netdev() failed\n", MODULE_NAME); | |
327 | goto failed; | |
328 | } | |
93822ad1 | 329 | |
6d98be39 | 330 | register_wlags_sysfs(dev); |
68c0bdff | 331 | |
6d98be39 PS |
332 | printk(KERN_INFO "%s: Wireless, io_addr %#03lx, irq %d, ""mac_address ", |
333 | dev->name, dev->base_addr, dev->irq); | |
194a636d | 334 | for (i = 0; i < ETH_ALEN; i++) |
6d98be39 | 335 | printk("%02X%c", dev->dev_addr[i], ((i < (ETH_ALEN-1)) ? ':' : '\n')); |
68c0bdff | 336 | |
6d98be39 PS |
337 | DBG_LEAVE(DbgInfo); |
338 | return; | |
68c0bdff | 339 | |
68c0bdff | 340 | failed: |
6d98be39 | 341 | wl_adapter_release(link); |
68c0bdff | 342 | |
6d98be39 PS |
343 | DBG_LEAVE(DbgInfo); |
344 | return; | |
194a636d | 345 | } /* wl_adapter_insert */ |
68c0bdff HG |
346 | /*============================================================================*/ |
347 | ||
348 | ||
349 | /******************************************************************************* | |
350 | * wl_adapter_open() | |
351 | ******************************************************************************* | |
352 | * | |
353 | * DESCRIPTION: | |
354 | * | |
355 | * Open the device. | |
356 | * | |
357 | * PARAMETERS: | |
358 | * | |
359 | * dev - a pointer to a net_device structure representing the network | |
360 | * device to open. | |
361 | * | |
362 | * RETURNS: | |
363 | * | |
364 | * 0 on success | |
365 | * errno value otherwise | |
366 | * | |
367 | ******************************************************************************/ | |
aa605fa4 | 368 | int wl_adapter_open(struct net_device *dev) |
68c0bdff | 369 | { |
6d98be39 PS |
370 | struct wl_private *lp = wl_priv(dev); |
371 | struct pcmcia_device *link = lp->link; | |
372 | int result = 0; | |
373 | int hcf_status = HCF_SUCCESS; | |
194a636d | 374 | /*--------------------------------------------------------------------*/ |
68c0bdff | 375 | |
6d98be39 PS |
376 | DBG_FUNC("wl_adapter_open"); |
377 | DBG_ENTER(DbgInfo); | |
aa605fa4 | 378 | DBG_PRINT("%s\n", VERSION_INFO); |
6d98be39 | 379 | DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev); |
68c0bdff | 380 | |
194a636d | 381 | if (!pcmcia_dev_present(link)) { |
6d98be39 PS |
382 | DBG_LEAVE(DbgInfo); |
383 | return -ENODEV; | |
384 | } | |
68c0bdff | 385 | |
6d98be39 | 386 | link->open++; |
68c0bdff | 387 | |
6d98be39 | 388 | hcf_status = wl_open(dev); |
68c0bdff | 389 | |
6d98be39 PS |
390 | if (hcf_status != HCF_SUCCESS) { |
391 | link->open--; | |
392 | result = -ENODEV; | |
393 | } | |
68c0bdff | 394 | |
6d98be39 PS |
395 | DBG_LEAVE(DbgInfo); |
396 | return result; | |
194a636d | 397 | } /* wl_adapter_open */ |
68c0bdff HG |
398 | /*============================================================================*/ |
399 | ||
400 | ||
401 | /******************************************************************************* | |
402 | * wl_adapter_close() | |
403 | ******************************************************************************* | |
404 | * | |
405 | * DESCRIPTION: | |
406 | * | |
407 | * Close the device. | |
408 | * | |
409 | * PARAMETERS: | |
410 | * | |
411 | * dev - a pointer to a net_device structure representing the network | |
412 | * device to close. | |
413 | * | |
414 | * RETURNS: | |
415 | * | |
416 | * 0 on success | |
417 | * errno value otherwise | |
418 | * | |
419 | ******************************************************************************/ | |
aa605fa4 | 420 | int wl_adapter_close(struct net_device *dev) |
68c0bdff | 421 | { |
6d98be39 PS |
422 | struct wl_private *lp = wl_priv(dev); |
423 | struct pcmcia_device *link = lp->link; | |
194a636d | 424 | /*--------------------------------------------------------------------*/ |
68c0bdff | 425 | |
6d98be39 PS |
426 | DBG_FUNC("wl_adapter_close"); |
427 | DBG_ENTER(DbgInfo); | |
428 | DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev); | |
68c0bdff | 429 | |
6d98be39 PS |
430 | if (link == NULL) { |
431 | DBG_LEAVE(DbgInfo); | |
432 | return -ENODEV; | |
433 | } | |
68c0bdff | 434 | |
6d98be39 PS |
435 | DBG_TRACE(DbgInfo, "%s: Shutting down adapter.\n", dev->name); |
436 | wl_close(dev); | |
68c0bdff | 437 | |
6d98be39 | 438 | link->open--; |
68c0bdff | 439 | |
6d98be39 PS |
440 | DBG_LEAVE(DbgInfo); |
441 | return 0; | |
194a636d | 442 | } /* wl_adapter_close */ |
68c0bdff HG |
443 | /*============================================================================*/ |
444 | ||
445 | static struct pcmcia_device_id wl_adapter_ids[] = { | |
194a636d | 446 | #if !((HCF_TYPE) & HCF_TYPE_HII5) |
68c0bdff HG |
447 | PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0003), |
448 | PCMCIA_DEVICE_PROD_ID12("Agere Systems", "Wireless PC Card Model 0110", | |
6d98be39 | 449 | 0x33103a9b, 0xe175b0dd), |
68c0bdff HG |
450 | #else |
451 | PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0004), | |
452 | PCMCIA_DEVICE_PROD_ID12("Linksys", "WCF54G_Wireless-G_CompactFlash_Card", | |
6d98be39 | 453 | 0x0733cc81, 0x98a599e1), |
194a636d | 454 | #endif /* (HCF_TYPE) & HCF_TYPE_HII5 */ |
68c0bdff | 455 | PCMCIA_DEVICE_NULL, |
6d98be39 | 456 | }; |
68c0bdff HG |
457 | MODULE_DEVICE_TABLE(pcmcia, wl_adapter_ids); |
458 | ||
459 | static struct pcmcia_driver wlags49_driver = { | |
6d98be39 PS |
460 | .owner = THIS_MODULE, |
461 | .drv = { | |
462 | .name = DRIVER_NAME, | |
463 | }, | |
464 | .probe = wl_adapter_attach, | |
465 | .remove = wl_adapter_detach, | |
466 | .id_table = wl_adapter_ids, | |
467 | .suspend = wl_adapter_suspend, | |
468 | .resume = wl_adapter_resume, | |
68c0bdff HG |
469 | }; |
470 | ||
471 | ||
472 | ||
473 | /******************************************************************************* | |
474 | * wl_adapter_init_module() | |
475 | ******************************************************************************* | |
476 | * | |
477 | * DESCRIPTION: | |
478 | * | |
479 | * Called by init_module() to perform PCMCIA driver initialization. | |
480 | * | |
481 | * PARAMETERS: | |
482 | * | |
483 | * N/A | |
484 | * | |
485 | * RETURNS: | |
486 | * | |
487 | * 0 on success | |
488 | * -1 on error | |
489 | * | |
490 | ******************************************************************************/ | |
aa605fa4 | 491 | int wl_adapter_init_module(void) |
68c0bdff | 492 | { |
6d98be39 | 493 | int ret; |
194a636d | 494 | /*--------------------------------------------------------------------*/ |
68c0bdff | 495 | |
6d98be39 PS |
496 | DBG_FUNC("wl_adapter_init_module"); |
497 | DBG_ENTER(DbgInfo); | |
498 | DBG_TRACE(DbgInfo, "wl_adapter_init_module() -- PCMCIA\n"); | |
68c0bdff | 499 | |
6d98be39 | 500 | ret = pcmcia_register_driver(&wlags49_driver); |
68c0bdff | 501 | |
6d98be39 PS |
502 | DBG_LEAVE(DbgInfo); |
503 | return ret; | |
194a636d | 504 | } /* wl_adapter_init_module */ |
68c0bdff HG |
505 | /*============================================================================*/ |
506 | ||
507 | ||
508 | /******************************************************************************* | |
509 | * wl_adapter_cleanup_module() | |
510 | ******************************************************************************* | |
511 | * | |
512 | * DESCRIPTION: | |
513 | * | |
514 | * Called by cleanup_module() to perform driver uninitialization. | |
515 | * | |
516 | * PARAMETERS: | |
517 | * | |
518 | * N/A | |
519 | * | |
520 | * RETURNS: | |
521 | * | |
522 | * N/A | |
523 | * | |
524 | ******************************************************************************/ | |
aa605fa4 | 525 | void wl_adapter_cleanup_module(void) |
68c0bdff | 526 | { |
6d98be39 PS |
527 | DBG_FUNC("wl_adapter_cleanup_module"); |
528 | DBG_ENTER(DbgInfo); | |
529 | DBG_TRACE(DbgInfo, "wl_adapter_cleanup_module() -- PCMCIA\n"); | |
68c0bdff HG |
530 | |
531 | ||
6d98be39 | 532 | pcmcia_unregister_driver(&wlags49_driver); |
68c0bdff | 533 | |
6d98be39 PS |
534 | DBG_LEAVE(DbgInfo); |
535 | return; | |
194a636d | 536 | } /* wl_adapter_cleanup_module */ |
68c0bdff HG |
537 | /*============================================================================*/ |
538 | ||
539 | ||
540 | /******************************************************************************* | |
541 | * wl_adapter_is_open() | |
542 | ******************************************************************************* | |
543 | * | |
544 | * DESCRIPTION: | |
545 | * | |
546 | * Check with Card Services to determine if this device is open. | |
547 | * | |
548 | * PARAMETERS: | |
549 | * | |
550 | * dev - a pointer to the net_device structure whose open status will be | |
551 | * checked | |
552 | * | |
553 | * RETURNS: | |
554 | * | |
555 | * nonzero if device is open | |
556 | * 0 otherwise | |
557 | * | |
558 | ******************************************************************************/ | |
aa605fa4 | 559 | int wl_adapter_is_open(struct net_device *dev) |
68c0bdff | 560 | { |
6d98be39 PS |
561 | struct wl_private *lp = wl_priv(dev); |
562 | struct pcmcia_device *link = lp->link; | |
68c0bdff | 563 | |
194a636d | 564 | if (!pcmcia_dev_present(link)) |
6d98be39 | 565 | return 0; |
68c0bdff | 566 | |
194a636d PS |
567 | return link->open; |
568 | } /* wl_adapter_is_open */ | |
68c0bdff HG |
569 | /*============================================================================*/ |
570 | ||
571 | ||
572 | #if DBG | |
573 | ||
574 | /******************************************************************************* | |
575 | * DbgEvent() | |
576 | ******************************************************************************* | |
577 | * | |
578 | * DESCRIPTION: | |
579 | * | |
580 | * Converts the card serivces events to text for debugging. | |
581 | * | |
582 | * PARAMETERS: | |
583 | * | |
584 | * mask - a integer representing the error(s) being reported by Card | |
585 | * Services. | |
586 | * | |
587 | * RETURNS: | |
588 | * | |
589 | * a pointer to a string describing the error(s) | |
590 | * | |
591 | ******************************************************************************/ | |
194a636d | 592 | const char *DbgEvent(int mask) |
68c0bdff | 593 | { |
6d98be39 PS |
594 | static char DbgBuffer[256]; |
595 | char *pBuf; | |
194a636d | 596 | /*--------------------------------------------------------------------*/ |
68c0bdff | 597 | |
6d98be39 PS |
598 | pBuf = DbgBuffer; |
599 | *pBuf = '\0'; | |
68c0bdff HG |
600 | |
601 | ||
6d98be39 PS |
602 | if (mask & CS_EVENT_WRITE_PROTECT) |
603 | strcat(pBuf, "WRITE_PROTECT "); | |
68c0bdff | 604 | |
6d98be39 PS |
605 | if (mask & CS_EVENT_CARD_LOCK) |
606 | strcat(pBuf, "CARD_LOCK "); | |
68c0bdff | 607 | |
6d98be39 PS |
608 | if (mask & CS_EVENT_CARD_INSERTION) |
609 | strcat(pBuf, "CARD_INSERTION "); | |
68c0bdff | 610 | |
6d98be39 PS |
611 | if (mask & CS_EVENT_CARD_REMOVAL) |
612 | strcat(pBuf, "CARD_REMOVAL "); | |
68c0bdff | 613 | |
6d98be39 PS |
614 | if (mask & CS_EVENT_BATTERY_DEAD) |
615 | strcat(pBuf, "BATTERY_DEAD "); | |
68c0bdff | 616 | |
6d98be39 PS |
617 | if (mask & CS_EVENT_BATTERY_LOW) |
618 | strcat(pBuf, "BATTERY_LOW "); | |
68c0bdff | 619 | |
6d98be39 PS |
620 | if (mask & CS_EVENT_READY_CHANGE) |
621 | strcat(pBuf, "READY_CHANGE "); | |
68c0bdff | 622 | |
6d98be39 PS |
623 | if (mask & CS_EVENT_CARD_DETECT) |
624 | strcat(pBuf, "CARD_DETECT "); | |
68c0bdff | 625 | |
6d98be39 PS |
626 | if (mask & CS_EVENT_RESET_REQUEST) |
627 | strcat(pBuf, "RESET_REQUEST "); | |
68c0bdff | 628 | |
6d98be39 PS |
629 | if (mask & CS_EVENT_RESET_PHYSICAL) |
630 | strcat(pBuf, "RESET_PHYSICAL "); | |
68c0bdff | 631 | |
6d98be39 PS |
632 | if (mask & CS_EVENT_CARD_RESET) |
633 | strcat(pBuf, "CARD_RESET "); | |
68c0bdff | 634 | |
6d98be39 PS |
635 | if (mask & CS_EVENT_REGISTRATION_COMPLETE) |
636 | strcat(pBuf, "REGISTRATION_COMPLETE "); | |
68c0bdff | 637 | |
194a636d PS |
638 | /* if (mask & CS_EVENT_RESET_COMPLETE) |
639 | strcat(pBuf, "RESET_COMPLETE "); */ | |
68c0bdff | 640 | |
6d98be39 PS |
641 | if (mask & CS_EVENT_PM_SUSPEND) |
642 | strcat(pBuf, "PM_SUSPEND "); | |
68c0bdff | 643 | |
6d98be39 PS |
644 | if (mask & CS_EVENT_PM_RESUME) |
645 | strcat(pBuf, "PM_RESUME "); | |
68c0bdff | 646 | |
6d98be39 PS |
647 | if (mask & CS_EVENT_INSERTION_REQUEST) |
648 | strcat(pBuf, "INSERTION_REQUEST "); | |
68c0bdff | 649 | |
6d98be39 PS |
650 | if (mask & CS_EVENT_EJECTION_REQUEST) |
651 | strcat(pBuf, "EJECTION_REQUEST "); | |
68c0bdff | 652 | |
6d98be39 PS |
653 | if (mask & CS_EVENT_MTD_REQUEST) |
654 | strcat(pBuf, "MTD_REQUEST "); | |
68c0bdff | 655 | |
6d98be39 PS |
656 | if (mask & CS_EVENT_ERASE_COMPLETE) |
657 | strcat(pBuf, "ERASE_COMPLETE "); | |
68c0bdff | 658 | |
6d98be39 PS |
659 | if (mask & CS_EVENT_REQUEST_ATTENTION) |
660 | strcat(pBuf, "REQUEST_ATTENTION "); | |
68c0bdff | 661 | |
6d98be39 PS |
662 | if (mask & CS_EVENT_CB_DETECT) |
663 | strcat(pBuf, "CB_DETECT "); | |
68c0bdff | 664 | |
6d98be39 PS |
665 | if (mask & CS_EVENT_3VCARD) |
666 | strcat(pBuf, "3VCARD "); | |
68c0bdff | 667 | |
6d98be39 PS |
668 | if (mask & CS_EVENT_XVCARD) |
669 | strcat(pBuf, "XVCARD "); | |
68c0bdff HG |
670 | |
671 | ||
6d98be39 PS |
672 | if (*pBuf) { |
673 | pBuf[strlen(pBuf) - 1] = '\0'; | |
674 | } else { | |
194a636d | 675 | if (mask != 0x0) |
6d98be39 | 676 | sprintf(pBuf, "<<0x%08x>>", mask); |
6d98be39 | 677 | } |
68c0bdff | 678 | |
6d98be39 | 679 | return pBuf; |
194a636d | 680 | } /* DbgEvent */ |
68c0bdff HG |
681 | /*============================================================================*/ |
682 | ||
683 | #endif /* DBG */ |