aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/pcmcia/3c574_cs.c12
-rw-r--r--drivers/net/pcmcia/3c589_cs.c12
-rw-r--r--drivers/net/pcmcia/axnet_cs.c15
-rw-r--r--drivers/net/pcmcia/com20020_cs.c12
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c13
-rw-r--r--drivers/net/pcmcia/ibmtr_cs.c14
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c13
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c13
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c59
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c18
-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
19 files changed, 173 insertions, 320 deletions
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 4611469fdff9..70e3cca09787 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -296,7 +296,6 @@ static int tc574_probe(struct pcmcia_device *link)
296 dev->watchdog_timeo = TX_TIMEOUT; 296 dev->watchdog_timeo = TX_TIMEOUT;
297#endif 297#endif
298 298
299 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
300 return tc574_config(link); 299 return tc574_config(link);
301} /* tc574_attach */ 300} /* tc574_attach */
302 301
@@ -318,8 +317,7 @@ static void tc574_detach(struct pcmcia_device *link)
318 if (link->dev_node) 317 if (link->dev_node)
319 unregister_netdev(dev); 318 unregister_netdev(dev);
320 319
321 if (link->state & DEV_CONFIG) 320 tc574_release(link);
322 tc574_release(link);
323 321
324 free_netdev(dev); 322 free_netdev(dev);
325} /* tc574_detach */ 323} /* tc574_detach */
@@ -363,9 +361,6 @@ static int tc574_config(struct pcmcia_device *link)
363 link->conf.ConfigBase = parse.config.base; 361 link->conf.ConfigBase = parse.config.base;
364 link->conf.Present = parse.config.rmask[0]; 362 link->conf.Present = parse.config.rmask[0];
365 363
366 /* Configure card */
367 link->state |= DEV_CONFIG;
368
369 link->io.IOAddrLines = 16; 364 link->io.IOAddrLines = 16;
370 for (i = j = 0; j < 0x400; j += 0x20) { 365 for (i = j = 0; j < 0x400; j += 0x20) {
371 link->io.BasePort1 = j ^ 0x300; 366 link->io.BasePort1 = j ^ 0x300;
@@ -464,7 +459,6 @@ static int tc574_config(struct pcmcia_device *link)
464 } 459 }
465 } 460 }
466 461
467 link->state &= ~DEV_CONFIG_PENDING;
468 link->dev_node = &lp->node; 462 link->dev_node = &lp->node;
469 SET_NETDEV_DEV(dev, &handle_to_dev(link)); 463 SET_NETDEV_DEV(dev, &handle_to_dev(link));
470 464
@@ -509,7 +503,7 @@ static int tc574_suspend(struct pcmcia_device *link)
509{ 503{
510 struct net_device *dev = link->priv; 504 struct net_device *dev = link->priv;
511 505
512 if ((link->state & DEV_CONFIG) && (link->open)) 506 if (link->open)
513 netif_device_detach(dev); 507 netif_device_detach(dev);
514 508
515 return 0; 509 return 0;
@@ -519,7 +513,7 @@ static int tc574_resume(struct pcmcia_device *link)
519{ 513{
520 struct net_device *dev = link->priv; 514 struct net_device *dev = link->priv;
521 515
522 if ((link->state & DEV_CONFIG) && (link->open)) { 516 if (link->open) {
523 tc574_reset(dev); 517 tc574_reset(dev);
524 netif_device_attach(dev); 518 netif_device_attach(dev);
525 } 519 }
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index 160d48a8ed88..3d05f66e9c70 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -211,7 +211,6 @@ static int tc589_probe(struct pcmcia_device *link)
211#endif 211#endif
212 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 212 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
213 213
214 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
215 return tc589_config(link); 214 return tc589_config(link);
216} /* tc589_attach */ 215} /* tc589_attach */
217 216
@@ -233,8 +232,7 @@ static void tc589_detach(struct pcmcia_device *link)
233 if (link->dev_node) 232 if (link->dev_node)
234 unregister_netdev(dev); 233 unregister_netdev(dev);
235 234
236 if (link->state & DEV_CONFIG) 235 tc589_release(link);
237 tc589_release(link);
238 236
239 free_netdev(dev); 237 free_netdev(dev);
240} /* tc589_detach */ 238} /* tc589_detach */
@@ -285,9 +283,6 @@ static int tc589_config(struct pcmcia_device *link)
285 "3Com card??\n"); 283 "3Com card??\n");
286 multi = (le16_to_cpu(buf[1]) == PRODID_3COM_3C562); 284 multi = (le16_to_cpu(buf[1]) == PRODID_3COM_3C562);
287 } 285 }
288
289 /* Configure card */
290 link->state |= DEV_CONFIG;
291 286
292 /* For the 3c562, the base address must be xx00-xx7f */ 287 /* For the 3c562, the base address must be xx00-xx7f */
293 link->io.IOAddrLines = 16; 288 link->io.IOAddrLines = 16;
@@ -338,7 +333,6 @@ static int tc589_config(struct pcmcia_device *link)
338 printk(KERN_ERR "3c589_cs: invalid if_port requested\n"); 333 printk(KERN_ERR "3c589_cs: invalid if_port requested\n");
339 334
340 link->dev_node = &lp->node; 335 link->dev_node = &lp->node;
341 link->state &= ~DEV_CONFIG_PENDING;
342 SET_NETDEV_DEV(dev, &handle_to_dev(link)); 336 SET_NETDEV_DEV(dev, &handle_to_dev(link));
343 337
344 if (register_netdev(dev) != 0) { 338 if (register_netdev(dev) != 0) {
@@ -383,7 +377,7 @@ static int tc589_suspend(struct pcmcia_device *link)
383{ 377{
384 struct net_device *dev = link->priv; 378 struct net_device *dev = link->priv;
385 379
386 if ((link->state & DEV_CONFIG) && (link->open)) 380 if (link->open)
387 netif_device_detach(dev); 381 netif_device_detach(dev);
388 382
389 return 0; 383 return 0;
@@ -393,7 +387,7 @@ static int tc589_resume(struct pcmcia_device *link)
393{ 387{
394 struct net_device *dev = link->priv; 388 struct net_device *dev = link->priv;
395 389
396 if ((link->state & DEV_CONFIG) && (link->open)) { 390 if (link->open) {
397 tc589_reset(dev); 391 tc589_reset(dev);
398 netif_device_attach(dev); 392 netif_device_attach(dev);
399 } 393 }
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index f6ca85d77c7d..0f1219c11853 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -168,7 +168,6 @@ static int axnet_probe(struct pcmcia_device *link)
168 dev->do_ioctl = &axnet_ioctl; 168 dev->do_ioctl = &axnet_ioctl;
169 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 169 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
170 170
171 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
172 return axnet_config(link); 171 return axnet_config(link);
173} /* axnet_attach */ 172} /* axnet_attach */
174 173
@@ -190,8 +189,7 @@ static void axnet_detach(struct pcmcia_device *link)
190 if (link->dev_node) 189 if (link->dev_node)
191 unregister_netdev(dev); 190 unregister_netdev(dev);
192 191
193 if (link->state & DEV_CONFIG) 192 axnet_release(link);
194 axnet_release(link);
195 193
196 free_netdev(dev); 194 free_netdev(dev);
197} /* axnet_detach */ 195} /* axnet_detach */
@@ -309,9 +307,6 @@ static int axnet_config(struct pcmcia_device *link)
309 /* don't trust the CIS on this; Linksys got it wrong */ 307 /* don't trust the CIS on this; Linksys got it wrong */
310 link->conf.Present = 0x63; 308 link->conf.Present = 0x63;
311 309
312 /* Configure card */
313 link->state |= DEV_CONFIG;
314
315 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 310 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
316 tuple.Attributes = 0; 311 tuple.Attributes = 0;
317 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 312 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
@@ -402,7 +397,6 @@ static int axnet_config(struct pcmcia_device *link)
402 397
403 info->phy_id = (i < 32) ? i : -1; 398 info->phy_id = (i < 32) ? i : -1;
404 link->dev_node = &info->node; 399 link->dev_node = &info->node;
405 link->state &= ~DEV_CONFIG_PENDING;
406 SET_NETDEV_DEV(dev, &handle_to_dev(link)); 400 SET_NETDEV_DEV(dev, &handle_to_dev(link));
407 401
408 if (register_netdev(dev) != 0) { 402 if (register_netdev(dev) != 0) {
@@ -429,7 +423,6 @@ cs_failed:
429 cs_error(link, last_fn, last_ret); 423 cs_error(link, last_fn, last_ret);
430failed: 424failed:
431 axnet_release(link); 425 axnet_release(link);
432 link->state &= ~DEV_CONFIG_PENDING;
433 return -ENODEV; 426 return -ENODEV;
434} /* axnet_config */ 427} /* axnet_config */
435 428
@@ -450,8 +443,8 @@ static int axnet_suspend(struct pcmcia_device *link)
450{ 443{
451 struct net_device *dev = link->priv; 444 struct net_device *dev = link->priv;
452 445
453 if ((link->state & DEV_CONFIG) && (link->open)) 446 if (link->open)
454 netif_device_detach(dev); 447 netif_device_detach(dev);
455 448
456 return 0; 449 return 0;
457} 450}
@@ -460,7 +453,7 @@ static int axnet_resume(struct pcmcia_device *link)
460{ 453{
461 struct net_device *dev = link->priv; 454 struct net_device *dev = link->priv;
462 455
463 if ((link->state & DEV_CONFIG) && (link->open)) { 456 if (link->open) {
464 axnet_reset_8390(dev); 457 axnet_reset_8390(dev);
465 AX88190_init(dev, 1); 458 AX88190_init(dev, 1);
466 netif_device_attach(dev); 459 netif_device_attach(dev);
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
index a7d675bc6051..441de824ab6b 100644
--- a/drivers/net/pcmcia/com20020_cs.c
+++ b/drivers/net/pcmcia/com20020_cs.c
@@ -178,7 +178,6 @@ static int com20020_probe(struct pcmcia_device *p_dev)
178 p_dev->irq.Instance = info->dev = dev; 178 p_dev->irq.Instance = info->dev = dev;
179 p_dev->priv = info; 179 p_dev->priv = info;
180 180
181 p_dev->state |= DEV_PRESENT;
182 return com20020_config(p_dev); 181 return com20020_config(p_dev);
183 182
184fail_alloc_dev: 183fail_alloc_dev:
@@ -218,8 +217,7 @@ static void com20020_detach(struct pcmcia_device *link)
218 free_irq(dev->irq, dev); 217 free_irq(dev->irq, dev);
219 } 218 }
220 219
221 if (link->state & DEV_CONFIG) 220 com20020_release(link);
222 com20020_release(link);
223 221
224 /* Unlink device structure, free bits */ 222 /* Unlink device structure, free bits */
225 DEBUG(1,"unlinking...\n"); 223 DEBUG(1,"unlinking...\n");
@@ -276,9 +274,6 @@ static int com20020_config(struct pcmcia_device *link)
276 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 274 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
277 link->conf.ConfigBase = parse.config.base; 275 link->conf.ConfigBase = parse.config.base;
278 276
279 /* Configure card */
280 link->state |= DEV_CONFIG;
281
282 DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1); 277 DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1);
283 i = !CS_SUCCESS; 278 i = !CS_SUCCESS;
284 if (!link->io.BasePort1) 279 if (!link->io.BasePort1)
@@ -328,7 +323,6 @@ static int com20020_config(struct pcmcia_device *link)
328 lp->card_flags = ARC_CAN_10MBIT; /* pretend all of them can 10Mbit */ 323 lp->card_flags = ARC_CAN_10MBIT; /* pretend all of them can 10Mbit */
329 324
330 link->dev_node = &info->node; 325 link->dev_node = &info->node;
331 link->state &= ~DEV_CONFIG_PENDING;
332 SET_NETDEV_DEV(dev, &handle_to_dev(link)); 326 SET_NETDEV_DEV(dev, &handle_to_dev(link));
333 327
334 i = com20020_found(dev, 0); /* calls register_netdev */ 328 i = com20020_found(dev, 0); /* calls register_netdev */
@@ -372,7 +366,7 @@ static int com20020_suspend(struct pcmcia_device *link)
372 com20020_dev_t *info = link->priv; 366 com20020_dev_t *info = link->priv;
373 struct net_device *dev = info->dev; 367 struct net_device *dev = info->dev;
374 368
375 if ((link->state & DEV_CONFIG) && (link->open)) 369 if (link->open)
376 netif_device_detach(dev); 370 netif_device_detach(dev);
377 371
378 return 0; 372 return 0;
@@ -383,7 +377,7 @@ static int com20020_resume(struct pcmcia_device *link)
383 com20020_dev_t *info = link->priv; 377 com20020_dev_t *info = link->priv;
384 struct net_device *dev = info->dev; 378 struct net_device *dev = info->dev;
385 379
386 if ((link->state & DEV_CONFIG) && (link->open)) { 380 if (link->open) {
387 int ioaddr = dev->base_addr; 381 int ioaddr = dev->base_addr;
388 struct arcnet_local *lp = dev->priv; 382 struct arcnet_local *lp = dev->priv;
389 ARCRESET; 383 ARCRESET;
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index d9c83b290095..7cb20b6b9348 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -272,7 +272,6 @@ static int fmvj18x_probe(struct pcmcia_device *link)
272#endif 272#endif
273 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 273 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
274 274
275 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
276 return fmvj18x_config(link); 275 return fmvj18x_config(link);
277} /* fmvj18x_attach */ 276} /* fmvj18x_attach */
278 277
@@ -287,8 +286,7 @@ static void fmvj18x_detach(struct pcmcia_device *link)
287 if (link->dev_node) 286 if (link->dev_node)
288 unregister_netdev(dev); 287 unregister_netdev(dev);
289 288
290 if (link->state & DEV_CONFIG) 289 fmvj18x_release(link);
291 fmvj18x_release(link);
292 290
293 free_netdev(dev); 291 free_netdev(dev);
294} /* fmvj18x_detach */ 292} /* fmvj18x_detach */
@@ -363,9 +361,6 @@ static int fmvj18x_config(struct pcmcia_device *link)
363 tuple.TupleOffset = 0; 361 tuple.TupleOffset = 0;
364 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 362 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
365 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 363 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
366
367 /* Configure card */
368 link->state |= DEV_CONFIG;
369 364
370 link->conf.ConfigBase = parse.config.base; 365 link->conf.ConfigBase = parse.config.base;
371 link->conf.Present = parse.config.rmask[0]; 366 link->conf.Present = parse.config.rmask[0];
@@ -532,7 +527,6 @@ static int fmvj18x_config(struct pcmcia_device *link)
532 527
533 lp->cardtype = cardtype; 528 lp->cardtype = cardtype;
534 link->dev_node = &lp->node; 529 link->dev_node = &lp->node;
535 link->state &= ~DEV_CONFIG_PENDING;
536 SET_NETDEV_DEV(dev, &handle_to_dev(link)); 530 SET_NETDEV_DEV(dev, &handle_to_dev(link));
537 531
538 if (register_netdev(dev) != 0) { 532 if (register_netdev(dev) != 0) {
@@ -557,7 +551,6 @@ cs_failed:
557 cs_error(link, last_fn, last_ret); 551 cs_error(link, last_fn, last_ret);
558failed: 552failed:
559 fmvj18x_release(link); 553 fmvj18x_release(link);
560 link->state &= ~DEV_CONFIG_PENDING;
561 return -ENODEV; 554 return -ENODEV;
562} /* fmvj18x_config */ 555} /* fmvj18x_config */
563/*====================================================================*/ 556/*====================================================================*/
@@ -668,7 +661,7 @@ static int fmvj18x_suspend(struct pcmcia_device *link)
668{ 661{
669 struct net_device *dev = link->priv; 662 struct net_device *dev = link->priv;
670 663
671 if ((link->state & DEV_CONFIG) && (link->open)) 664 if (link->open)
672 netif_device_detach(dev); 665 netif_device_detach(dev);
673 666
674 return 0; 667 return 0;
@@ -678,7 +671,7 @@ static int fmvj18x_resume(struct pcmcia_device *link)
678{ 671{
679 struct net_device *dev = link->priv; 672 struct net_device *dev = link->priv;
680 673
681 if ((link->state & DEV_CONFIG) && (link->open)) { 674 if (link->open) {
682 fjn_reset(dev); 675 fjn_reset(dev);
683 netif_device_attach(dev); 676 netif_device_attach(dev);
684 } 677 }
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
index e038d9278a59..b8fe70b85641 100644
--- a/drivers/net/pcmcia/ibmtr_cs.c
+++ b/drivers/net/pcmcia/ibmtr_cs.c
@@ -173,7 +173,6 @@ static int ibmtr_attach(struct pcmcia_device *link)
173 173
174 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 174 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
175 175
176 link->state |= DEV_PRESENT;
177 return ibmtr_config(link); 176 return ibmtr_config(link);
178} /* ibmtr_attach */ 177} /* ibmtr_attach */
179 178
@@ -200,8 +199,8 @@ static void ibmtr_detach(struct pcmcia_device *link)
200 struct tok_info *ti = netdev_priv(dev); 199 struct tok_info *ti = netdev_priv(dev);
201 del_timer_sync(&(ti->tr_timer)); 200 del_timer_sync(&(ti->tr_timer));
202 } 201 }
203 if (link->state & DEV_CONFIG) 202
204 ibmtr_release(link); 203 ibmtr_release(link);
205 204
206 free_netdev(dev); 205 free_netdev(dev);
207 kfree(info); 206 kfree(info);
@@ -241,10 +240,6 @@ static int ibmtr_config(struct pcmcia_device *link)
241 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 240 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
242 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 241 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
243 link->conf.ConfigBase = parse.config.base; 242 link->conf.ConfigBase = parse.config.base;
244
245 /* Configure card */
246 link->state |= DEV_CONFIG;
247
248 link->conf.ConfigIndex = 0x61; 243 link->conf.ConfigIndex = 0x61;
249 244
250 /* Determine if this is PRIMARY or ALTERNATE. */ 245 /* Determine if this is PRIMARY or ALTERNATE. */
@@ -301,7 +296,6 @@ static int ibmtr_config(struct pcmcia_device *link)
301 ibmtr_hw_setup(dev, mmiobase); 296 ibmtr_hw_setup(dev, mmiobase);
302 297
303 link->dev_node = &info->node; 298 link->dev_node = &info->node;
304 link->state &= ~DEV_CONFIG_PENDING;
305 SET_NETDEV_DEV(dev, &handle_to_dev(link)); 299 SET_NETDEV_DEV(dev, &handle_to_dev(link));
306 300
307 i = ibmtr_probe_card(dev); 301 i = ibmtr_probe_card(dev);
@@ -358,7 +352,7 @@ static int ibmtr_suspend(struct pcmcia_device *link)
358 ibmtr_dev_t *info = link->priv; 352 ibmtr_dev_t *info = link->priv;
359 struct net_device *dev = info->dev; 353 struct net_device *dev = info->dev;
360 354
361 if ((link->state & DEV_CONFIG) && (link->open)) 355 if (link->open)
362 netif_device_detach(dev); 356 netif_device_detach(dev);
363 357
364 return 0; 358 return 0;
@@ -369,7 +363,7 @@ static int ibmtr_resume(struct pcmcia_device *link)
369 ibmtr_dev_t *info = link->priv; 363 ibmtr_dev_t *info = link->priv;
370 struct net_device *dev = info->dev; 364 struct net_device *dev = info->dev;
371 365
372 if ((link->state & DEV_CONFIG) && (link->open)) { 366 if (link->open) {
373 ibmtr_probe(dev); /* really? */ 367 ibmtr_probe(dev); /* really? */
374 netif_device_attach(dev); 368 netif_device_attach(dev);
375 } 369 }
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index ea8a62e629a4..fd191143cb2f 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -487,7 +487,6 @@ static int nmclan_probe(struct pcmcia_device *link)
487 dev->watchdog_timeo = TX_TIMEOUT; 487 dev->watchdog_timeo = TX_TIMEOUT;
488#endif 488#endif
489 489
490 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
491 return nmclan_config(link); 490 return nmclan_config(link);
492} /* nmclan_attach */ 491} /* nmclan_attach */
493 492
@@ -508,8 +507,7 @@ static void nmclan_detach(struct pcmcia_device *link)
508 if (link->dev_node) 507 if (link->dev_node)
509 unregister_netdev(dev); 508 unregister_netdev(dev);
510 509
511 if (link->state & DEV_CONFIG) 510 nmclan_release(link);
512 nmclan_release(link);
513 511
514 free_netdev(dev); 512 free_netdev(dev);
515} /* nmclan_detach */ 513} /* nmclan_detach */
@@ -675,9 +673,6 @@ static int nmclan_config(struct pcmcia_device *link)
675 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 673 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
676 link->conf.ConfigBase = parse.config.base; 674 link->conf.ConfigBase = parse.config.base;
677 675
678 /* Configure card */
679 link->state |= DEV_CONFIG;
680
681 CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); 676 CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io));
682 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 677 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
683 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 678 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
@@ -707,7 +702,6 @@ static int nmclan_config(struct pcmcia_device *link)
707 } else { 702 } else {
708 printk(KERN_NOTICE "nmclan_cs: mace id not found: %x %x should" 703 printk(KERN_NOTICE "nmclan_cs: mace id not found: %x %x should"
709 " be 0x40 0x?9\n", sig[0], sig[1]); 704 " be 0x40 0x?9\n", sig[0], sig[1]);
710 link->state &= ~DEV_CONFIG_PENDING;
711 return -ENODEV; 705 return -ENODEV;
712 } 706 }
713 } 707 }
@@ -722,7 +716,6 @@ static int nmclan_config(struct pcmcia_device *link)
722 printk(KERN_NOTICE "nmclan_cs: invalid if_port requested\n"); 716 printk(KERN_NOTICE "nmclan_cs: invalid if_port requested\n");
723 717
724 link->dev_node = &lp->node; 718 link->dev_node = &lp->node;
725 link->state &= ~DEV_CONFIG_PENDING;
726 SET_NETDEV_DEV(dev, &handle_to_dev(link)); 719 SET_NETDEV_DEV(dev, &handle_to_dev(link));
727 720
728 i = register_netdev(dev); 721 i = register_netdev(dev);
@@ -763,7 +756,7 @@ static int nmclan_suspend(struct pcmcia_device *link)
763{ 756{
764 struct net_device *dev = link->priv; 757 struct net_device *dev = link->priv;
765 758
766 if ((link->state & DEV_CONFIG) && (link->open)) 759 if (link->open)
767 netif_device_detach(dev); 760 netif_device_detach(dev);
768 761
769 return 0; 762 return 0;
@@ -773,7 +766,7 @@ static int nmclan_resume(struct pcmcia_device *link)
773{ 766{
774 struct net_device *dev = link->priv; 767 struct net_device *dev = link->priv;
775 768
776 if ((link->state & DEV_CONFIG) && (link->open)) { 769 if (link->open) {
777 nmclan_reset(dev); 770 nmclan_reset(dev);
778 netif_device_attach(dev); 771 netif_device_attach(dev);
779 } 772 }
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index d840c0f03ea9..d9661410f2ff 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -264,7 +264,6 @@ static int pcnet_probe(struct pcmcia_device *link)
264 dev->stop = &pcnet_close; 264 dev->stop = &pcnet_close;
265 dev->set_config = &set_config; 265 dev->set_config = &set_config;
266 266
267 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
268 return pcnet_config(link); 267 return pcnet_config(link);
269} /* pcnet_attach */ 268} /* pcnet_attach */
270 269
@@ -286,8 +285,7 @@ static void pcnet_detach(struct pcmcia_device *link)
286 if (link->dev_node) 285 if (link->dev_node)
287 unregister_netdev(dev); 286 unregister_netdev(dev);
288 287
289 if (link->state & DEV_CONFIG) 288 pcnet_release(link);
290 pcnet_release(link);
291 289
292 free_netdev(dev); 290 free_netdev(dev);
293} /* pcnet_detach */ 291} /* pcnet_detach */
@@ -538,9 +536,6 @@ static int pcnet_config(struct pcmcia_device *link)
538 link->conf.ConfigBase = parse.config.base; 536 link->conf.ConfigBase = parse.config.base;
539 link->conf.Present = parse.config.rmask[0]; 537 link->conf.Present = parse.config.rmask[0];
540 538
541 /* Configure card */
542 link->state |= DEV_CONFIG;
543
544 tuple.DesiredTuple = CISTPL_MANFID; 539 tuple.DesiredTuple = CISTPL_MANFID;
545 tuple.Attributes = TUPLE_RETURN_COMMON; 540 tuple.Attributes = TUPLE_RETURN_COMMON;
546 if ((pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) && 541 if ((pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) &&
@@ -667,7 +662,6 @@ static int pcnet_config(struct pcmcia_device *link)
667 } 662 }
668 663
669 link->dev_node = &info->node; 664 link->dev_node = &info->node;
670 link->state &= ~DEV_CONFIG_PENDING;
671 SET_NETDEV_DEV(dev, &handle_to_dev(link)); 665 SET_NETDEV_DEV(dev, &handle_to_dev(link));
672 666
673#ifdef CONFIG_NET_POLL_CONTROLLER 667#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -705,7 +699,6 @@ cs_failed:
705 cs_error(link, last_fn, last_ret); 699 cs_error(link, last_fn, last_ret);
706failed: 700failed:
707 pcnet_release(link); 701 pcnet_release(link);
708 link->state &= ~DEV_CONFIG_PENDING;
709 return -ENODEV; 702 return -ENODEV;
710} /* pcnet_config */ 703} /* pcnet_config */
711 704
@@ -742,7 +735,7 @@ static int pcnet_suspend(struct pcmcia_device *link)
742{ 735{
743 struct net_device *dev = link->priv; 736 struct net_device *dev = link->priv;
744 737
745 if ((link->state & DEV_CONFIG) && (link->open)) 738 if (link->open)
746 netif_device_detach(dev); 739 netif_device_detach(dev);
747 740
748 return 0; 741 return 0;
@@ -752,7 +745,7 @@ static int pcnet_resume(struct pcmcia_device *link)
752{ 745{
753 struct net_device *dev = link->priv; 746 struct net_device *dev = link->priv;
754 747
755 if ((link->state & DEV_CONFIG) && (link->open)) { 748 if (link->open) {
756 pcnet_reset_8390(dev); 749 pcnet_reset_8390(dev);
757 NS8390_init(dev, 1); 750 NS8390_init(dev, 1);
758 netif_device_attach(dev); 751 netif_device_attach(dev);
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index 3252c1dc9ee7..7d565f26a3bf 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -356,7 +356,6 @@ static int smc91c92_probe(struct pcmcia_device *link)
356 smc->mii_if.phy_id_mask = 0x1f; 356 smc->mii_if.phy_id_mask = 0x1f;
357 smc->mii_if.reg_num_mask = 0x1f; 357 smc->mii_if.reg_num_mask = 0x1f;
358 358
359 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
360 return smc91c92_config(link); 359 return smc91c92_config(link);
361} /* smc91c92_attach */ 360} /* smc91c92_attach */
362 361
@@ -378,8 +377,7 @@ static void smc91c92_detach(struct pcmcia_device *link)
378 if (link->dev_node) 377 if (link->dev_node)
379 unregister_netdev(dev); 378 unregister_netdev(dev);
380 379
381 if (link->state & DEV_CONFIG) 380 smc91c92_release(link);
382 smc91c92_release(link);
383 381
384 free_netdev(dev); 382 free_netdev(dev);
385} /* smc91c92_detach */ 383} /* smc91c92_detach */
@@ -862,7 +860,7 @@ static int smc91c92_suspend(struct pcmcia_device *link)
862{ 860{
863 struct net_device *dev = link->priv; 861 struct net_device *dev = link->priv;
864 862
865 if ((link->state & DEV_CONFIG) && (link->open)) 863 if (link->open)
866 netif_device_detach(dev); 864 netif_device_detach(dev);
867 865
868 return 0; 866 return 0;
@@ -874,33 +872,31 @@ static int smc91c92_resume(struct pcmcia_device *link)
874 struct smc_private *smc = netdev_priv(dev); 872 struct smc_private *smc = netdev_priv(dev);
875 int i; 873 int i;
876 874
877 if (link->state & DEV_CONFIG) { 875 if ((smc->manfid == MANFID_MEGAHERTZ) &&
878 if ((smc->manfid == MANFID_MEGAHERTZ) && 876 (smc->cardid == PRODID_MEGAHERTZ_EM3288))
879 (smc->cardid == PRODID_MEGAHERTZ_EM3288)) 877 mhz_3288_power(link);
880 mhz_3288_power(link); 878 if (smc->manfid == MANFID_MOTOROLA)
881 if (smc->manfid == MANFID_MOTOROLA) 879 mot_config(link);
882 mot_config(link); 880 if ((smc->manfid == MANFID_OSITECH) &&
883 if ((smc->manfid == MANFID_OSITECH) && 881 (smc->cardid != PRODID_OSITECH_SEVEN)) {
884 (smc->cardid != PRODID_OSITECH_SEVEN)) { 882 /* Power up the card and enable interrupts */
885 /* Power up the card and enable interrupts */ 883 set_bits(0x0300, dev->base_addr-0x10+OSITECH_AUI_PWR);
886 set_bits(0x0300, dev->base_addr-0x10+OSITECH_AUI_PWR); 884 set_bits(0x0300, dev->base_addr-0x10+OSITECH_RESET_ISR);
887 set_bits(0x0300, dev->base_addr-0x10+OSITECH_RESET_ISR); 885 }
888 } 886 if (((smc->manfid == MANFID_OSITECH) &&
889 if (((smc->manfid == MANFID_OSITECH) && 887 (smc->cardid == PRODID_OSITECH_SEVEN)) ||
890 (smc->cardid == PRODID_OSITECH_SEVEN)) || 888 ((smc->manfid == MANFID_PSION) &&
891 ((smc->manfid == MANFID_PSION) && 889 (smc->cardid == PRODID_PSION_NET100))) {
892 (smc->cardid == PRODID_PSION_NET100))) { 890 /* Download the Seven of Diamonds firmware */
893 /* Download the Seven of Diamonds firmware */ 891 for (i = 0; i < sizeof(__Xilinx7OD); i++) {
894 for (i = 0; i < sizeof(__Xilinx7OD); i++) { 892 outb(__Xilinx7OD[i], link->io.BasePort1+2);
895 outb(__Xilinx7OD[i], link->io.BasePort1+2); 893 udelay(50);
896 udelay(50);
897 }
898 }
899 if (link->open) {
900 smc_reset(dev);
901 netif_device_attach(dev);
902 } 894 }
903 } 895 }
896 if (link->open) {
897 smc_reset(dev);
898 netif_device_attach(dev);
899 }
904 900
905 return 0; 901 return 0;
906} 902}
@@ -1010,9 +1006,6 @@ static int smc91c92_config(struct pcmcia_device *link)
1010 smc->cardid = parse->manfid.card; 1006 smc->cardid = parse->manfid.card;
1011 } 1007 }
1012 1008
1013 /* Configure card */
1014 link->state |= DEV_CONFIG;
1015
1016 if ((smc->manfid == MANFID_OSITECH) && 1009 if ((smc->manfid == MANFID_OSITECH) &&
1017 (smc->cardid != PRODID_OSITECH_SEVEN)) { 1010 (smc->cardid != PRODID_OSITECH_SEVEN)) {
1018 i = osi_config(link); 1011 i = osi_config(link);
@@ -1108,7 +1101,6 @@ static int smc91c92_config(struct pcmcia_device *link)
1108 } 1101 }
1109 1102
1110 link->dev_node = &smc->node; 1103 link->dev_node = &smc->node;
1111 link->state &= ~DEV_CONFIG_PENDING;
1112 SET_NETDEV_DEV(dev, &handle_to_dev(link)); 1104 SET_NETDEV_DEV(dev, &handle_to_dev(link));
1113 1105
1114 if (register_netdev(dev) != 0) { 1106 if (register_netdev(dev) != 0) {
@@ -1149,7 +1141,6 @@ config_undo:
1149 unregister_netdev(dev); 1141 unregister_netdev(dev);
1150config_failed: /* CS_EXIT_TEST() calls jump to here... */ 1142config_failed: /* CS_EXIT_TEST() calls jump to here... */
1151 smc91c92_release(link); 1143 smc91c92_release(link);
1152 link->state &= ~DEV_CONFIG_PENDING;
1153 kfree(cfg_mem); 1144 kfree(cfg_mem);
1154 return -ENODEV; 1145 return -ENODEV;
1155} /* smc91c92_config */ 1146} /* smc91c92_config */
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index 77bf4e3a6139..0141c5037f41 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -591,7 +591,6 @@ xirc2ps_probe(struct pcmcia_device *link)
591 dev->watchdog_timeo = TX_TIMEOUT; 591 dev->watchdog_timeo = TX_TIMEOUT;
592#endif 592#endif
593 593
594 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
595 return xirc2ps_config(link); 594 return xirc2ps_config(link);
596} /* xirc2ps_attach */ 595} /* xirc2ps_attach */
597 596
@@ -612,8 +611,7 @@ xirc2ps_detach(struct pcmcia_device *link)
612 if (link->dev_node) 611 if (link->dev_node)
613 unregister_netdev(dev); 612 unregister_netdev(dev);
614 613
615 if (link->state & DEV_CONFIG) 614 xirc2ps_release(link);
616 xirc2ps_release(link);
617 615
618 free_netdev(dev); 616 free_netdev(dev);
619} /* xirc2ps_detach */ 617} /* xirc2ps_detach */
@@ -843,9 +841,6 @@ xirc2ps_config(struct pcmcia_device * link)
843 for (i=0; i < 6; i++) 841 for (i=0; i < 6; i++)
844 dev->dev_addr[i] = node_id->id[i]; 842 dev->dev_addr[i] = node_id->id[i];
845 843
846 /* Configure card */
847 link->state |= DEV_CONFIG;
848
849 link->io.IOAddrLines =10; 844 link->io.IOAddrLines =10;
850 link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 845 link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
851 link->irq.Attributes = IRQ_HANDLE_PRESENT; 846 link->irq.Attributes = IRQ_HANDLE_PRESENT;
@@ -1041,7 +1036,6 @@ xirc2ps_config(struct pcmcia_device * link)
1041 do_reset(dev, 1); /* a kludge to make the cem56 work */ 1036 do_reset(dev, 1); /* a kludge to make the cem56 work */
1042 1037
1043 link->dev_node = &local->node; 1038 link->dev_node = &local->node;
1044 link->state &= ~DEV_CONFIG_PENDING;
1045 SET_NETDEV_DEV(dev, &handle_to_dev(link)); 1039 SET_NETDEV_DEV(dev, &handle_to_dev(link));
1046 1040
1047 if ((err=register_netdev(dev))) { 1041 if ((err=register_netdev(dev))) {
@@ -1062,14 +1056,12 @@ xirc2ps_config(struct pcmcia_device * link)
1062 return 0; 1056 return 0;
1063 1057
1064 config_error: 1058 config_error:
1065 link->state &= ~DEV_CONFIG_PENDING;
1066 xirc2ps_release(link); 1059 xirc2ps_release(link);
1067 return -ENODEV; 1060 return -ENODEV;
1068 1061
1069 cis_error: 1062 cis_error:
1070 printk(KNOT_XIRC "unable to parse CIS\n"); 1063 printk(KNOT_XIRC "unable to parse CIS\n");
1071 failure: 1064 failure:
1072 link->state &= ~DEV_CONFIG_PENDING;
1073 return -ENODEV; 1065 return -ENODEV;
1074} /* xirc2ps_config */ 1066} /* xirc2ps_config */
1075 1067
@@ -1099,9 +1091,9 @@ static int xirc2ps_suspend(struct pcmcia_device *link)
1099{ 1091{
1100 struct net_device *dev = link->priv; 1092 struct net_device *dev = link->priv;
1101 1093
1102 if ((link->state & DEV_CONFIG) && (link->open)) { 1094 if (link->open) {
1103 netif_device_detach(dev); 1095 netif_device_detach(dev);
1104 do_powerdown(dev); 1096 do_powerdown(dev);
1105 } 1097 }
1106 1098
1107 return 0; 1099 return 0;
@@ -1111,7 +1103,7 @@ static int xirc2ps_resume(struct pcmcia_device *link)
1111{ 1103{
1112 struct net_device *dev = link->priv; 1104 struct net_device *dev = link->priv;
1113 1105
1114 if ((link->state & DEV_CONFIG) && (link->open)) { 1106 if (link->open) {
1115 do_reset(dev,1); 1107 do_reset(dev,1);
1116 netif_device_attach(dev); 1108 netif_device_attach(dev);
1117 } 1109 }
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 }