aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2006-03-05 04:45:09 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2006-03-31 10:15:57 -0500
commitfd238232cd0ff4840ae6946bb338502154096d88 (patch)
treed20e8f5871f7cff9d0867a84f6ba088fbffcbe28 /drivers/net/wireless
parenta78f4dd331a4f6a396eb5849656a4a72a70a56d7 (diff)
[PATCH] pcmcia: embed dev_link_t into struct pcmcia_device
Embed dev_link_t into struct pcmcia_device(), as they basically address the same entity. The actual contents of dev_link_t will be cleaned up step by step. This patch includes a bugfix from and signed-off-by Andrew Morton. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/airo_cs.c33
-rw-r--r--drivers/net/wireless/atmel_cs.c33
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c20
-rw-r--r--drivers/net/wireless/netwave_cs.c19
-rw-r--r--drivers/net/wireless/orinoco_cs.c22
-rw-r--r--drivers/net/wireless/ray_cs.c98
-rw-r--r--drivers/net/wireless/spectrum_cs.c21
-rw-r--r--drivers/net/wireless/wavelan_cs.c46
-rw-r--r--drivers/net/wireless/wl3501.h1
-rw-r--r--drivers/net/wireless/wl3501_cs.c61
10 files changed, 108 insertions, 246 deletions
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index 2216c04a02af..836c71ff7762 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -143,22 +143,14 @@ typedef struct local_info_t {
143 143
144static int airo_attach(struct pcmcia_device *p_dev) 144static int airo_attach(struct pcmcia_device *p_dev)
145{ 145{
146 dev_link_t *link;
147 local_info_t *local; 146 local_info_t *local;
148 147
149 DEBUG(0, "airo_attach()\n"); 148 DEBUG(0, "airo_attach()\n");
150 149
151 /* Initialize the dev_link_t structure */
152 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL);
153 if (!link) {
154 printk(KERN_ERR "airo_cs: no memory for new device\n");
155 return -ENOMEM;
156 }
157
158 /* Interrupt setup */ 150 /* Interrupt setup */
159 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 151 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
160 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 152 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
161 link->irq.Handler = NULL; 153 p_dev->irq.Handler = NULL;
162 154
163 /* 155 /*
164 General socket configuration defaults can go here. In this 156 General socket configuration defaults can go here. In this
@@ -167,23 +159,19 @@ static int airo_attach(struct pcmcia_device *p_dev)
167 and attributes of IO windows) are fixed by the nature of the 159 and attributes of IO windows) are fixed by the nature of the
168 device, and can be hard-wired here. 160 device, and can be hard-wired here.
169 */ 161 */
170 link->conf.Attributes = 0; 162 p_dev->conf.Attributes = 0;
171 link->conf.IntType = INT_MEMORY_AND_IO; 163 p_dev->conf.IntType = INT_MEMORY_AND_IO;
172 164
173 /* Allocate space for private device-specific data */ 165 /* Allocate space for private device-specific data */
174 local = kzalloc(sizeof(local_info_t), GFP_KERNEL); 166 local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
175 if (!local) { 167 if (!local) {
176 printk(KERN_ERR "airo_cs: no memory for new device\n"); 168 printk(KERN_ERR "airo_cs: no memory for new device\n");
177 kfree (link);
178 return -ENOMEM; 169 return -ENOMEM;
179 } 170 }
180 link->priv = local; 171 p_dev->priv = local;
181
182 link->handle = p_dev;
183 p_dev->instance = link;
184 172
185 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 173 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
186 airo_config(link); 174 airo_config(p_dev);
187 175
188 return 0; 176 return 0;
189} /* airo_attach */ 177} /* airo_attach */
@@ -212,7 +200,6 @@ static void airo_detach(struct pcmcia_device *p_dev)
212 ((local_info_t*)link->priv)->eth_dev = NULL; 200 ((local_info_t*)link->priv)->eth_dev = NULL;
213 201
214 kfree(link->priv); 202 kfree(link->priv);
215 kfree(link);
216} /* airo_detach */ 203} /* airo_detach */
217 204
218/*====================================================================== 205/*======================================================================
@@ -378,11 +365,11 @@ static void airo_config(dev_link_t *link)
378 365
379 /* 366 /*
380 At this point, the dev_node_t structure(s) need to be 367 At this point, the dev_node_t structure(s) need to be
381 initialized and arranged in a linked list at link->dev. 368 initialized and arranged in a linked list at link->dev_node.
382 */ 369 */
383 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name ); 370 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name );
384 dev->node.major = dev->node.minor = 0; 371 dev->node.major = dev->node.minor = 0;
385 link->dev = &dev->node; 372 link->dev_node = &dev->node;
386 373
387 /* Finally, report what we've done */ 374 /* Finally, report what we've done */
388 printk(KERN_INFO "%s: index 0x%02x: ", 375 printk(KERN_INFO "%s: index 0x%02x: ",
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 53fdaa22226d..522bbed47a05 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -154,22 +154,14 @@ typedef struct local_info_t {
154 154
155static int atmel_attach(struct pcmcia_device *p_dev) 155static int atmel_attach(struct pcmcia_device *p_dev)
156{ 156{
157 dev_link_t *link;
158 local_info_t *local; 157 local_info_t *local;
159 158
160 DEBUG(0, "atmel_attach()\n"); 159 DEBUG(0, "atmel_attach()\n");
161 160
162 /* Initialize the dev_link_t structure */
163 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL);
164 if (!link) {
165 printk(KERN_ERR "atmel_cs: no memory for new device\n");
166 return -ENOMEM;
167 }
168
169 /* Interrupt setup */ 161 /* Interrupt setup */
170 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 162 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
171 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 163 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
172 link->irq.Handler = NULL; 164 p_dev->irq.Handler = NULL;
173 165
174 /* 166 /*
175 General socket configuration defaults can go here. In this 167 General socket configuration defaults can go here. In this
@@ -178,23 +170,19 @@ static int atmel_attach(struct pcmcia_device *p_dev)
178 and attributes of IO windows) are fixed by the nature of the 170 and attributes of IO windows) are fixed by the nature of the
179 device, and can be hard-wired here. 171 device, and can be hard-wired here.
180 */ 172 */
181 link->conf.Attributes = 0; 173 p_dev->conf.Attributes = 0;
182 link->conf.IntType = INT_MEMORY_AND_IO; 174 p_dev->conf.IntType = INT_MEMORY_AND_IO;
183 175
184 /* Allocate space for private device-specific data */ 176 /* Allocate space for private device-specific data */
185 local = kzalloc(sizeof(local_info_t), GFP_KERNEL); 177 local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
186 if (!local) { 178 if (!local) {
187 printk(KERN_ERR "atmel_cs: no memory for new device\n"); 179 printk(KERN_ERR "atmel_cs: no memory for new device\n");
188 kfree (link);
189 return -ENOMEM; 180 return -ENOMEM;
190 } 181 }
191 link->priv = local; 182 p_dev->priv = local;
192
193 link->handle = p_dev;
194 p_dev->instance = link;
195 183
196 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 184 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
197 atmel_config(link); 185 atmel_config(p_dev);
198 186
199 return 0; 187 return 0;
200} /* atmel_attach */ 188} /* atmel_attach */
@@ -218,7 +206,6 @@ static void atmel_detach(struct pcmcia_device *p_dev)
218 atmel_release(link); 206 atmel_release(link);
219 207
220 kfree(link->priv); 208 kfree(link->priv);
221 kfree(link);
222} 209}
223 210
224/*====================================================================== 211/*======================================================================
@@ -387,11 +374,11 @@ static void atmel_config(dev_link_t *link)
387 374
388 /* 375 /*
389 At this point, the dev_node_t structure(s) need to be 376 At this point, the dev_node_t structure(s) need to be
390 initialized and arranged in a linked list at link->dev. 377 initialized and arranged in a linked list at link->dev_node.
391 */ 378 */
392 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name ); 379 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name );
393 dev->node.major = dev->node.minor = 0; 380 dev->node.major = dev->node.minor = 0;
394 link->dev = &dev->node; 381 link->dev_node = &dev->node;
395 382
396 link->state &= ~DEV_CONFIG_PENDING; 383 link->state &= ~DEV_CONFIG_PENDING;
397 return; 384 return;
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index 69024bfb5bba..e3095a88745c 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -503,22 +503,11 @@ static struct prism2_helper_functions prism2_pccard_funcs =
503 * initialize dev_link structure, but do not configure the card yet */ 503 * initialize dev_link structure, but do not configure the card yet */
504static int prism2_attach(struct pcmcia_device *p_dev) 504static int prism2_attach(struct pcmcia_device *p_dev)
505{ 505{
506 dev_link_t *link;
507
508 link = kmalloc(sizeof(dev_link_t), GFP_KERNEL);
509 if (link == NULL)
510 return -ENOMEM;
511
512 memset(link, 0, sizeof(dev_link_t));
513
514 PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info); 506 PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info);
515 link->conf.IntType = INT_MEMORY_AND_IO; 507 p_dev->conf.IntType = INT_MEMORY_AND_IO;
516
517 link->handle = p_dev;
518 p_dev->instance = link;
519 508
520 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 509 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
521 if (prism2_config(link)) 510 if (prism2_config(p_dev))
522 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n"); 511 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");
523 512
524 return 0; 513 return 0;
@@ -546,7 +535,6 @@ static void prism2_detach(struct pcmcia_device *p_dev)
546 prism2_free_local_data(dev); 535 prism2_free_local_data(dev);
547 kfree(hw_priv); 536 kfree(hw_priv);
548 } 537 }
549 kfree(link);
550} 538}
551 539
552 540
@@ -713,7 +701,7 @@ static int prism2_config(dev_link_t *link)
713 local->hw_priv = hw_priv; 701 local->hw_priv = hw_priv;
714 hw_priv->link = link; 702 hw_priv->link = link;
715 strcpy(hw_priv->node.dev_name, dev->name); 703 strcpy(hw_priv->node.dev_name, dev->name);
716 link->dev = &hw_priv->node; 704 link->dev_node = &hw_priv->node;
717 705
718 /* 706 /*
719 * Allocate an interrupt line. Note that this does not assign a 707 * Allocate an interrupt line. Note that this does not assign a
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index 23d6b3376e6e..68dfe68ffecf 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -268,7 +268,7 @@ struct site_survey {
268}; 268};
269 269
270typedef struct netwave_private { 270typedef struct netwave_private {
271 dev_link_t link; 271 struct pcmcia_device *p_dev;
272 spinlock_t spinlock; /* Serialize access to the hardware (SMP) */ 272 spinlock_t spinlock; /* Serialize access to the hardware (SMP) */
273 dev_node_t node; 273 dev_node_t node;
274 u_char __iomem *ramBase; 274 u_char __iomem *ramBase;
@@ -378,9 +378,9 @@ static struct iw_statistics *netwave_get_wireless_stats(struct net_device *dev)
378 */ 378 */
379static int netwave_attach(struct pcmcia_device *p_dev) 379static int netwave_attach(struct pcmcia_device *p_dev)
380{ 380{
381 dev_link_t *link;
382 struct net_device *dev; 381 struct net_device *dev;
383 netwave_private *priv; 382 netwave_private *priv;
383 dev_link_t *link = dev_to_instance(p_dev);
384 384
385 DEBUG(0, "netwave_attach()\n"); 385 DEBUG(0, "netwave_attach()\n");
386 386
@@ -389,7 +389,7 @@ static int netwave_attach(struct pcmcia_device *p_dev)
389 if (!dev) 389 if (!dev)
390 return -ENOMEM; 390 return -ENOMEM;
391 priv = netdev_priv(dev); 391 priv = netdev_priv(dev);
392 link = &priv->link; 392 priv->p_dev = p_dev;
393 link->priv = dev; 393 link->priv = dev;
394 394
395 /* The io structure describes IO port mapping */ 395 /* The io structure describes IO port mapping */
@@ -429,9 +429,6 @@ static int netwave_attach(struct pcmcia_device *p_dev)
429 dev->stop = &netwave_close; 429 dev->stop = &netwave_close;
430 link->irq.Instance = dev; 430 link->irq.Instance = dev;
431 431
432 link->handle = p_dev;
433 p_dev->instance = link;
434
435 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 432 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
436 netwave_pcmcia_config( link); 433 netwave_pcmcia_config( link);
437 434
@@ -456,7 +453,7 @@ static void netwave_detach(struct pcmcia_device *p_dev)
456 if (link->state & DEV_CONFIG) 453 if (link->state & DEV_CONFIG)
457 netwave_release(link); 454 netwave_release(link);
458 455
459 if (link->dev) 456 if (link->dev_node)
460 unregister_netdev(dev); 457 unregister_netdev(dev);
461 458
462 free_netdev(dev); 459 free_netdev(dev);
@@ -830,7 +827,7 @@ static void netwave_pcmcia_config(dev_link_t *link) {
830 } 827 }
831 828
832 strcpy(priv->node.dev_name, dev->name); 829 strcpy(priv->node.dev_name, dev->name);
833 link->dev = &priv->node; 830 link->dev_node = &priv->node;
834 link->state &= ~DEV_CONFIG_PENDING; 831 link->state &= ~DEV_CONFIG_PENDING;
835 832
836 /* Reset card before reading physical address */ 833 /* Reset card before reading physical address */
@@ -1103,7 +1100,7 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id, struct pt_regs *regs
1103 u_char __iomem *ramBase; 1100 u_char __iomem *ramBase;
1104 struct net_device *dev = (struct net_device *)dev_id; 1101 struct net_device *dev = (struct net_device *)dev_id;
1105 struct netwave_private *priv = netdev_priv(dev); 1102 struct netwave_private *priv = netdev_priv(dev);
1106 dev_link_t *link = &priv->link; 1103 dev_link_t *link = priv->p_dev;
1107 int i; 1104 int i;
1108 1105
1109 if (!netif_device_present(dev)) 1106 if (!netif_device_present(dev))
@@ -1357,7 +1354,7 @@ static int netwave_rx(struct net_device *dev)
1357 1354
1358static int netwave_open(struct net_device *dev) { 1355static int netwave_open(struct net_device *dev) {
1359 netwave_private *priv = netdev_priv(dev); 1356 netwave_private *priv = netdev_priv(dev);
1360 dev_link_t *link = &priv->link; 1357 dev_link_t *link = priv->p_dev;
1361 1358
1362 DEBUG(1, "netwave_open: starting.\n"); 1359 DEBUG(1, "netwave_open: starting.\n");
1363 1360
@@ -1374,7 +1371,7 @@ static int netwave_open(struct net_device *dev) {
1374 1371
1375static int netwave_close(struct net_device *dev) { 1372static int netwave_close(struct net_device *dev) {
1376 netwave_private *priv = netdev_priv(dev); 1373 netwave_private *priv = netdev_priv(dev);
1377 dev_link_t *link = &priv->link; 1374 dev_link_t *link = priv->p_dev;
1378 1375
1379 DEBUG(1, "netwave_close: finishing.\n"); 1376 DEBUG(1, "netwave_close: finishing.\n");
1380 1377
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index 75981d88a1e2..f10d97bc45f0 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -49,7 +49,7 @@ MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket
49/* PCMCIA specific device information (goes in the card field of 49/* PCMCIA specific device information (goes in the card field of
50 * struct orinoco_private */ 50 * struct orinoco_private */
51struct orinoco_pccard { 51struct orinoco_pccard {
52 dev_link_t link; 52 struct pcmcia_device *p_dev;
53 dev_node_t node; 53 dev_node_t node;
54 54
55 /* Used to handle hard reset */ 55 /* Used to handle hard reset */
@@ -75,7 +75,7 @@ static int
75orinoco_cs_hard_reset(struct orinoco_private *priv) 75orinoco_cs_hard_reset(struct orinoco_private *priv)
76{ 76{
77 struct orinoco_pccard *card = priv->card; 77 struct orinoco_pccard *card = priv->card;
78 dev_link_t *link = &card->link; 78 dev_link_t *link = card->p_dev;
79 int err; 79 int err;
80 80
81 /* We need atomic ops here, because we're not holding the lock */ 81 /* We need atomic ops here, because we're not holding the lock */
@@ -109,7 +109,7 @@ orinoco_cs_attach(struct pcmcia_device *p_dev)
109 struct net_device *dev; 109 struct net_device *dev;
110 struct orinoco_private *priv; 110 struct orinoco_private *priv;
111 struct orinoco_pccard *card; 111 struct orinoco_pccard *card;
112 dev_link_t *link; 112 dev_link_t *link = dev_to_instance(p_dev);
113 113
114 dev = alloc_orinocodev(sizeof(*card), orinoco_cs_hard_reset); 114 dev = alloc_orinocodev(sizeof(*card), orinoco_cs_hard_reset);
115 if (! dev) 115 if (! dev)
@@ -118,7 +118,7 @@ orinoco_cs_attach(struct pcmcia_device *p_dev)
118 card = priv->card; 118 card = priv->card;
119 119
120 /* Link both structures together */ 120 /* Link both structures together */
121 link = &card->link; 121 card->p_dev = p_dev;
122 link->priv = dev; 122 link->priv = dev;
123 123
124 /* Interrupt setup */ 124 /* Interrupt setup */
@@ -135,12 +135,6 @@ orinoco_cs_attach(struct pcmcia_device *p_dev)
135 link->conf.Attributes = 0; 135 link->conf.Attributes = 0;
136 link->conf.IntType = INT_MEMORY_AND_IO; 136 link->conf.IntType = INT_MEMORY_AND_IO;
137 137
138 /* Register with Card Services */
139 link->next = NULL;
140
141 link->handle = p_dev;
142 p_dev->instance = link;
143
144 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 138 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
145 orinoco_cs_config(link); 139 orinoco_cs_config(link);
146 140
@@ -161,8 +155,8 @@ static void orinoco_cs_detach(struct pcmcia_device *p_dev)
161 if (link->state & DEV_CONFIG) 155 if (link->state & DEV_CONFIG)
162 orinoco_cs_release(link); 156 orinoco_cs_release(link);
163 157
164 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); 158 DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node);
165 if (link->dev) { 159 if (link->dev_node) {
166 DEBUG(0, PFX "About to unregister net device %p\n", 160 DEBUG(0, PFX "About to unregister net device %p\n",
167 dev); 161 dev);
168 unregister_netdev(dev); 162 unregister_netdev(dev);
@@ -364,9 +358,9 @@ orinoco_cs_config(dev_link_t *link)
364 } 358 }
365 359
366 /* At this point, the dev_node_t structure(s) needs to be 360 /* At this point, the dev_node_t structure(s) needs to be
367 * initialized and arranged in a linked list at link->dev. */ 361 * initialized and arranged in a linked list at link->dev_node. */
368 strcpy(card->node.dev_name, dev->name); 362 strcpy(card->node.dev_name, dev->name);
369 link->dev = &card->node; /* link->dev being non-NULL is also 363 link->dev_node = &card->node; /* link->dev_node being non-NULL is also
370 used to indicate that the 364 used to indicate that the
371 net_device has been registered */ 365 net_device has been registered */
372 link->state &= ~DEV_CONFIG_PENDING; 366 link->state &= ~DEV_CONFIG_PENDING;
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 7d95587d09db..60297460debd 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -190,12 +190,6 @@ static int bc;
190static char *phy_addr = NULL; 190static char *phy_addr = NULL;
191 191
192 192
193/* A linked list of "instances" of the ray device. Each actual
194 PCMCIA card corresponds to one device instance, and is described
195 by one dev_link_t structure (defined in ds.h).
196*/
197static dev_link_t *dev_list = NULL;
198
199/* A dev_link_t structure has fields for most things that are needed 193/* A dev_link_t structure has fields for most things that are needed
200 to keep track of a socket, but there will usually be some device 194 to keep track of a socket, but there will usually be some device
201 specific information that also needs to be kept track of. The 195 specific information that also needs to be kept track of. The
@@ -204,6 +198,9 @@ static dev_link_t *dev_list = NULL;
204*/ 198*/
205static unsigned int ray_mem_speed = 500; 199static unsigned int ray_mem_speed = 500;
206 200
201/* WARNING: THIS DRIVER IS NOT CAPABLE OF HANDLING MULTIPLE DEVICES! */
202static struct pcmcia_device *this_device = NULL;
203
207MODULE_AUTHOR("Corey Thomas <corey@world.std.com>"); 204MODULE_AUTHOR("Corey Thomas <corey@world.std.com>");
208MODULE_DESCRIPTION("Raylink/WebGear wireless LAN driver"); 205MODULE_DESCRIPTION("Raylink/WebGear wireless LAN driver");
209MODULE_LICENSE("GPL"); 206MODULE_LICENSE("GPL");
@@ -308,53 +305,44 @@ static char rcsid[] = "Raylink/WebGear wireless LAN - Corey <Thomas corey@world.
308=============================================================================*/ 305=============================================================================*/
309static int ray_attach(struct pcmcia_device *p_dev) 306static int ray_attach(struct pcmcia_device *p_dev)
310{ 307{
311 dev_link_t *link;
312 ray_dev_t *local; 308 ray_dev_t *local;
313 struct net_device *dev; 309 struct net_device *dev;
314
315 DEBUG(1, "ray_attach()\n");
316
317 /* Initialize the dev_link_t structure */
318 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
319 310
320 if (!link) 311 DEBUG(1, "ray_attach()\n");
321 return -ENOMEM;
322 312
323 /* Allocate space for private device-specific data */ 313 /* Allocate space for private device-specific data */
324 dev = alloc_etherdev(sizeof(ray_dev_t)); 314 dev = alloc_etherdev(sizeof(ray_dev_t));
325
326 if (!dev) 315 if (!dev)
327 goto fail_alloc_dev; 316 goto fail_alloc_dev;
328 317
329 local = dev->priv; 318 local = dev->priv;
330 319 local->finder = p_dev;
331 memset(link, 0, sizeof(struct dev_link_t));
332 320
333 /* The io structure describes IO port mapping. None used here */ 321 /* The io structure describes IO port mapping. None used here */
334 link->io.NumPorts1 = 0; 322 p_dev->io.NumPorts1 = 0;
335 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 323 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
336 link->io.IOAddrLines = 5; 324 p_dev->io.IOAddrLines = 5;
337 325
338 /* Interrupt setup. For PCMCIA, driver takes what's given */ 326 /* Interrupt setup. For PCMCIA, driver takes what's given */
339 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 327 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
340 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 328 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
341 link->irq.Handler = &ray_interrupt; 329 p_dev->irq.Handler = &ray_interrupt;
342 330
343 /* General socket configuration */ 331 /* General socket configuration */
344 link->conf.Attributes = CONF_ENABLE_IRQ; 332 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
345 link->conf.IntType = INT_MEMORY_AND_IO; 333 p_dev->conf.IntType = INT_MEMORY_AND_IO;
346 link->conf.ConfigIndex = 1; 334 p_dev->conf.ConfigIndex = 1;
347 link->conf.Present = PRESENT_OPTION; 335 p_dev->conf.Present = PRESENT_OPTION;
348 336
349 link->priv = dev; 337 p_dev->priv = dev;
350 link->irq.Instance = dev; 338 p_dev->irq.Instance = dev;
351 339
352 local->finder = link; 340 local->finder = p_dev;
353 local->card_status = CARD_INSERTED; 341 local->card_status = CARD_INSERTED;
354 local->authentication_state = UNAUTHENTICATED; 342 local->authentication_state = UNAUTHENTICATED;
355 local->num_multi = 0; 343 local->num_multi = 0;
356 DEBUG(2,"ray_attach link = %p, dev = %p, local = %p, intr = %p\n", 344 DEBUG(2,"ray_attach p_dev = %p, dev = %p, local = %p, intr = %p\n",
357 link,dev,local,&ray_interrupt); 345 p_dev,dev,local,&ray_interrupt);
358 346
359 /* Raylink entries in the device structure */ 347 /* Raylink entries in the device structure */
360 dev->hard_start_xmit = &ray_dev_start_xmit; 348 dev->hard_start_xmit = &ray_dev_start_xmit;
@@ -378,16 +366,13 @@ static int ray_attach(struct pcmcia_device *p_dev)
378 366
379 init_timer(&local->timer); 367 init_timer(&local->timer);
380 368
381 link->handle = p_dev; 369 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
382 p_dev->instance = link; 370 this_device = p_dev;
383 371 ray_config(p_dev);
384 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
385 ray_config(link);
386 372
387 return 0; 373 return 0;
388 374
389fail_alloc_dev: 375fail_alloc_dev:
390 kfree(link);
391 return -ENOMEM; 376 return -ENOMEM;
392} /* ray_attach */ 377} /* ray_attach */
393/*============================================================================= 378/*=============================================================================
@@ -399,18 +384,12 @@ fail_alloc_dev:
399static void ray_detach(struct pcmcia_device *p_dev) 384static void ray_detach(struct pcmcia_device *p_dev)
400{ 385{
401 dev_link_t *link = dev_to_instance(p_dev); 386 dev_link_t *link = dev_to_instance(p_dev);
402 dev_link_t **linkp;
403 struct net_device *dev; 387 struct net_device *dev;
404 ray_dev_t *local; 388 ray_dev_t *local;
405 389
406 DEBUG(1, "ray_detach(0x%p)\n", link); 390 DEBUG(1, "ray_detach(0x%p)\n", link);
407
408 /* Locate device structure */
409 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
410 if (*linkp == link) break;
411 if (*linkp == NULL)
412 return;
413 391
392 this_device = NULL;
414 dev = link->priv; 393 dev = link->priv;
415 394
416 if (link->state & DEV_CONFIG) { 395 if (link->state & DEV_CONFIG) {
@@ -420,13 +399,10 @@ static void ray_detach(struct pcmcia_device *p_dev)
420 del_timer(&local->timer); 399 del_timer(&local->timer);
421 } 400 }
422 401
423 /* Unlink device structure, free pieces */
424 *linkp = link->next;
425 if (link->priv) { 402 if (link->priv) {
426 if (link->dev) unregister_netdev(dev); 403 if (link->dev_node) unregister_netdev(dev);
427 free_netdev(dev); 404 free_netdev(dev);
428 } 405 }
429 kfree(link);
430 DEBUG(2,"ray_cs ray_detach ending\n"); 406 DEBUG(2,"ray_cs ray_detach ending\n");
431} /* ray_detach */ 407} /* ray_detach */
432/*============================================================================= 408/*=============================================================================
@@ -537,7 +513,7 @@ static void ray_config(dev_link_t *link)
537 } 513 }
538 514
539 strcpy(local->node.dev_name, dev->name); 515 strcpy(local->node.dev_name, dev->name);
540 link->dev = &local->node; 516 link->dev_node = &local->node;
541 517
542 link->state &= ~DEV_CONFIG_PENDING; 518 link->state &= ~DEV_CONFIG_PENDING;
543 printk(KERN_INFO "%s: RayLink, irq %d, hw_addr ", 519 printk(KERN_INFO "%s: RayLink, irq %d, hw_addr ",
@@ -1640,18 +1616,14 @@ static const struct iw_handler_def ray_handler_def =
1640/*===========================================================================*/ 1616/*===========================================================================*/
1641static int ray_open(struct net_device *dev) 1617static int ray_open(struct net_device *dev)
1642{ 1618{
1643 dev_link_t *link;
1644 ray_dev_t *local = (ray_dev_t *)dev->priv; 1619 ray_dev_t *local = (ray_dev_t *)dev->priv;
1620 dev_link_t *link;
1621 link = local->finder;
1645 1622
1646 DEBUG(1, "ray_open('%s')\n", dev->name); 1623 DEBUG(1, "ray_open('%s')\n", dev->name);
1647 1624
1648 for (link = dev_list; link; link = link->next) 1625 if (link->open == 0)
1649 if (link->priv == dev) break; 1626 local->num_multi = 0;
1650 if (!DEV_OK(link)) {
1651 return -ENODEV;
1652 }
1653
1654 if (link->open == 0) local->num_multi = 0;
1655 link->open++; 1627 link->open++;
1656 1628
1657 /* If the card is not started, time to start it ! - Jean II */ 1629 /* If the card is not started, time to start it ! - Jean II */
@@ -1678,15 +1650,12 @@ static int ray_open(struct net_device *dev)
1678/*===========================================================================*/ 1650/*===========================================================================*/
1679static int ray_dev_close(struct net_device *dev) 1651static int ray_dev_close(struct net_device *dev)
1680{ 1652{
1653 ray_dev_t *local = (ray_dev_t *)dev->priv;
1681 dev_link_t *link; 1654 dev_link_t *link;
1655 link = local->finder;
1682 1656
1683 DEBUG(1, "ray_dev_close('%s')\n", dev->name); 1657 DEBUG(1, "ray_dev_close('%s')\n", dev->name);
1684 1658
1685 for (link = dev_list; link; link = link->next)
1686 if (link->priv == dev) break;
1687 if (link == NULL)
1688 return -ENODEV;
1689
1690 link->open--; 1659 link->open--;
1691 netif_stop_queue(dev); 1660 netif_stop_queue(dev);
1692 1661
@@ -2679,7 +2648,7 @@ static int ray_cs_proc_read(char *buf, char **start, off_t offset, int len)
2679 struct freq_hop_element *pfh; 2648 struct freq_hop_element *pfh;
2680 UCHAR c[33]; 2649 UCHAR c[33];
2681 2650
2682 link = dev_list; 2651 link = this_device;
2683 if (!link) 2652 if (!link)
2684 return 0; 2653 return 0;
2685 dev = (struct net_device *)link->priv; 2654 dev = (struct net_device *)link->priv;
@@ -2923,7 +2892,6 @@ static void __exit exit_ray_cs(void)
2923#endif 2892#endif
2924 2893
2925 pcmcia_unregister_driver(&ray_driver); 2894 pcmcia_unregister_driver(&ray_driver);
2926 BUG_ON(dev_list != NULL);
2927} /* exit_ray_cs */ 2895} /* exit_ray_cs */
2928 2896
2929module_init(init_ray_cs); 2897module_init(init_ray_cs);
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index 7a4a80b01f9c..be36679c8c95 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -63,7 +63,7 @@ MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket
63/* PCMCIA specific device information (goes in the card field of 63/* PCMCIA specific device information (goes in the card field of
64 * struct orinoco_private */ 64 * struct orinoco_private */
65struct orinoco_pccard { 65struct orinoco_pccard {
66 dev_link_t link; 66 struct pcmcia_device *p_dev;
67 dev_node_t node; 67 dev_node_t node;
68}; 68};
69 69
@@ -554,12 +554,12 @@ static int
554spectrum_cs_hard_reset(struct orinoco_private *priv) 554spectrum_cs_hard_reset(struct orinoco_private *priv)
555{ 555{
556 struct orinoco_pccard *card = priv->card; 556 struct orinoco_pccard *card = priv->card;
557 dev_link_t *link = &card->link; 557 dev_link_t *link = card->p_dev;
558 int err; 558 int err;
559 559
560 if (!hermes_present(&priv->hw)) { 560 if (!hermes_present(&priv->hw)) {
561 /* The firmware needs to be reloaded */ 561 /* The firmware needs to be reloaded */
562 if (spectrum_dl_firmware(&priv->hw, &card->link) != 0) { 562 if (spectrum_dl_firmware(&priv->hw, link) != 0) {
563 printk(KERN_ERR PFX "Firmware download failed\n"); 563 printk(KERN_ERR PFX "Firmware download failed\n");
564 err = -ENODEV; 564 err = -ENODEV;
565 } 565 }
@@ -589,7 +589,7 @@ spectrum_cs_attach(struct pcmcia_device *p_dev)
589 struct net_device *dev; 589 struct net_device *dev;
590 struct orinoco_private *priv; 590 struct orinoco_private *priv;
591 struct orinoco_pccard *card; 591 struct orinoco_pccard *card;
592 dev_link_t *link; 592 dev_link_t *link = dev_to_instance(p_dev);
593 593
594 dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset); 594 dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset);
595 if (! dev) 595 if (! dev)
@@ -598,7 +598,7 @@ spectrum_cs_attach(struct pcmcia_device *p_dev)
598 card = priv->card; 598 card = priv->card;
599 599
600 /* Link both structures together */ 600 /* Link both structures together */
601 link = &card->link; 601 card->p_dev = p_dev;
602 link->priv = dev; 602 link->priv = dev;
603 603
604 /* Interrupt setup */ 604 /* Interrupt setup */
@@ -615,9 +615,6 @@ spectrum_cs_attach(struct pcmcia_device *p_dev)
615 link->conf.Attributes = 0; 615 link->conf.Attributes = 0;
616 link->conf.IntType = INT_MEMORY_AND_IO; 616 link->conf.IntType = INT_MEMORY_AND_IO;
617 617
618 link->handle = p_dev;
619 p_dev->instance = link;
620
621 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 618 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
622 spectrum_cs_config(link); 619 spectrum_cs_config(link);
623 620
@@ -638,8 +635,8 @@ static void spectrum_cs_detach(struct pcmcia_device *p_dev)
638 if (link->state & DEV_CONFIG) 635 if (link->state & DEV_CONFIG)
639 spectrum_cs_release(link); 636 spectrum_cs_release(link);
640 637
641 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); 638 DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node);
642 if (link->dev) { 639 if (link->dev_node) {
643 DEBUG(0, PFX "About to unregister net device %p\n", 640 DEBUG(0, PFX "About to unregister net device %p\n",
644 dev); 641 dev);
645 unregister_netdev(dev); 642 unregister_netdev(dev);
@@ -842,9 +839,9 @@ spectrum_cs_config(dev_link_t *link)
842 } 839 }
843 840
844 /* At this point, the dev_node_t structure(s) needs to be 841 /* At this point, the dev_node_t structure(s) needs to be
845 * initialized and arranged in a linked list at link->dev. */ 842 * initialized and arranged in a linked list at link->dev_node. */
846 strcpy(card->node.dev_name, dev->name); 843 strcpy(card->node.dev_name, dev->name);
847 link->dev = &card->node; /* link->dev being non-NULL is also 844 link->dev_node = &card->node; /* link->dev_node being non-NULL is also
848 used to indicate that the 845 used to indicate that the
849 net_device has been registered */ 846 net_device has been registered */
850 link->state &= ~DEV_CONFIG_PENDING; 847 link->state &= ~DEV_CONFIG_PENDING;
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index daa17dc34320..baa1011e70e0 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -4081,7 +4081,7 @@ wv_pcmcia_config(dev_link_t * link)
4081 } 4081 }
4082 4082
4083 strcpy(((net_local *) netdev_priv(dev))->node.dev_name, dev->name); 4083 strcpy(((net_local *) netdev_priv(dev))->node.dev_name, dev->name);
4084 link->dev = &((net_local *) netdev_priv(dev))->node; 4084 link->dev_node = &((net_local *) netdev_priv(dev))->node;
4085 4085
4086#ifdef DEBUG_CONFIG_TRACE 4086#ifdef DEBUG_CONFIG_TRACE
4087 printk(KERN_DEBUG "<-wv_pcmcia_config()\n"); 4087 printk(KERN_DEBUG "<-wv_pcmcia_config()\n");
@@ -4583,7 +4583,6 @@ wavelan_close(struct net_device * dev)
4583static int 4583static int
4584wavelan_attach(struct pcmcia_device *p_dev) 4584wavelan_attach(struct pcmcia_device *p_dev)
4585{ 4585{
4586 dev_link_t * link; /* Info for cardmgr */
4587 struct net_device * dev; /* Interface generic data */ 4586 struct net_device * dev; /* Interface generic data */
4588 net_local * lp; /* Interface specific data */ 4587 net_local * lp; /* Interface specific data */
4589 4588
@@ -4591,34 +4590,26 @@ wavelan_attach(struct pcmcia_device *p_dev)
4591 printk(KERN_DEBUG "-> wavelan_attach()\n"); 4590 printk(KERN_DEBUG "-> wavelan_attach()\n");
4592#endif 4591#endif
4593 4592
4594 /* Initialize the dev_link_t structure */
4595 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL);
4596 if (!link) return -ENOMEM;
4597
4598 /* The io structure describes IO port mapping */ 4593 /* The io structure describes IO port mapping */
4599 link->io.NumPorts1 = 8; 4594 p_dev->io.NumPorts1 = 8;
4600 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 4595 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
4601 link->io.IOAddrLines = 3; 4596 p_dev->io.IOAddrLines = 3;
4602 4597
4603 /* Interrupt setup */ 4598 /* Interrupt setup */
4604 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 4599 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
4605 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 4600 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
4606 link->irq.Handler = wavelan_interrupt; 4601 p_dev->irq.Handler = wavelan_interrupt;
4607 4602
4608 /* General socket configuration */ 4603 /* General socket configuration */
4609 link->conf.Attributes = CONF_ENABLE_IRQ; 4604 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
4610 link->conf.IntType = INT_MEMORY_AND_IO; 4605 p_dev->conf.IntType = INT_MEMORY_AND_IO;
4611
4612 /* Chain drivers */
4613 link->next = NULL;
4614 4606
4615 /* Allocate the generic data structure */ 4607 /* Allocate the generic data structure */
4616 dev = alloc_etherdev(sizeof(net_local)); 4608 dev = alloc_etherdev(sizeof(net_local));
4617 if (!dev) { 4609 if (!dev)
4618 kfree(link);
4619 return -ENOMEM; 4610 return -ENOMEM;
4620 } 4611
4621 link->priv = link->irq.Instance = dev; 4612 p_dev->priv = p_dev->irq.Instance = dev;
4622 4613
4623 lp = netdev_priv(dev); 4614 lp = netdev_priv(dev);
4624 4615
@@ -4635,7 +4626,6 @@ wavelan_attach(struct pcmcia_device *p_dev)
4635 spin_lock_init(&lp->spinlock); 4626 spin_lock_init(&lp->spinlock);
4636 4627
4637 /* back links */ 4628 /* back links */
4638 lp->link = link;
4639 lp->dev = dev; 4629 lp->dev = dev;
4640 4630
4641 /* wavelan NET3 callbacks */ 4631 /* wavelan NET3 callbacks */
@@ -4661,11 +4651,8 @@ wavelan_attach(struct pcmcia_device *p_dev)
4661 /* Other specific data */ 4651 /* Other specific data */
4662 dev->mtu = WAVELAN_MTU; 4652 dev->mtu = WAVELAN_MTU;
4663 4653
4664 link->handle = p_dev; 4654 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
4665 p_dev->instance = link; 4655 if(wv_pcmcia_config(p_dev) &&
4666
4667 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
4668 if(wv_pcmcia_config(link) &&
4669 wv_hw_config(dev)) 4656 wv_hw_config(dev))
4670 wv_init_info(dev); 4657 wv_init_info(dev);
4671 else 4658 else
@@ -4713,14 +4700,13 @@ wavelan_detach(struct pcmcia_device *p_dev)
4713 4700
4714 /* Remove ourselves from the kernel list of ethernet devices */ 4701 /* Remove ourselves from the kernel list of ethernet devices */
4715 /* Warning : can't be called from interrupt, timer or wavelan_close() */ 4702 /* Warning : can't be called from interrupt, timer or wavelan_close() */
4716 if (link->dev) 4703 if (link->dev_node)
4717 unregister_netdev(dev); 4704 unregister_netdev(dev);
4718 link->dev = NULL; 4705 link->dev_node = NULL;
4719 ((net_local *)netdev_priv(dev))->link = NULL; 4706 ((net_local *)netdev_priv(dev))->link = NULL;
4720 ((net_local *)netdev_priv(dev))->dev = NULL; 4707 ((net_local *)netdev_priv(dev))->dev = NULL;
4721 free_netdev(dev); 4708 free_netdev(dev);
4722 } 4709 }
4723 kfree(link);
4724 4710
4725#ifdef DEBUG_CALLBACK_TRACE 4711#ifdef DEBUG_CALLBACK_TRACE
4726 printk(KERN_DEBUG "<- wavelan_detach()\n"); 4712 printk(KERN_DEBUG "<- wavelan_detach()\n");
diff --git a/drivers/net/wireless/wl3501.h b/drivers/net/wireless/wl3501.h
index 4303c50c2ab6..65ceb088f700 100644
--- a/drivers/net/wireless/wl3501.h
+++ b/drivers/net/wireless/wl3501.h
@@ -611,5 +611,6 @@ struct wl3501_card {
611 struct iw_spy_data spy_data; 611 struct iw_spy_data spy_data;
612 struct iw_public_data wireless_data; 612 struct iw_public_data wireless_data;
613 struct dev_node_t node; 613 struct dev_node_t node;
614 struct pcmcia_device *p_dev;
614}; 615};
615#endif 616#endif
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);