aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2006-03-01 18:09:29 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2006-03-31 10:26:33 -0500
commite2d4096365e06b9a3799afbadc28b4519c0b3526 (patch)
tree90ec691d71f9c0309048714e359b8ba351b533f7 /drivers/net/wireless
parentf6fbe01ac976f3ec618cd5fb71ad9ce2cfa7ab2b (diff)
[PATCH] pcmcia: use bitfield instead of p_state and state
Instead of the two status values struct pcmcia_device->p_state and state, use descriptive bitfields. Most value-checking in drivers was invalid, as the core now only calls the ->remove() (a.k.a. detach) function in case the attachement _and_ configuration was successful. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/airo_cs.c16
-rw-r--r--drivers/net/wireless/atmel_cs.c25
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c56
-rw-r--r--drivers/net/wireless/netwave_cs.c12
-rw-r--r--drivers/net/wireless/orinoco_cs.c70
-rw-r--r--drivers/net/wireless/ray_cs.c53
-rw-r--r--drivers/net/wireless/spectrum_cs.c37
-rw-r--r--drivers/net/wireless/wavelan_cs.c24
-rw-r--r--drivers/net/wireless/wl3501_cs.c19
9 files changed, 117 insertions, 195 deletions
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index 97f41565fca8..af0cbb6c5c0c 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -170,7 +170,6 @@ static int airo_probe(struct pcmcia_device *p_dev)
170 } 170 }
171 p_dev->priv = local; 171 p_dev->priv = local;
172 172
173 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
174 return airo_config(p_dev); 173 return airo_config(p_dev);
175} /* airo_attach */ 174} /* airo_attach */
176 175
@@ -187,8 +186,7 @@ static void airo_detach(struct pcmcia_device *link)
187{ 186{
188 DEBUG(0, "airo_detach(0x%p)\n", link); 187 DEBUG(0, "airo_detach(0x%p)\n", link);
189 188
190 if (link->state & DEV_CONFIG) 189 airo_release(link);
191 airo_release(link);
192 190
193 if ( ((local_info_t*)link->priv)->eth_dev ) { 191 if ( ((local_info_t*)link->priv)->eth_dev ) {
194 stop_airo_card( ((local_info_t*)link->priv)->eth_dev, 0 ); 192 stop_airo_card( ((local_info_t*)link->priv)->eth_dev, 0 );
@@ -237,10 +235,7 @@ static int airo_config(struct pcmcia_device *link)
237 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 235 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
238 link->conf.ConfigBase = parse.config.base; 236 link->conf.ConfigBase = parse.config.base;
239 link->conf.Present = parse.config.rmask[0]; 237 link->conf.Present = parse.config.rmask[0];
240 238
241 /* Configure card */
242 link->state |= DEV_CONFIG;
243
244 /* 239 /*
245 In this loop, we scan the CIS for configuration table entries, 240 In this loop, we scan the CIS for configuration table entries,
246 each of which describes a valid card configuration, including 241 each of which describes a valid card configuration, including
@@ -382,8 +377,6 @@ static int airo_config(struct pcmcia_device *link)
382 printk(", mem 0x%06lx-0x%06lx", req.Base, 377 printk(", mem 0x%06lx-0x%06lx", req.Base,
383 req.Base+req.Size-1); 378 req.Base+req.Size-1);
384 printk("\n"); 379 printk("\n");
385
386 link->state &= ~DEV_CONFIG_PENDING;
387 return 0; 380 return 0;
388 381
389 cs_failed: 382 cs_failed:
@@ -410,8 +403,7 @@ static int airo_suspend(struct pcmcia_device *link)
410{ 403{
411 local_info_t *local = link->priv; 404 local_info_t *local = link->priv;
412 405
413 if (link->state & DEV_CONFIG) 406 netif_device_detach(local->eth_dev);
414 netif_device_detach(local->eth_dev);
415 407
416 return 0; 408 return 0;
417} 409}
@@ -420,7 +412,7 @@ static int airo_resume(struct pcmcia_device *link)
420{ 412{
421 local_info_t *local = link->priv; 413 local_info_t *local = link->priv;
422 414
423 if ((link->state & DEV_CONFIG) && (link->open)) { 415 if (link->open) {
424 reset_airo_card(local->eth_dev); 416 reset_airo_card(local->eth_dev);
425 netif_device_attach(local->eth_dev); 417 netif_device_attach(local->eth_dev);
426 } 418 }
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index d09b1472e673..25fb919b3791 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -181,7 +181,6 @@ static int atmel_probe(struct pcmcia_device *p_dev)
181 } 181 }
182 p_dev->priv = local; 182 p_dev->priv = local;
183 183
184 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
185 return atmel_config(p_dev); 184 return atmel_config(p_dev);
186} /* atmel_attach */ 185} /* atmel_attach */
187 186
@@ -198,8 +197,7 @@ static void atmel_detach(struct pcmcia_device *link)
198{ 197{
199 DEBUG(0, "atmel_detach(0x%p)\n", link); 198 DEBUG(0, "atmel_detach(0x%p)\n", link);
200 199
201 if (link->state & DEV_CONFIG) 200 atmel_release(link);
202 atmel_release(link);
203 201
204 kfree(link->priv); 202 kfree(link->priv);
205} 203}
@@ -222,7 +220,7 @@ static int card_present(void *arg)
222 struct pcmcia_device *link = (struct pcmcia_device *)arg; 220 struct pcmcia_device *link = (struct pcmcia_device *)arg;
223 if (link->suspended) 221 if (link->suspended)
224 return 0; 222 return 0;
225 else if (link->state & DEV_PRESENT) 223 else if (pcmcia_dev_present(link))
226 return 1; 224 return 1;
227 225
228 return 0; 226 return 0;
@@ -257,10 +255,7 @@ static int atmel_config(struct pcmcia_device *link)
257 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 255 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
258 link->conf.ConfigBase = parse.config.base; 256 link->conf.ConfigBase = parse.config.base;
259 link->conf.Present = parse.config.rmask[0]; 257 link->conf.Present = parse.config.rmask[0];
260 258
261 /* Configure card */
262 link->state |= DEV_CONFIG;
263
264 /* 259 /*
265 In this loop, we scan the CIS for configuration table entries, 260 In this loop, we scan the CIS for configuration table entries,
266 each of which describes a valid card configuration, including 261 each of which describes a valid card configuration, including
@@ -373,10 +368,9 @@ static int atmel_config(struct pcmcia_device *link)
373 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name ); 368 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name );
374 dev->node.major = dev->node.minor = 0; 369 dev->node.major = dev->node.minor = 0;
375 link->dev_node = &dev->node; 370 link->dev_node = &dev->node;
376 371
377 link->state &= ~DEV_CONFIG_PENDING;
378 return 0; 372 return 0;
379 373
380 cs_failed: 374 cs_failed:
381 cs_error(link, last_fn, last_ret); 375 cs_error(link, last_fn, last_ret);
382 atmel_release(link); 376 atmel_release(link);
@@ -408,8 +402,7 @@ static int atmel_suspend(struct pcmcia_device *link)
408{ 402{
409 local_info_t *local = link->priv; 403 local_info_t *local = link->priv;
410 404
411 if (link->state & DEV_CONFIG) 405 netif_device_detach(local->eth_dev);
412 netif_device_detach(local->eth_dev);
413 406
414 return 0; 407 return 0;
415} 408}
@@ -418,10 +411,8 @@ static int atmel_resume(struct pcmcia_device *link)
418{ 411{
419 local_info_t *local = link->priv; 412 local_info_t *local = link->priv;
420 413
421 if (link->state & DEV_CONFIG) { 414 atmel_open(local->eth_dev);
422 atmel_open(local->eth_dev); 415 netif_device_attach(local->eth_dev);
423 netif_device_attach(local->eth_dev);
424 }
425 416
426 return 0; 417 return 0;
427} 418}
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index 88dc383a3da7..a2cb9b0fa3d6 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -210,9 +210,7 @@ static int prism2_config(struct pcmcia_device *link);
210static int prism2_pccard_card_present(local_info_t *local) 210static int prism2_pccard_card_present(local_info_t *local)
211{ 211{
212 struct hostap_cs_priv *hw_priv = local->hw_priv; 212 struct hostap_cs_priv *hw_priv = local->hw_priv;
213 if (hw_priv != NULL && hw_priv->link != NULL && 213 if (hw_priv != NULL && hw_priv->link != NULL && DEV_OK(hw_priv->link))
214 ((hw_priv->link->state & (DEV_PRESENT | DEV_CONFIG)) ==
215 (DEV_PRESENT | DEV_CONFIG)))
216 return 1; 214 return 1;
217 return 0; 215 return 0;
218} 216}
@@ -508,7 +506,6 @@ static int hostap_cs_probe(struct pcmcia_device *p_dev)
508 PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info); 506 PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info);
509 p_dev->conf.IntType = INT_MEMORY_AND_IO; 507 p_dev->conf.IntType = INT_MEMORY_AND_IO;
510 508
511 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
512 ret = prism2_config(p_dev); 509 ret = prism2_config(p_dev);
513 if (ret) { 510 if (ret) {
514 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n"); 511 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");
@@ -522,9 +519,7 @@ static void prism2_detach(struct pcmcia_device *link)
522{ 519{
523 PDEBUG(DEBUG_FLOW, "prism2_detach\n"); 520 PDEBUG(DEBUG_FLOW, "prism2_detach\n");
524 521
525 if (link->state & DEV_CONFIG) { 522 prism2_release((u_long)link);
526 prism2_release((u_long)link);
527 }
528 523
529 /* release net devices */ 524 /* release net devices */
530 if (link->priv) { 525 if (link->priv) {
@@ -746,9 +741,6 @@ static int prism2_config(struct pcmcia_device *link)
746 link->io.BasePort2+link->io.NumPorts2-1); 741 link->io.BasePort2+link->io.NumPorts2-1);
747 printk("\n"); 742 printk("\n");
748 743
749 link->state |= DEV_CONFIG;
750 link->state &= ~DEV_CONFIG_PENDING;
751
752 local->shutdown = 0; 744 local->shutdown = 0;
753 745
754 sandisk_enable_wireless(dev); 746 sandisk_enable_wireless(dev);
@@ -784,8 +776,7 @@ static void prism2_release(u_long arg)
784 struct hostap_interface *iface; 776 struct hostap_interface *iface;
785 777
786 iface = netdev_priv(dev); 778 iface = netdev_priv(dev);
787 if (link->state & DEV_CONFIG) 779 prism2_hw_shutdown(dev, 0);
788 prism2_hw_shutdown(dev, 0);
789 iface->local->shutdown = 1; 780 iface->local->shutdown = 1;
790 } 781 }
791 782
@@ -797,19 +788,19 @@ static int hostap_cs_suspend(struct pcmcia_device *link)
797{ 788{
798 struct net_device *dev = (struct net_device *) link->priv; 789 struct net_device *dev = (struct net_device *) link->priv;
799 int dev_open = 0; 790 int dev_open = 0;
791 struct hostap_interface *iface = NULL;
800 792
801 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info); 793 if (dev)
794 iface = netdev_priv(dev);
802 795
803 if (link->state & DEV_CONFIG) { 796 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info);
804 struct hostap_interface *iface = netdev_priv(dev); 797 if (iface && iface->local)
805 if (iface && iface->local) 798 dev_open = iface->local->num_dev_open > 0;
806 dev_open = iface->local->num_dev_open > 0; 799 if (dev_open) {
807 if (dev_open) { 800 netif_stop_queue(dev);
808 netif_stop_queue(dev); 801 netif_device_detach(dev);
809 netif_device_detach(dev);
810 }
811 prism2_suspend(dev);
812 } 802 }
803 prism2_suspend(dev);
813 804
814 return 0; 805 return 0;
815} 806}
@@ -818,20 +809,21 @@ static int hostap_cs_resume(struct pcmcia_device *link)
818{ 809{
819 struct net_device *dev = (struct net_device *) link->priv; 810 struct net_device *dev = (struct net_device *) link->priv;
820 int dev_open = 0; 811 int dev_open = 0;
812 struct hostap_interface *iface = NULL;
813
814 if (dev)
815 iface = netdev_priv(dev);
821 816
822 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info); 817 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info);
823 818
824 if (link->state & DEV_CONFIG) { 819 if (iface && iface->local)
825 struct hostap_interface *iface = netdev_priv(dev); 820 dev_open = iface->local->num_dev_open > 0;
826 if (iface && iface->local)
827 dev_open = iface->local->num_dev_open > 0;
828 821
829 prism2_hw_shutdown(dev, 1); 822 prism2_hw_shutdown(dev, 1);
830 prism2_hw_config(dev, dev_open ? 0 : 1); 823 prism2_hw_config(dev, dev_open ? 0 : 1);
831 if (dev_open) { 824 if (dev_open) {
832 netif_device_attach(dev); 825 netif_device_attach(dev);
833 netif_start_queue(dev); 826 netif_start_queue(dev);
834 }
835 } 827 }
836 828
837 return 0; 829 return 0;
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index 2689f3bbc889..fbc8595cde39 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -428,7 +428,6 @@ static int netwave_probe(struct pcmcia_device *link)
428 dev->stop = &netwave_close; 428 dev->stop = &netwave_close;
429 link->irq.Instance = dev; 429 link->irq.Instance = dev;
430 430
431 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
432 return netwave_pcmcia_config( link); 431 return netwave_pcmcia_config( link);
433} /* netwave_attach */ 432} /* netwave_attach */
434 433
@@ -446,8 +445,7 @@ static void netwave_detach(struct pcmcia_device *link)
446 445
447 DEBUG(0, "netwave_detach(0x%p)\n", link); 446 DEBUG(0, "netwave_detach(0x%p)\n", link);
448 447
449 if (link->state & DEV_CONFIG) 448 netwave_release(link);
450 netwave_release(link);
451 449
452 if (link->dev_node) 450 if (link->dev_node)
453 unregister_netdev(dev); 451 unregister_netdev(dev);
@@ -763,9 +761,6 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) {
763 link->conf.ConfigBase = parse.config.base; 761 link->conf.ConfigBase = parse.config.base;
764 link->conf.Present = parse.config.rmask[0]; 762 link->conf.Present = parse.config.rmask[0];
765 763
766 /* Configure card */
767 link->state |= DEV_CONFIG;
768
769 /* 764 /*
770 * Try allocating IO ports. This tries a few fixed addresses. 765 * Try allocating IO ports. This tries a few fixed addresses.
771 * If you want, you can also read the card's config table to 766 * If you want, you can also read the card's config table to
@@ -823,7 +818,6 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) {
823 818
824 strcpy(priv->node.dev_name, dev->name); 819 strcpy(priv->node.dev_name, dev->name);
825 link->dev_node = &priv->node; 820 link->dev_node = &priv->node;
826 link->state &= ~DEV_CONFIG_PENDING;
827 821
828 /* Reset card before reading physical address */ 822 /* Reset card before reading physical address */
829 netwave_doreset(dev->base_addr, ramBase); 823 netwave_doreset(dev->base_addr, ramBase);
@@ -875,7 +869,7 @@ static int netwave_suspend(struct pcmcia_device *link)
875{ 869{
876 struct net_device *dev = link->priv; 870 struct net_device *dev = link->priv;
877 871
878 if ((link->state & DEV_CONFIG) && (link->open)) 872 if (link->open)
879 netif_device_detach(dev); 873 netif_device_detach(dev);
880 874
881 return 0; 875 return 0;
@@ -885,7 +879,7 @@ static int netwave_resume(struct pcmcia_device *link)
885{ 879{
886 struct net_device *dev = link->priv; 880 struct net_device *dev = link->priv;
887 881
888 if ((link->state & DEV_CONFIG) && (link->open)) { 882 if (link->open) {
889 netwave_reset(dev); 883 netwave_reset(dev);
890 netif_device_attach(dev); 884 netif_device_attach(dev);
891 } 885 }
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index 0e92bee16c9b..434f7d7ad841 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -134,7 +134,6 @@ orinoco_cs_probe(struct pcmcia_device *link)
134 link->conf.Attributes = 0; 134 link->conf.Attributes = 0;
135 link->conf.IntType = INT_MEMORY_AND_IO; 135 link->conf.IntType = INT_MEMORY_AND_IO;
136 136
137 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
138 return orinoco_cs_config(link); 137 return orinoco_cs_config(link);
139} /* orinoco_cs_attach */ 138} /* orinoco_cs_attach */
140 139
@@ -148,8 +147,7 @@ static void orinoco_cs_detach(struct pcmcia_device *link)
148{ 147{
149 struct net_device *dev = link->priv; 148 struct net_device *dev = link->priv;
150 149
151 if (link->state & DEV_CONFIG) 150 orinoco_cs_release(link);
152 orinoco_cs_release(link);
153 151
154 DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node); 152 DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node);
155 if (link->dev_node) { 153 if (link->dev_node) {
@@ -202,9 +200,6 @@ orinoco_cs_config(struct pcmcia_device *link)
202 link->conf.ConfigBase = parse.config.base; 200 link->conf.ConfigBase = parse.config.base;
203 link->conf.Present = parse.config.rmask[0]; 201 link->conf.Present = parse.config.rmask[0];
204 202
205 /* Configure card */
206 link->state |= DEV_CONFIG;
207
208 /* Look up the current Vcc */ 203 /* Look up the current Vcc */
209 CS_CHECK(GetConfigurationInfo, 204 CS_CHECK(GetConfigurationInfo,
210 pcmcia_get_configuration_info(link, &conf)); 205 pcmcia_get_configuration_info(link, &conf));
@@ -358,7 +353,6 @@ orinoco_cs_config(struct pcmcia_device *link)
358 link->dev_node = &card->node; /* link->dev_node being non-NULL is also 353 link->dev_node = &card->node; /* link->dev_node being non-NULL is also
359 used to indicate that the 354 used to indicate that the
360 net_device has been registered */ 355 net_device has been registered */
361 link->state &= ~DEV_CONFIG_PENDING;
362 356
363 /* Finally, report what we've done */ 357 /* Finally, report what we've done */
364 printk(KERN_DEBUG "%s: index 0x%02x: ", 358 printk(KERN_DEBUG "%s: index 0x%02x: ",
@@ -416,23 +410,21 @@ static int orinoco_cs_suspend(struct pcmcia_device *link)
416 int err = 0; 410 int err = 0;
417 unsigned long flags; 411 unsigned long flags;
418 412
419 if (link->state & DEV_CONFIG) { 413 /* This is probably racy, but I can't think of
420 /* This is probably racy, but I can't think of 414 a better way, short of rewriting the PCMCIA
421 a better way, short of rewriting the PCMCIA 415 layer to not suck :-( */
422 layer to not suck :-( */ 416 if (! test_bit(0, &card->hard_reset_in_progress)) {
423 if (! test_bit(0, &card->hard_reset_in_progress)) { 417 spin_lock_irqsave(&priv->lock, flags);
424 spin_lock_irqsave(&priv->lock, flags);
425 418
426 err = __orinoco_down(dev); 419 err = __orinoco_down(dev);
427 if (err) 420 if (err)
428 printk(KERN_WARNING "%s: Error %d downing interface\n", 421 printk(KERN_WARNING "%s: Error %d downing interface\n",
429 dev->name, err); 422 dev->name, err);
430 423
431 netif_device_detach(dev); 424 netif_device_detach(dev);
432 priv->hw_unavailable++; 425 priv->hw_unavailable++;
433 426
434 spin_unlock_irqrestore(&priv->lock, flags); 427 spin_unlock_irqrestore(&priv->lock, flags);
435 }
436 } 428 }
437 429
438 return 0; 430 return 0;
@@ -446,29 +438,27 @@ static int orinoco_cs_resume(struct pcmcia_device *link)
446 int err = 0; 438 int err = 0;
447 unsigned long flags; 439 unsigned long flags;
448 440
449 if (link->state & DEV_CONFIG) { 441 if (! test_bit(0, &card->hard_reset_in_progress)) {
450 if (! test_bit(0, &card->hard_reset_in_progress)) { 442 err = orinoco_reinit_firmware(dev);
451 err = orinoco_reinit_firmware(dev); 443 if (err) {
452 if (err) { 444 printk(KERN_ERR "%s: Error %d re-initializing firmware\n",
453 printk(KERN_ERR "%s: Error %d re-initializing firmware\n", 445 dev->name, err);
454 dev->name, err); 446 return -EIO;
455 return -EIO; 447 }
456 }
457
458 spin_lock_irqsave(&priv->lock, flags);
459 448
460 netif_device_attach(dev); 449 spin_lock_irqsave(&priv->lock, flags);
461 priv->hw_unavailable--;
462 450
463 if (priv->open && ! priv->hw_unavailable) { 451 netif_device_attach(dev);
464 err = __orinoco_up(dev); 452 priv->hw_unavailable--;
465 if (err)
466 printk(KERN_ERR "%s: Error %d restarting card\n",
467 dev->name, err);
468 }
469 453
470 spin_unlock_irqrestore(&priv->lock, flags); 454 if (priv->open && ! priv->hw_unavailable) {
455 err = __orinoco_up(dev);
456 if (err)
457 printk(KERN_ERR "%s: Error %d restarting card\n",
458 dev->name, err);
471 } 459 }
460
461 spin_unlock_irqrestore(&priv->lock, flags);
472 } 462 }
473 463
474 return 0; 464 return 0;
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index e3924339fabe..85712ffb842a 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -366,7 +366,6 @@ static int ray_probe(struct pcmcia_device *p_dev)
366 366
367 init_timer(&local->timer); 367 init_timer(&local->timer);
368 368
369 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
370 this_device = p_dev; 369 this_device = p_dev;
371 return ray_config(p_dev); 370 return ray_config(p_dev);
372 371
@@ -389,12 +388,10 @@ static void ray_detach(struct pcmcia_device *link)
389 this_device = NULL; 388 this_device = NULL;
390 dev = link->priv; 389 dev = link->priv;
391 390
392 if (link->state & DEV_CONFIG) { 391 ray_release(link);
393 ray_release(link);
394 392
395 local = (ray_dev_t *)dev->priv; 393 local = (ray_dev_t *)dev->priv;
396 del_timer(&local->timer); 394 del_timer(&local->timer);
397 }
398 395
399 if (link->priv) { 396 if (link->priv) {
400 if (link->dev_node) unregister_netdev(dev); 397 if (link->dev_node) unregister_netdev(dev);
@@ -448,9 +445,6 @@ static int ray_config(struct pcmcia_device *link)
448 if (buf[i] == 0) buf[i] = ' '; 445 if (buf[i] == 0) buf[i] = ' ';
449 printk(KERN_INFO "ray_cs Detected: %s\n",buf); 446 printk(KERN_INFO "ray_cs Detected: %s\n",buf);
450 447
451 /* Configure card */
452 link->state |= DEV_CONFIG;
453
454 /* Now allocate an interrupt line. Note that this does not 448 /* Now allocate an interrupt line. Note that this does not
455 actually assign a handler to the interrupt. 449 actually assign a handler to the interrupt.
456 */ 450 */
@@ -511,7 +505,6 @@ static int ray_config(struct pcmcia_device *link)
511 strcpy(local->node.dev_name, dev->name); 505 strcpy(local->node.dev_name, dev->name);
512 link->dev_node = &local->node; 506 link->dev_node = &local->node;
513 507
514 link->state &= ~DEV_CONFIG_PENDING;
515 printk(KERN_INFO "%s: RayLink, irq %d, hw_addr ", 508 printk(KERN_INFO "%s: RayLink, irq %d, hw_addr ",
516 dev->name, dev->irq); 509 dev->name, dev->irq);
517 for (i = 0; i < 6; i++) 510 for (i = 0; i < 6; i++)
@@ -552,7 +545,7 @@ static int ray_init(struct net_device *dev)
552 ray_dev_t *local = (ray_dev_t *)dev->priv; 545 ray_dev_t *local = (ray_dev_t *)dev->priv;
553 struct pcmcia_device *link = local->finder; 546 struct pcmcia_device *link = local->finder;
554 DEBUG(1, "ray_init(0x%p)\n", dev); 547 DEBUG(1, "ray_init(0x%p)\n", dev);
555 if (!(link->state & DEV_PRESENT)) { 548 if (!(pcmcia_dev_present(link))) {
556 DEBUG(0,"ray_init - device not present\n"); 549 DEBUG(0,"ray_init - device not present\n");
557 return -1; 550 return -1;
558 } 551 }
@@ -615,7 +608,7 @@ static int dl_startup_params(struct net_device *dev)
615 struct pcmcia_device *link = local->finder; 608 struct pcmcia_device *link = local->finder;
616 609
617 DEBUG(1,"dl_startup_params entered\n"); 610 DEBUG(1,"dl_startup_params entered\n");
618 if (!(link->state & DEV_PRESENT)) { 611 if (!(pcmcia_dev_present(link))) {
619 DEBUG(2,"ray_cs dl_startup_params - device not present\n"); 612 DEBUG(2,"ray_cs dl_startup_params - device not present\n");
620 return -1; 613 return -1;
621 } 614 }
@@ -721,7 +714,7 @@ static void verify_dl_startup(u_long data)
721 UCHAR status; 714 UCHAR status;
722 struct pcmcia_device *link = local->finder; 715 struct pcmcia_device *link = local->finder;
723 716
724 if (!(link->state & DEV_PRESENT)) { 717 if (!(pcmcia_dev_present(link))) {
725 DEBUG(2,"ray_cs verify_dl_startup - device not present\n"); 718 DEBUG(2,"ray_cs verify_dl_startup - device not present\n");
726 return; 719 return;
727 } 720 }
@@ -760,7 +753,7 @@ static void start_net(u_long data)
760 struct ccs __iomem *pccs; 753 struct ccs __iomem *pccs;
761 int ccsindex; 754 int ccsindex;
762 struct pcmcia_device *link = local->finder; 755 struct pcmcia_device *link = local->finder;
763 if (!(link->state & DEV_PRESENT)) { 756 if (!(pcmcia_dev_present(link))) {
764 DEBUG(2,"ray_cs start_net - device not present\n"); 757 DEBUG(2,"ray_cs start_net - device not present\n");
765 return; 758 return;
766 } 759 }
@@ -788,7 +781,7 @@ static void join_net(u_long data)
788 int ccsindex; 781 int ccsindex;
789 struct pcmcia_device *link = local->finder; 782 struct pcmcia_device *link = local->finder;
790 783
791 if (!(link->state & DEV_PRESENT)) { 784 if (!(pcmcia_dev_present(link))) {
792 DEBUG(2,"ray_cs join_net - device not present\n"); 785 DEBUG(2,"ray_cs join_net - device not present\n");
793 return; 786 return;
794 } 787 }
@@ -839,7 +832,7 @@ static int ray_suspend(struct pcmcia_device *link)
839{ 832{
840 struct net_device *dev = link->priv; 833 struct net_device *dev = link->priv;
841 834
842 if ((link->state & DEV_CONFIG) && (link->open)) 835 if (link->open)
843 netif_device_detach(dev); 836 netif_device_detach(dev);
844 837
845 return 0; 838 return 0;
@@ -849,7 +842,7 @@ static int ray_resume(struct pcmcia_device *link)
849{ 842{
850 struct net_device *dev = link->priv; 843 struct net_device *dev = link->priv;
851 844
852 if ((link->state & DEV_CONFIG) && (link->open)) { 845 if (link->open) {
853 ray_reset(dev); 846 ray_reset(dev);
854 netif_device_attach(dev); 847 netif_device_attach(dev);
855 } 848 }
@@ -867,7 +860,7 @@ int ray_dev_init(struct net_device *dev)
867 struct pcmcia_device *link = local->finder; 860 struct pcmcia_device *link = local->finder;
868 861
869 DEBUG(1,"ray_dev_init(dev=%p)\n",dev); 862 DEBUG(1,"ray_dev_init(dev=%p)\n",dev);
870 if (!(link->state & DEV_PRESENT)) { 863 if (!(pcmcia_dev_present(link))) {
871 DEBUG(2,"ray_dev_init - device not present\n"); 864 DEBUG(2,"ray_dev_init - device not present\n");
872 return -1; 865 return -1;
873 } 866 }
@@ -901,7 +894,7 @@ static int ray_dev_config(struct net_device *dev, struct ifmap *map)
901 struct pcmcia_device *link = local->finder; 894 struct pcmcia_device *link = local->finder;
902 /* Dummy routine to satisfy device structure */ 895 /* Dummy routine to satisfy device structure */
903 DEBUG(1,"ray_dev_config(dev=%p,ifmap=%p)\n",dev,map); 896 DEBUG(1,"ray_dev_config(dev=%p,ifmap=%p)\n",dev,map);
904 if (!(link->state & DEV_PRESENT)) { 897 if (!(pcmcia_dev_present(link))) {
905 DEBUG(2,"ray_dev_config - device not present\n"); 898 DEBUG(2,"ray_dev_config - device not present\n");
906 return -1; 899 return -1;
907 } 900 }
@@ -915,7 +908,7 @@ static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev)
915 struct pcmcia_device *link = local->finder; 908 struct pcmcia_device *link = local->finder;
916 short length = skb->len; 909 short length = skb->len;
917 910
918 if (!(link->state & DEV_PRESENT)) { 911 if (!(pcmcia_dev_present(link))) {
919 DEBUG(2,"ray_dev_start_xmit - device not present\n"); 912 DEBUG(2,"ray_dev_start_xmit - device not present\n");
920 return -1; 913 return -1;
921 } 914 }
@@ -1542,7 +1535,7 @@ static iw_stats * ray_get_wireless_stats(struct net_device * dev)
1542 } 1535 }
1543#endif /* WIRELESS_SPY */ 1536#endif /* WIRELESS_SPY */
1544 1537
1545 if((link->state & DEV_PRESENT)) { 1538 if(pcmcia_dev_present(link)) {
1546 local->wstats.qual.noise = readb(&p->rxnoise); 1539 local->wstats.qual.noise = readb(&p->rxnoise);
1547 local->wstats.qual.updated |= 4; 1540 local->wstats.qual.updated |= 4;
1548 } 1541 }
@@ -1674,7 +1667,7 @@ static int interrupt_ecf(ray_dev_t *local, int ccs)
1674 int i = 50; 1667 int i = 50;
1675 struct pcmcia_device *link = local->finder; 1668 struct pcmcia_device *link = local->finder;
1676 1669
1677 if (!(link->state & DEV_PRESENT)) { 1670 if (!(pcmcia_dev_present(link))) {
1678 DEBUG(2,"ray_cs interrupt_ecf - device not present\n"); 1671 DEBUG(2,"ray_cs interrupt_ecf - device not present\n");
1679 return -1; 1672 return -1;
1680 } 1673 }
@@ -1701,7 +1694,7 @@ static int get_free_tx_ccs(ray_dev_t *local)
1701 struct ccs __iomem *pccs = ccs_base(local); 1694 struct ccs __iomem *pccs = ccs_base(local);
1702 struct pcmcia_device *link = local->finder; 1695 struct pcmcia_device *link = local->finder;
1703 1696
1704 if (!(link->state & DEV_PRESENT)) { 1697 if (!(pcmcia_dev_present(link))) {
1705 DEBUG(2,"ray_cs get_free_tx_ccs - device not present\n"); 1698 DEBUG(2,"ray_cs get_free_tx_ccs - device not present\n");
1706 return ECARDGONE; 1699 return ECARDGONE;
1707 } 1700 }
@@ -1732,7 +1725,7 @@ static int get_free_ccs(ray_dev_t *local)
1732 struct ccs __iomem *pccs = ccs_base(local); 1725 struct ccs __iomem *pccs = ccs_base(local);
1733 struct pcmcia_device *link = local->finder; 1726 struct pcmcia_device *link = local->finder;
1734 1727
1735 if (!(link->state & DEV_PRESENT)) { 1728 if (!(pcmcia_dev_present(link))) {
1736 DEBUG(2,"ray_cs get_free_ccs - device not present\n"); 1729 DEBUG(2,"ray_cs get_free_ccs - device not present\n");
1737 return ECARDGONE; 1730 return ECARDGONE;
1738 } 1731 }
@@ -1807,7 +1800,7 @@ static struct net_device_stats *ray_get_stats(struct net_device *dev)
1807 ray_dev_t *local = (ray_dev_t *)dev->priv; 1800 ray_dev_t *local = (ray_dev_t *)dev->priv;
1808 struct pcmcia_device *link = local->finder; 1801 struct pcmcia_device *link = local->finder;
1809 struct status __iomem *p = local->sram + STATUS_BASE; 1802 struct status __iomem *p = local->sram + STATUS_BASE;
1810 if (!(link->state & DEV_PRESENT)) { 1803 if (!(pcmcia_dev_present(link))) {
1811 DEBUG(2,"ray_cs net_device_stats - device not present\n"); 1804 DEBUG(2,"ray_cs net_device_stats - device not present\n");
1812 return &local->stats; 1805 return &local->stats;
1813 } 1806 }
@@ -1840,7 +1833,7 @@ static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value, i
1840 int i; 1833 int i;
1841 struct ccs __iomem *pccs; 1834 struct ccs __iomem *pccs;
1842 1835
1843 if (!(link->state & DEV_PRESENT)) { 1836 if (!(pcmcia_dev_present(link))) {
1844 DEBUG(2,"ray_update_parm - device not present\n"); 1837 DEBUG(2,"ray_update_parm - device not present\n");
1845 return; 1838 return;
1846 } 1839 }
@@ -1875,7 +1868,7 @@ static void ray_update_multi_list(struct net_device *dev, int all)
1875 struct pcmcia_device *link = local->finder; 1868 struct pcmcia_device *link = local->finder;
1876 void __iomem *p = local->sram + HOST_TO_ECF_BASE; 1869 void __iomem *p = local->sram + HOST_TO_ECF_BASE;
1877 1870
1878 if (!(link->state & DEV_PRESENT)) { 1871 if (!(pcmcia_dev_present(link))) {
1879 DEBUG(2,"ray_update_multi_list - device not present\n"); 1872 DEBUG(2,"ray_update_multi_list - device not present\n");
1880 return; 1873 return;
1881 } 1874 }
@@ -1968,7 +1961,7 @@ static irqreturn_t ray_interrupt(int irq, void *dev_id, struct pt_regs * regs)
1968 1961
1969 local = (ray_dev_t *)dev->priv; 1962 local = (ray_dev_t *)dev->priv;
1970 link = (struct pcmcia_device *)local->finder; 1963 link = (struct pcmcia_device *)local->finder;
1971 if ( ! (link->state & DEV_PRESENT) || link->suspended ) { 1964 if (!(pcmcia_dev_present(link)) || link->suspended ) {
1972 DEBUG(2,"ray_cs interrupt from device not present or suspended.\n"); 1965 DEBUG(2,"ray_cs interrupt from device not present or suspended.\n");
1973 return IRQ_NONE; 1966 return IRQ_NONE;
1974 } 1967 }
@@ -2489,7 +2482,7 @@ static void authenticate(ray_dev_t *local)
2489{ 2482{
2490 struct pcmcia_device *link = local->finder; 2483 struct pcmcia_device *link = local->finder;
2491 DEBUG(0,"ray_cs Starting authentication.\n"); 2484 DEBUG(0,"ray_cs Starting authentication.\n");
2492 if (!(link->state & DEV_PRESENT)) { 2485 if (!(pcmcia_dev_present(link))) {
2493 DEBUG(2,"ray_cs authenticate - device not present\n"); 2486 DEBUG(2,"ray_cs authenticate - device not present\n");
2494 return; 2487 return;
2495 } 2488 }
@@ -2556,7 +2549,7 @@ static void associate(ray_dev_t *local)
2556 struct pcmcia_device *link = local->finder; 2549 struct pcmcia_device *link = local->finder;
2557 struct net_device *dev = link->priv; 2550 struct net_device *dev = link->priv;
2558 int ccsindex; 2551 int ccsindex;
2559 if (!(link->state & DEV_PRESENT)) { 2552 if (!(pcmcia_dev_present(link))) {
2560 DEBUG(2,"ray_cs associate - device not present\n"); 2553 DEBUG(2,"ray_cs associate - device not present\n");
2561 return; 2554 return;
2562 } 2555 }
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index 118b2c6e5a29..f7b77ce54d7b 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -245,7 +245,7 @@ spectrum_reset(struct pcmcia_device *link, int idle)
245 u_int save_cor; 245 u_int save_cor;
246 246
247 /* Doing it if hardware is gone is guaranteed crash */ 247 /* Doing it if hardware is gone is guaranteed crash */
248 if (!(link->state & DEV_CONFIG)) 248 if (pcmcia_dev_present(link))
249 return -ENODEV; 249 return -ENODEV;
250 250
251 /* Save original COR value */ 251 /* Save original COR value */
@@ -613,7 +613,6 @@ spectrum_cs_probe(struct pcmcia_device *link)
613 link->conf.Attributes = 0; 613 link->conf.Attributes = 0;
614 link->conf.IntType = INT_MEMORY_AND_IO; 614 link->conf.IntType = INT_MEMORY_AND_IO;
615 615
616 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
617 return spectrum_cs_config(link); 616 return spectrum_cs_config(link);
618} /* spectrum_cs_attach */ 617} /* spectrum_cs_attach */
619 618
@@ -627,8 +626,7 @@ static void spectrum_cs_detach(struct pcmcia_device *link)
627{ 626{
628 struct net_device *dev = link->priv; 627 struct net_device *dev = link->priv;
629 628
630 if (link->state & DEV_CONFIG) 629 spectrum_cs_release(link);
631 spectrum_cs_release(link);
632 630
633 DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node); 631 DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node);
634 if (link->dev_node) { 632 if (link->dev_node) {
@@ -677,9 +675,6 @@ spectrum_cs_config(struct pcmcia_device *link)
677 link->conf.ConfigBase = parse.config.base; 675 link->conf.ConfigBase = parse.config.base;
678 link->conf.Present = parse.config.rmask[0]; 676 link->conf.Present = parse.config.rmask[0];
679 677
680 /* Configure card */
681 link->state |= DEV_CONFIG;
682
683 /* Look up the current Vcc */ 678 /* Look up the current Vcc */
684 CS_CHECK(GetConfigurationInfo, 679 CS_CHECK(GetConfigurationInfo,
685 pcmcia_get_configuration_info(link, &conf)); 680 pcmcia_get_configuration_info(link, &conf));
@@ -838,7 +833,6 @@ spectrum_cs_config(struct pcmcia_device *link)
838 link->dev_node = &card->node; /* link->dev_node being non-NULL is also 833 link->dev_node = &card->node; /* link->dev_node being non-NULL is also
839 used to indicate that the 834 used to indicate that the
840 net_device has been registered */ 835 net_device has been registered */
841 link->state &= ~DEV_CONFIG_PENDING;
842 836
843 /* Finally, report what we've done */ 837 /* Finally, report what we've done */
844 printk(KERN_DEBUG "%s: index 0x%02x: ", 838 printk(KERN_DEBUG "%s: index 0x%02x: ",
@@ -898,19 +892,17 @@ spectrum_cs_suspend(struct pcmcia_device *link)
898 int err = 0; 892 int err = 0;
899 893
900 /* Mark the device as stopped, to block IO until later */ 894 /* Mark the device as stopped, to block IO until later */
901 if (link->state & DEV_CONFIG) { 895 spin_lock_irqsave(&priv->lock, flags);
902 spin_lock_irqsave(&priv->lock, flags);
903 896
904 err = __orinoco_down(dev); 897 err = __orinoco_down(dev);
905 if (err) 898 if (err)
906 printk(KERN_WARNING "%s: Error %d downing interface\n", 899 printk(KERN_WARNING "%s: Error %d downing interface\n",
907 dev->name, err); 900 dev->name, err);
908 901
909 netif_device_detach(dev); 902 netif_device_detach(dev);
910 priv->hw_unavailable++; 903 priv->hw_unavailable++;
911 904
912 spin_unlock_irqrestore(&priv->lock, flags); 905 spin_unlock_irqrestore(&priv->lock, flags);
913 }
914 906
915 return 0; 907 return 0;
916} 908}
@@ -921,11 +913,10 @@ spectrum_cs_resume(struct pcmcia_device *link)
921 struct net_device *dev = link->priv; 913 struct net_device *dev = link->priv;
922 struct orinoco_private *priv = netdev_priv(dev); 914 struct orinoco_private *priv = netdev_priv(dev);
923 915
924 if (link->state & DEV_CONFIG) { 916 netif_device_attach(dev);
925 netif_device_attach(dev); 917 priv->hw_unavailable--;
926 priv->hw_unavailable--; 918 schedule_work(&priv->reset_work);
927 schedule_work(&priv->reset_work); 919
928 }
929 return 0; 920 return 0;
930} 921}
931 922
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index 6b6769654777..f7724eb2fa7e 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -3983,12 +3983,9 @@ wv_pcmcia_config(struct pcmcia_device * link)
3983 if(i != CS_SUCCESS) 3983 if(i != CS_SUCCESS)
3984 { 3984 {
3985 cs_error(link, ParseTuple, i); 3985 cs_error(link, ParseTuple, i);
3986 link->state &= ~DEV_CONFIG_PENDING;
3987 return FALSE; 3986 return FALSE;
3988 } 3987 }
3989 3988
3990 /* Configure card */
3991 link->state |= DEV_CONFIG;
3992 do 3989 do
3993 { 3990 {
3994 i = pcmcia_request_io(link, &link->io); 3991 i = pcmcia_request_io(link, &link->io);
@@ -4071,7 +4068,6 @@ wv_pcmcia_config(struct pcmcia_device * link)
4071 } 4068 }
4072 while(0); /* Humm... Disguised goto !!! */ 4069 while(0); /* Humm... Disguised goto !!! */
4073 4070
4074 link->state &= ~DEV_CONFIG_PENDING;
4075 /* If any step failed, release any partially configured state */ 4071 /* If any step failed, release any partially configured state */
4076 if(i != 0) 4072 if(i != 0)
4077 { 4073 {
@@ -4651,7 +4647,6 @@ wavelan_probe(struct pcmcia_device *p_dev)
4651 /* Other specific data */ 4647 /* Other specific data */
4652 dev->mtu = WAVELAN_MTU; 4648 dev->mtu = WAVELAN_MTU;
4653 4649
4654 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
4655 ret = wv_pcmcia_config(p_dev); 4650 ret = wv_pcmcia_config(p_dev);
4656 if (ret) 4651 if (ret)
4657 return ret; 4652 return ret;
@@ -4686,17 +4681,8 @@ wavelan_detach(struct pcmcia_device *link)
4686 printk(KERN_DEBUG "-> wavelan_detach(0x%p)\n", link); 4681 printk(KERN_DEBUG "-> wavelan_detach(0x%p)\n", link);
4687#endif 4682#endif
4688 4683
4689 /* 4684 /* Some others haven't done their job : give them another chance */
4690 * If the device is currently configured and active, we won't 4685 wv_pcmcia_release(link);
4691 * actually delete it yet. Instead, it is marked so that when the
4692 * release() function is called, that will trigger a proper
4693 * detach().
4694 */
4695 if(link->state & DEV_CONFIG)
4696 {
4697 /* Some others haven't done their job : give them another chance */
4698 wv_pcmcia_release(link);
4699 }
4700 4686
4701 /* Free pieces */ 4687 /* Free pieces */
4702 if(link->priv) 4688 if(link->priv)
@@ -4731,7 +4717,7 @@ static int wavelan_suspend(struct pcmcia_device *link)
4731 /* Stop receiving new messages and wait end of transmission */ 4717 /* Stop receiving new messages and wait end of transmission */
4732 wv_ru_stop(dev); 4718 wv_ru_stop(dev);
4733 4719
4734 if ((link->state & DEV_CONFIG) && (link->open)) 4720 if (link->open)
4735 netif_device_detach(dev); 4721 netif_device_detach(dev);
4736 4722
4737 /* Power down the module */ 4723 /* Power down the module */
@@ -4744,7 +4730,7 @@ static int wavelan_resume(struct pcmcia_device *link)
4744{ 4730{
4745 struct net_device * dev = (struct net_device *) link->priv; 4731 struct net_device * dev = (struct net_device *) link->priv;
4746 4732
4747 if ((link->state & DEV_CONFIG) && (link->open)) { 4733 if (link->open) {
4748 wv_hw_reset(dev); 4734 wv_hw_reset(dev);
4749 netif_device_attach(dev); 4735 netif_device_attach(dev);
4750 } 4736 }
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index 6b3a605897bd..b6578059de34 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -1485,13 +1485,11 @@ static void wl3501_detach(struct pcmcia_device *link)
1485 * delete it yet. Instead, it is marked so that when the release() 1485 * delete it yet. Instead, it is marked so that when the release()
1486 * function is called, that will trigger a proper detach(). */ 1486 * function is called, that will trigger a proper detach(). */
1487 1487
1488 if (link->state & DEV_CONFIG) { 1488 while (link->open > 0)
1489 while (link->open > 0) 1489 wl3501_close(dev);
1490 wl3501_close(dev);
1491 1490
1492 netif_device_detach(dev); 1491 netif_device_detach(dev);
1493 wl3501_release(link); 1492 wl3501_release(link);
1494 }
1495 1493
1496 if (link->priv) 1494 if (link->priv)
1497 free_netdev(link->priv); 1495 free_netdev(link->priv);
@@ -1959,7 +1957,6 @@ static int wl3501_probe(struct pcmcia_device *p_dev)
1959 netif_stop_queue(dev); 1957 netif_stop_queue(dev);
1960 p_dev->priv = p_dev->irq.Instance = dev; 1958 p_dev->priv = p_dev->irq.Instance = dev;
1961 1959
1962 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1963 return wl3501_config(p_dev); 1960 return wl3501_config(p_dev);
1964out_link: 1961out_link:
1965 return -ENOMEM; 1962 return -ENOMEM;
@@ -1997,9 +1994,6 @@ static int wl3501_config(struct pcmcia_device *link)
1997 link->conf.ConfigBase = parse.config.base; 1994 link->conf.ConfigBase = parse.config.base;
1998 link->conf.Present = parse.config.rmask[0]; 1995 link->conf.Present = parse.config.rmask[0];
1999 1996
2000 /* Configure card */
2001 link->state |= DEV_CONFIG;
2002
2003 /* Try allocating IO ports. This tries a few fixed addresses. If you 1997 /* Try allocating IO ports. This tries a few fixed addresses. If you
2004 * want, you can also read the card's config table to pick addresses -- 1998 * want, you can also read the card's config table to pick addresses --
2005 * see the serial driver for an example. */ 1999 * see the serial driver for an example. */
@@ -2044,7 +2038,6 @@ static int wl3501_config(struct pcmcia_device *link)
2044 * arranged in a linked list at link->dev_node. 2038 * arranged in a linked list at link->dev_node.
2045 */ 2039 */
2046 link->dev_node = &this->node; 2040 link->dev_node = &this->node;
2047 link->state &= ~DEV_CONFIG_PENDING;
2048 2041
2049 this->base_addr = dev->base_addr; 2042 this->base_addr = dev->base_addr;
2050 2043
@@ -2113,7 +2106,7 @@ static int wl3501_suspend(struct pcmcia_device *link)
2113 struct net_device *dev = link->priv; 2106 struct net_device *dev = link->priv;
2114 2107
2115 wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND); 2108 wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND);
2116 if ((link->state & DEV_CONFIG) && (link->open)) 2109 if (link->open)
2117 netif_device_detach(dev); 2110 netif_device_detach(dev);
2118 2111
2119 return 0; 2112 return 0;
@@ -2124,7 +2117,7 @@ static int wl3501_resume(struct pcmcia_device *link)
2124 struct net_device *dev = link->priv; 2117 struct net_device *dev = link->priv;
2125 2118
2126 wl3501_pwr_mgmt(dev->priv, WL3501_RESUME); 2119 wl3501_pwr_mgmt(dev->priv, WL3501_RESUME);
2127 if ((link->state & DEV_CONFIG) && (link->open)) { 2120 if (link->open) {
2128 wl3501_reset(dev); 2121 wl3501_reset(dev);
2129 netif_device_attach(dev); 2122 netif_device_attach(dev);
2130 } 2123 }