blob: b55dc43a1d11ff40b197c7f8f2dc9fa6db4d334a [file] [log] [blame]
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001/*******************************************************************************
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 *
Prashant P. Shah8cd57782010-06-23 12:16:41 +053026 * Copyright (c) 2003 Agere Systems Inc.
Henk de Groot68c0bdf2009-09-27 11:12:52 +020027 * 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 *
Prashant P. Shah8cd57782010-06-23 12:16:41 +053047 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
Henk de Groot68c0bdf2009-09-27 11:12:52 +020048 * 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
Henk de Groot68c0bdf2009-09-27 11:12:52 +020062/*******************************************************************************
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>
Henk de Groot68c0bdf2009-09-27 11:12:52 +020070#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>
Henk de Groot68c0bdf2009-09-27 11:12:52 +020077#include <asm/bitops.h>
78
79#include <linux/netdevice.h>
80#include <linux/etherdevice.h>
81#include <linux/skbuff.h>
82#include <linux/if_arp.h>
83#include <linux/ioport.h>
Paul Gortmaker45296232011-08-30 17:50:46 -040084#include <linux/module.h>
Henk de Groot68c0bdf2009-09-27 11:12:52 +020085
Henk de Groot68c0bdf2009-09-27 11:12:52 +020086#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
105/*******************************************************************************
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200106 * global definitions
107 ******************************************************************************/
108#if DBG
109extern 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 ******************************************************************************/
132static int wl_adapter_attach(struct pcmcia_device *link)
133{
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530134 struct net_device *dev;
135 struct wl_private *lp;
Alexey Khoroshilov657d4c82013-04-23 19:27:39 -0400136 int ret;
Prashant P. Shah194a6362010-06-23 12:17:02 +0530137 /*--------------------------------------------------------------------*/
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200138
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530139 DBG_FUNC("wl_adapter_attach");
140 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200141
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530142 dev = wl_device_alloc();
143 if (dev == NULL) {
144 DBG_ERROR(DbgInfo, "wl_device_alloc returned NULL\n");
145 return -ENOMEM;
146 }
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200147
Linus Torvalds1685e632010-08-06 12:25:06 -0700148 link->resource[0]->end = HCF_NUM_IO_PORTS;
149 link->resource[0]->flags= IO_DATA_PATH_WIDTH_16;
Dominik Brodowski1ac71e52010-07-29 19:27:09 +0200150 link->config_flags |= CONF_ENABLE_IRQ;
Dominik Brodowski7feabb62010-07-29 18:35:47 +0200151 link->config_index = 5;
152 link->config_regs = PRESENT_OPTION;
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200153
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530154 link->priv = dev;
155 lp = wl_priv(dev);
156 lp->link = link;
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200157
Alexey Khoroshilov657d4c82013-04-23 19:27:39 -0400158 ret = wl_adapter_insert(link);
159 if (ret != 0)
160 wl_device_dealloc(dev);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200161
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530162 DBG_LEAVE(DbgInfo);
Alexey Khoroshilov657d4c82013-04-23 19:27:39 -0400163 return ret;
Prashant P. Shah194a6362010-06-23 12:17:02 +0530164} /* wl_adapter_attach */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200165/*============================================================================*/
166
167
168
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200169static void wl_adapter_detach(struct pcmcia_device *link)
170{
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530171 struct net_device *dev = link->priv;
Prashant P. Shah194a6362010-06-23 12:17:02 +0530172 /*--------------------------------------------------------------------*/
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200173
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530174 DBG_FUNC("wl_adapter_detach");
175 DBG_ENTER(DbgInfo);
176 DBG_PARAM(DbgInfo, "link", "0x%p", link);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200177
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530178 wl_adapter_release(link);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200179
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530180 if (dev) {
181 unregister_wlags_sysfs(dev);
182 unregister_netdev(dev);
Dan Carpenterbed861b2012-05-14 23:56:46 +0300183 wl_device_dealloc(dev);
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530184 }
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200185
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530186 DBG_LEAVE(DbgInfo);
Prashant P. Shah194a6362010-06-23 12:17:02 +0530187} /* wl_adapter_detach */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200188/*============================================================================*/
189
190
Prashant P. Shahaa605fa2010-06-10 22:07:04 +0530191void wl_adapter_release(struct pcmcia_device *link)
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200192{
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530193 DBG_FUNC("wl_adapter_release");
194 DBG_ENTER(DbgInfo);
195 DBG_PARAM(DbgInfo, "link", "0x%p", link);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200196
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530197 /* Stop hardware */
198 wl_remove(link->priv);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200199
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530200 pcmcia_disable_device(link);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200201
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530202 DBG_LEAVE(DbgInfo);
Prashant P. Shah194a6362010-06-23 12:17:02 +0530203} /* wl_adapter_release */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200204/*============================================================================*/
205
206static int wl_adapter_suspend(struct pcmcia_device *link)
207{
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530208 struct net_device *dev = link->priv;
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200209
Prashant P. Shah194a6362010-06-23 12:17:02 +0530210 /* if (link->open) { */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200211 netif_device_detach(dev);
212 wl_suspend(dev);
Prashant P. Shah194a6362010-06-23 12:17:02 +0530213 /* CHECK! pcmcia_release_configuration(link->handle); */
214 /* } */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200215
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530216 return 0;
Prashant P. Shah194a6362010-06-23 12:17:02 +0530217} /* wl_adapter_suspend */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200218
219static int wl_adapter_resume(struct pcmcia_device *link)
220{
221 struct net_device *dev = link->priv;
222
223 wl_resume(dev);
224
Prashant P. Shahaa605fa2010-06-10 22:07:04 +0530225 netif_device_attach(dev);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200226
227 return 0;
Prashant P. Shah194a6362010-06-23 12:17:02 +0530228} /* wl_adapter_resume */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200229
Alexey Khoroshilov657d4c82013-04-23 19:27:39 -0400230int wl_adapter_insert(struct pcmcia_device *link)
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200231{
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530232 struct net_device *dev;
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530233 int ret;
Prashant P. Shah194a6362010-06-23 12:17:02 +0530234 /*--------------------------------------------------------------------*/
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200235
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530236 DBG_FUNC("wl_adapter_insert");
237 DBG_ENTER(DbgInfo);
238 DBG_PARAM(DbgInfo, "link", "0x%p", link);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200239
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530240 dev = link->priv;
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200241
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530242 /* Do we need to allocate an interrupt? */
Dominik Brodowski1ac71e52010-07-29 19:27:09 +0200243 link->config_flags |= CONF_ENABLE_IRQ;
Linus Torvalds1685e632010-08-06 12:25:06 -0700244 link->io_lines = 6;
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200245
Linus Torvalds1685e632010-08-06 12:25:06 -0700246 ret = pcmcia_request_io(link);
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530247 if (ret != 0)
248 goto failed;
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200249
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530250 ret = pcmcia_request_irq(link, (void *) wl_isr);
251 if (ret != 0)
252 goto failed;
Henk de Groot93822ad2010-05-13 16:27:33 +0200253
Dominik Brodowski1ac71e52010-07-29 19:27:09 +0200254 ret = pcmcia_enable_device(link);
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530255 if (ret != 0)
256 goto failed;
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200257
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530258 dev->irq = link->irq;
Linus Torvalds1685e632010-08-06 12:25:06 -0700259 dev->base_addr = link->resource[0]->start;
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200260
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530261 SET_NETDEV_DEV(dev, &link->dev);
Wei Yongjun49c144c2013-05-17 16:43:15 +0800262 ret = register_netdev(dev);
263 if (ret != 0) {
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530264 printk("%s: register_netdev() failed\n", MODULE_NAME);
265 goto failed;
266 }
Henk de Groot93822ad2010-05-13 16:27:33 +0200267
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530268 register_wlags_sysfs(dev);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200269
Danny Kukawka5d74f172012-02-24 14:46:02 +0100270 printk(KERN_INFO "%s: Wireless, io_addr %#03lx, irq %d, mac_address"
271 " %pM\n", dev->name, dev->base_addr, dev->irq, dev->dev_addr);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200272
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530273 DBG_LEAVE(DbgInfo);
Alexey Khoroshilov657d4c82013-04-23 19:27:39 -0400274 return 0;
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200275
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200276failed:
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530277 wl_adapter_release(link);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200278
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530279 DBG_LEAVE(DbgInfo);
Alexey Khoroshilov657d4c82013-04-23 19:27:39 -0400280 return ret;
Prashant P. Shah194a6362010-06-23 12:17:02 +0530281} /* wl_adapter_insert */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200282/*============================================================================*/
283
284
285/*******************************************************************************
286 * wl_adapter_open()
287 *******************************************************************************
288 *
289 * DESCRIPTION:
290 *
291 * Open the device.
292 *
293 * PARAMETERS:
294 *
295 * dev - a pointer to a net_device structure representing the network
296 * device to open.
297 *
298 * RETURNS:
299 *
300 * 0 on success
301 * errno value otherwise
302 *
303 ******************************************************************************/
Prashant P. Shahaa605fa2010-06-10 22:07:04 +0530304int wl_adapter_open(struct net_device *dev)
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200305{
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530306 struct wl_private *lp = wl_priv(dev);
307 struct pcmcia_device *link = lp->link;
308 int result = 0;
309 int hcf_status = HCF_SUCCESS;
Prashant P. Shah194a6362010-06-23 12:17:02 +0530310 /*--------------------------------------------------------------------*/
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200311
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530312 DBG_FUNC("wl_adapter_open");
313 DBG_ENTER(DbgInfo);
Prashant P. Shahaa605fa2010-06-10 22:07:04 +0530314 DBG_PRINT("%s\n", VERSION_INFO);
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530315 DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200316
Prashant P. Shah194a6362010-06-23 12:17:02 +0530317 if (!pcmcia_dev_present(link)) {
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530318 DBG_LEAVE(DbgInfo);
319 return -ENODEV;
320 }
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200321
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530322 link->open++;
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200323
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530324 hcf_status = wl_open(dev);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200325
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530326 if (hcf_status != HCF_SUCCESS) {
327 link->open--;
328 result = -ENODEV;
329 }
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200330
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530331 DBG_LEAVE(DbgInfo);
332 return result;
Prashant P. Shah194a6362010-06-23 12:17:02 +0530333} /* wl_adapter_open */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200334/*============================================================================*/
335
336
337/*******************************************************************************
338 * wl_adapter_close()
339 *******************************************************************************
340 *
341 * DESCRIPTION:
342 *
343 * Close the device.
344 *
345 * PARAMETERS:
346 *
347 * dev - a pointer to a net_device structure representing the network
348 * device to close.
349 *
350 * RETURNS:
351 *
352 * 0 on success
353 * errno value otherwise
354 *
355 ******************************************************************************/
Prashant P. Shahaa605fa2010-06-10 22:07:04 +0530356int wl_adapter_close(struct net_device *dev)
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200357{
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530358 struct wl_private *lp = wl_priv(dev);
359 struct pcmcia_device *link = lp->link;
Prashant P. Shah194a6362010-06-23 12:17:02 +0530360 /*--------------------------------------------------------------------*/
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200361
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530362 DBG_FUNC("wl_adapter_close");
363 DBG_ENTER(DbgInfo);
364 DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200365
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530366 if (link == NULL) {
367 DBG_LEAVE(DbgInfo);
368 return -ENODEV;
369 }
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200370
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530371 DBG_TRACE(DbgInfo, "%s: Shutting down adapter.\n", dev->name);
372 wl_close(dev);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200373
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530374 link->open--;
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200375
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530376 DBG_LEAVE(DbgInfo);
377 return 0;
Prashant P. Shah194a6362010-06-23 12:17:02 +0530378} /* wl_adapter_close */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200379/*============================================================================*/
380
Joe Perches2202a5a2011-05-03 19:29:02 -0700381static const struct pcmcia_device_id wl_adapter_ids[] = {
Prashant P. Shah194a6362010-06-23 12:17:02 +0530382#if !((HCF_TYPE) & HCF_TYPE_HII5)
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200383 PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0003),
384 PCMCIA_DEVICE_PROD_ID12("Agere Systems", "Wireless PC Card Model 0110",
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530385 0x33103a9b, 0xe175b0dd),
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200386#else
387 PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0004),
388 PCMCIA_DEVICE_PROD_ID12("Linksys", "WCF54G_Wireless-G_CompactFlash_Card",
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530389 0x0733cc81, 0x98a599e1),
Prashant P. Shah194a6362010-06-23 12:17:02 +0530390#endif /* (HCF_TYPE) & HCF_TYPE_HII5 */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200391 PCMCIA_DEVICE_NULL,
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530392};
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200393MODULE_DEVICE_TABLE(pcmcia, wl_adapter_ids);
394
395static struct pcmcia_driver wlags49_driver = {
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530396 .owner = THIS_MODULE,
Dominik Brodowski2e9b9812010-08-08 11:36:26 +0200397 .name = DRIVER_NAME,
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530398 .probe = wl_adapter_attach,
399 .remove = wl_adapter_detach,
400 .id_table = wl_adapter_ids,
401 .suspend = wl_adapter_suspend,
402 .resume = wl_adapter_resume,
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200403};
404
405
406
407/*******************************************************************************
408 * wl_adapter_init_module()
409 *******************************************************************************
410 *
411 * DESCRIPTION:
412 *
413 * Called by init_module() to perform PCMCIA driver initialization.
414 *
415 * PARAMETERS:
416 *
417 * N/A
418 *
419 * RETURNS:
420 *
421 * 0 on success
422 * -1 on error
423 *
424 ******************************************************************************/
Prashant P. Shahaa605fa2010-06-10 22:07:04 +0530425int wl_adapter_init_module(void)
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200426{
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530427 int ret;
Prashant P. Shah194a6362010-06-23 12:17:02 +0530428 /*--------------------------------------------------------------------*/
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200429
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530430 DBG_FUNC("wl_adapter_init_module");
431 DBG_ENTER(DbgInfo);
432 DBG_TRACE(DbgInfo, "wl_adapter_init_module() -- PCMCIA\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200433
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530434 ret = pcmcia_register_driver(&wlags49_driver);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200435
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530436 DBG_LEAVE(DbgInfo);
437 return ret;
Prashant P. Shah194a6362010-06-23 12:17:02 +0530438} /* wl_adapter_init_module */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200439/*============================================================================*/
440
441
442/*******************************************************************************
443 * wl_adapter_cleanup_module()
444 *******************************************************************************
445 *
446 * DESCRIPTION:
447 *
448 * Called by cleanup_module() to perform driver uninitialization.
449 *
450 * PARAMETERS:
451 *
452 * N/A
453 *
454 * RETURNS:
455 *
456 * N/A
457 *
458 ******************************************************************************/
Prashant P. Shahaa605fa2010-06-10 22:07:04 +0530459void wl_adapter_cleanup_module(void)
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200460{
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530461 DBG_FUNC("wl_adapter_cleanup_module");
462 DBG_ENTER(DbgInfo);
463 DBG_TRACE(DbgInfo, "wl_adapter_cleanup_module() -- PCMCIA\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200464
465
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530466 pcmcia_unregister_driver(&wlags49_driver);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200467
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530468 DBG_LEAVE(DbgInfo);
469 return;
Prashant P. Shah194a6362010-06-23 12:17:02 +0530470} /* wl_adapter_cleanup_module */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200471/*============================================================================*/
472
473
474/*******************************************************************************
475 * wl_adapter_is_open()
476 *******************************************************************************
477 *
478 * DESCRIPTION:
479 *
480 * Check with Card Services to determine if this device is open.
481 *
482 * PARAMETERS:
483 *
484 * dev - a pointer to the net_device structure whose open status will be
485 * checked
486 *
487 * RETURNS:
488 *
489 * nonzero if device is open
490 * 0 otherwise
491 *
492 ******************************************************************************/
Prashant P. Shahaa605fa2010-06-10 22:07:04 +0530493int wl_adapter_is_open(struct net_device *dev)
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200494{
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530495 struct wl_private *lp = wl_priv(dev);
496 struct pcmcia_device *link = lp->link;
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200497
Prashant P. Shah194a6362010-06-23 12:17:02 +0530498 if (!pcmcia_dev_present(link))
Prashant P. Shah6d98be32010-06-23 12:15:06 +0530499 return 0;
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200500
Prashant P. Shah194a6362010-06-23 12:17:02 +0530501 return link->open;
502} /* wl_adapter_is_open */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200503/*============================================================================*/