aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl3501_cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/wl3501_cs.c')
-rw-r--r--drivers/net/wireless/wl3501_cs.c61
1 files changed, 9 insertions, 52 deletions
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index 393b5cb7a52c..4b054f54e9d5 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -226,17 +226,6 @@ static void iw_copy_mgmt_info_element(struct iw_mgmt_info_element *to,
226 iw_set_mgmt_info_element(from->id, to, from->data, from->len); 226 iw_set_mgmt_info_element(from->id, to, from->data, from->len);
227} 227}
228 228
229/*
230 * A linked list of "instances" of the wl24 device. Each actual PCMCIA card
231 * corresponds to one device instance, and is described by one dev_link_t
232 * structure (defined in ds.h).
233 *
234 * You may not want to use a linked list for this -- for example, the memory
235 * card driver uses an array of dev_link_t pointers, where minor device numbers
236 * are used to derive the corresponding array index.
237 */
238static dev_link_t *wl3501_dev_list;
239
240static inline void wl3501_switch_page(struct wl3501_card *this, u8 page) 229static inline void wl3501_switch_page(struct wl3501_card *this, u8 page)
241{ 230{
242 wl3501_outb(page, this->base_addr + WL3501_NIC_BSS); 231 wl3501_outb(page, this->base_addr + WL3501_NIC_BSS);
@@ -1282,14 +1271,9 @@ static int wl3501_close(struct net_device *dev)
1282 int rc = -ENODEV; 1271 int rc = -ENODEV;
1283 unsigned long flags; 1272 unsigned long flags;
1284 dev_link_t *link; 1273 dev_link_t *link;
1274 link = this->p_dev;
1285 1275
1286 spin_lock_irqsave(&this->lock, flags); 1276 spin_lock_irqsave(&this->lock, flags);
1287 /* Check if the device is in wl3501_dev_list */
1288 for (link = wl3501_dev_list; link; link = link->next)
1289 if (link->priv == dev)
1290 break;
1291 if (!link)
1292 goto out;
1293 link->open--; 1277 link->open--;
1294 1278
1295 /* Stop wl3501_hard_start_xmit() from now on */ 1279 /* Stop wl3501_hard_start_xmit() from now on */
@@ -1301,7 +1285,6 @@ static int wl3501_close(struct net_device *dev)
1301 1285
1302 rc = 0; 1286 rc = 0;
1303 printk(KERN_INFO "%s: WL3501 closed\n", dev->name); 1287 printk(KERN_INFO "%s: WL3501 closed\n", dev->name);
1304out:
1305 spin_unlock_irqrestore(&this->lock, flags); 1288 spin_unlock_irqrestore(&this->lock, flags);
1306 return rc; 1289 return rc;
1307} 1290}
@@ -1401,12 +1384,9 @@ static int wl3501_open(struct net_device *dev)
1401 struct wl3501_card *this = dev->priv; 1384 struct wl3501_card *this = dev->priv;
1402 unsigned long flags; 1385 unsigned long flags;
1403 dev_link_t *link; 1386 dev_link_t *link;
1387 link = this->p_dev;
1404 1388
1405 spin_lock_irqsave(&this->lock, flags); 1389 spin_lock_irqsave(&this->lock, flags);
1406 /* Check if the device is in wl3501_dev_list */
1407 for (link = wl3501_dev_list; link; link = link->next)
1408 if (link->priv == dev)
1409 break;
1410 if (!DEV_OK(link)) 1390 if (!DEV_OK(link))
1411 goto out; 1391 goto out;
1412 netif_device_attach(dev); 1392 netif_device_attach(dev);
@@ -1500,16 +1480,8 @@ static struct ethtool_ops ops = {
1500static void wl3501_detach(struct pcmcia_device *p_dev) 1480static void wl3501_detach(struct pcmcia_device *p_dev)
1501{ 1481{
1502 dev_link_t *link = dev_to_instance(p_dev); 1482 dev_link_t *link = dev_to_instance(p_dev);
1503 dev_link_t **linkp;
1504 struct net_device *dev = link->priv; 1483 struct net_device *dev = link->priv;
1505 1484
1506 /* Locate device structure */
1507 for (linkp = &wl3501_dev_list; *linkp; linkp = &(*linkp)->next)
1508 if (*linkp == link)
1509 break;
1510 if (!*linkp)
1511 goto out;
1512
1513 /* If the device is currently configured and active, we won't actually 1485 /* If the device is currently configured and active, we won't actually
1514 * delete it yet. Instead, it is marked so that when the release() 1486 * delete it yet. Instead, it is marked so that when the release()
1515 * function is called, that will trigger a proper detach(). */ 1487 * function is called, that will trigger a proper detach(). */
@@ -1522,13 +1494,9 @@ static void wl3501_detach(struct pcmcia_device *p_dev)
1522 wl3501_release(link); 1494 wl3501_release(link);
1523 } 1495 }
1524 1496
1525 /* Unlink device structure, free pieces */
1526 *linkp = link->next;
1527
1528 if (link->priv) 1497 if (link->priv)
1529 free_netdev(link->priv); 1498 free_netdev(link->priv);
1530 kfree(link); 1499
1531out:
1532 return; 1500 return;
1533} 1501}
1534 1502
@@ -1955,14 +1923,9 @@ static const struct iw_handler_def wl3501_handler_def = {
1955 */ 1923 */
1956static int wl3501_attach(struct pcmcia_device *p_dev) 1924static int wl3501_attach(struct pcmcia_device *p_dev)
1957{ 1925{
1958 dev_link_t *link;
1959 struct net_device *dev; 1926 struct net_device *dev;
1960 struct wl3501_card *this; 1927 struct wl3501_card *this;
1961 1928 dev_link_t *link = dev_to_instance(p_dev);
1962 /* Initialize the dev_link_t structure */
1963 link = kzalloc(sizeof(*link), GFP_KERNEL);
1964 if (!link)
1965 return -ENOMEM;
1966 1929
1967 /* The io structure describes IO port mapping */ 1930 /* The io structure describes IO port mapping */
1968 link->io.NumPorts1 = 16; 1931 link->io.NumPorts1 = 16;
@@ -1991,22 +1954,18 @@ static int wl3501_attach(struct pcmcia_device *p_dev)
1991 dev->get_stats = wl3501_get_stats; 1954 dev->get_stats = wl3501_get_stats;
1992 this = dev->priv; 1955 this = dev->priv;
1993 this->wireless_data.spy_data = &this->spy_data; 1956 this->wireless_data.spy_data = &this->spy_data;
1957 this->p_dev = p_dev;
1994 dev->wireless_data = &this->wireless_data; 1958 dev->wireless_data = &this->wireless_data;
1995 dev->wireless_handlers = (struct iw_handler_def *)&wl3501_handler_def; 1959 dev->wireless_handlers = (struct iw_handler_def *)&wl3501_handler_def;
1996 SET_ETHTOOL_OPS(dev, &ops); 1960 SET_ETHTOOL_OPS(dev, &ops);
1997 netif_stop_queue(dev); 1961 netif_stop_queue(dev);
1998 link->priv = link->irq.Instance = dev; 1962 link->priv = link->irq.Instance = dev;
1999 1963
2000 link->handle = p_dev;
2001 p_dev->instance = link;
2002
2003 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 1964 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
2004 wl3501_config(link); 1965 wl3501_config(p_dev);
2005 1966
2006 return 0; 1967 return 0;
2007out_link: 1968out_link:
2008 kfree(link);
2009 link = NULL;
2010 return -ENOMEM; 1969 return -ENOMEM;
2011} 1970}
2012 1971
@@ -2087,9 +2046,9 @@ static void wl3501_config(dev_link_t *link)
2087 this = dev->priv; 2046 this = dev->priv;
2088 /* 2047 /*
2089 * At this point, the dev_node_t structure(s) should be initialized and 2048 * At this point, the dev_node_t structure(s) should be initialized and
2090 * arranged in a linked list at link->dev. 2049 * arranged in a linked list at link->dev_node.
2091 */ 2050 */
2092 link->dev = &this->node; 2051 link->dev_node = &this->node;
2093 link->state &= ~DEV_CONFIG_PENDING; 2052 link->state &= ~DEV_CONFIG_PENDING;
2094 2053
2095 this->base_addr = dev->base_addr; 2054 this->base_addr = dev->base_addr;
@@ -2148,7 +2107,7 @@ static void wl3501_release(dev_link_t *link)
2148 struct net_device *dev = link->priv; 2107 struct net_device *dev = link->priv;
2149 2108
2150 /* Unlink the device chain */ 2109 /* Unlink the device chain */
2151 if (link->dev) 2110 if (link->dev_node)
2152 unregister_netdev(dev); 2111 unregister_netdev(dev);
2153 2112
2154 pcmcia_disable_device(link->handle); 2113 pcmcia_disable_device(link->handle);
@@ -2206,9 +2165,7 @@ static int __init wl3501_init_module(void)
2206 2165
2207static void __exit wl3501_exit_module(void) 2166static void __exit wl3501_exit_module(void)
2208{ 2167{
2209 dprintk(0, ": unloading");
2210 pcmcia_unregister_driver(&wl3501_driver); 2168 pcmcia_unregister_driver(&wl3501_driver);
2211 BUG_ON(wl3501_dev_list != NULL);
2212} 2169}
2213 2170
2214module_init(wl3501_init_module); 2171module_init(wl3501_init_module);