aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-04-02 15:49:59 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-04-02 15:49:59 -0400
commit86dca4f8e6ab1fd8a3fb5838163fc9d7990f416e (patch)
tree3d32116afc3be0d323ef93f260592bcea11db329 /drivers/net
parent9c8680e2cfbb60d5075f8caaf9d98276120bcc78 (diff)
parent553ee5dc1a7a1fb04a6286b0c779481f7035bbd1 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6: (33 commits) [PATCH] pcmcia: declare pccard_iodyn_ops (fix m8xx_pcmcia.c compilation error) [PATCH] pcmcia: fix pcmcia_device_remove oops [PATCH] pcmcia: Add support for Possio GCC AKA PCMCIA Siemens MC45 [PATCH] pcmcia: pseudo device handling update [PATCH] pcmcia: convert DEV_OK to pcmcia_dev_present [PATCH] pcmcia: use bitfield instead of p_state and state [PATCH] pcmcia: remove unused p_dev->state flags [PATCH] pcmcia: make pcmcia_release_{io,irq} static [PATCH] pcmcia: add return value to _config() functions [PATCH] pcmcia: remove dev_link_t and client_handle_t indirection [PATCH] pcmcia: embed dev_link_t into struct pcmcia_device [PATCH] pcmcia: rename pcmcia_device.state [PATCH] pcmcia: remove unneeded Vcc pseudo setting [PATCH] pcmcia: remove export of pcmcia_release_configuration [PATCH] pcmcia: default suspend and resume handling [PATCH] pcmcia: convert remaining users of pcmcia_release_io and _irq [PATCH] pcmcia: add pcmcia_disable_device [PATCH] serial_cs: add Merlin U630 IDs [PATCH] pcmcia: AT91RM9200 Compact Flash driver [PATCH] pcmcia: socket.functions starts with 1 ...
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/pcmcia/3c574_cs.c115
-rw-r--r--drivers/net/pcmcia/3c589_cs.c122
-rw-r--r--drivers/net/pcmcia/axnet_cs.c126
-rw-r--r--drivers/net/pcmcia/com20020_cs.c127
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c166
-rw-r--r--drivers/net/pcmcia/ibmtr_cs.c121
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c126
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c161
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c235
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c185
-rw-r--r--drivers/net/wireless/airo_cs.c158
-rw-r--r--drivers/net/wireless/atmel_cs.c162
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c198
-rw-r--r--drivers/net/wireless/netwave_cs.c127
-rw-r--r--drivers/net/wireless/orinoco_cs.c187
-rw-r--r--drivers/net/wireless/ray_cs.c279
-rw-r--r--drivers/net/wireless/ray_cs.h2
-rw-r--r--drivers/net/wireless/spectrum_cs.c173
-rw-r--r--drivers/net/wireless/wavelan_cs.c189
-rw-r--r--drivers/net/wireless/wavelan_cs.p.h6
-rw-r--r--drivers/net/wireless/wl3501.h1
-rw-r--r--drivers/net/wireless/wl3501_cs.c178
22 files changed, 1186 insertions, 1958 deletions
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index ce90becb8bdf..fab93360f017 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -204,7 +204,7 @@ enum Window4 { /* Window 4: Xcvr/media bits. */
204#define MEDIA_TP 0x00C0 /* Enable link beat and jabber for 10baseT. */ 204#define MEDIA_TP 0x00C0 /* Enable link beat and jabber for 10baseT. */
205 205
206struct el3_private { 206struct el3_private {
207 dev_link_t link; 207 struct pcmcia_device *p_dev;
208 dev_node_t node; 208 dev_node_t node;
209 struct net_device_stats stats; 209 struct net_device_stats stats;
210 u16 advertising, partner; /* NWay media advertisement */ 210 u16 advertising, partner; /* NWay media advertisement */
@@ -225,8 +225,8 @@ static char mii_preamble_required = 0;
225 225
226/* Index of functions. */ 226/* Index of functions. */
227 227
228static void tc574_config(dev_link_t *link); 228static int tc574_config(struct pcmcia_device *link);
229static void tc574_release(dev_link_t *link); 229static void tc574_release(struct pcmcia_device *link);
230 230
231static void mdio_sync(kio_addr_t ioaddr, int bits); 231static void mdio_sync(kio_addr_t ioaddr, int bits);
232static int mdio_read(kio_addr_t ioaddr, int phy_id, int location); 232static int mdio_read(kio_addr_t ioaddr, int phy_id, int location);
@@ -256,10 +256,9 @@ static void tc574_detach(struct pcmcia_device *p_dev);
256 with Card Services. 256 with Card Services.
257*/ 257*/
258 258
259static int tc574_attach(struct pcmcia_device *p_dev) 259static int tc574_probe(struct pcmcia_device *link)
260{ 260{
261 struct el3_private *lp; 261 struct el3_private *lp;
262 dev_link_t *link;
263 struct net_device *dev; 262 struct net_device *dev;
264 263
265 DEBUG(0, "3c574_attach()\n"); 264 DEBUG(0, "3c574_attach()\n");
@@ -269,8 +268,8 @@ static int tc574_attach(struct pcmcia_device *p_dev)
269 if (!dev) 268 if (!dev)
270 return -ENOMEM; 269 return -ENOMEM;
271 lp = netdev_priv(dev); 270 lp = netdev_priv(dev);
272 link = &lp->link;
273 link->priv = dev; 271 link->priv = dev;
272 lp->p_dev = link;
274 273
275 spin_lock_init(&lp->window_lock); 274 spin_lock_init(&lp->window_lock);
276 link->io.NumPorts1 = 32; 275 link->io.NumPorts1 = 32;
@@ -280,7 +279,6 @@ static int tc574_attach(struct pcmcia_device *p_dev)
280 link->irq.Handler = &el3_interrupt; 279 link->irq.Handler = &el3_interrupt;
281 link->irq.Instance = dev; 280 link->irq.Instance = dev;
282 link->conf.Attributes = CONF_ENABLE_IRQ; 281 link->conf.Attributes = CONF_ENABLE_IRQ;
283 link->conf.Vcc = 50;
284 link->conf.IntType = INT_MEMORY_AND_IO; 282 link->conf.IntType = INT_MEMORY_AND_IO;
285 link->conf.ConfigIndex = 1; 283 link->conf.ConfigIndex = 1;
286 link->conf.Present = PRESENT_OPTION; 284 link->conf.Present = PRESENT_OPTION;
@@ -298,13 +296,7 @@ static int tc574_attach(struct pcmcia_device *p_dev)
298 dev->watchdog_timeo = TX_TIMEOUT; 296 dev->watchdog_timeo = TX_TIMEOUT;
299#endif 297#endif
300 298
301 link->handle = p_dev; 299 return tc574_config(link);
302 p_dev->instance = link;
303
304 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
305 tc574_config(link);
306
307 return 0;
308} /* tc574_attach */ 300} /* tc574_attach */
309 301
310/* 302/*
@@ -316,18 +308,16 @@ static int tc574_attach(struct pcmcia_device *p_dev)
316 308
317*/ 309*/
318 310
319static void tc574_detach(struct pcmcia_device *p_dev) 311static void tc574_detach(struct pcmcia_device *link)
320{ 312{
321 dev_link_t *link = dev_to_instance(p_dev);
322 struct net_device *dev = link->priv; 313 struct net_device *dev = link->priv;
323 314
324 DEBUG(0, "3c574_detach(0x%p)\n", link); 315 DEBUG(0, "3c574_detach(0x%p)\n", link);
325 316
326 if (link->dev) 317 if (link->dev_node)
327 unregister_netdev(dev); 318 unregister_netdev(dev);
328 319
329 if (link->state & DEV_CONFIG) 320 tc574_release(link);
330 tc574_release(link);
331 321
332 free_netdev(dev); 322 free_netdev(dev);
333} /* tc574_detach */ 323} /* tc574_detach */
@@ -343,9 +333,8 @@ static void tc574_detach(struct pcmcia_device *p_dev)
343 333
344static const char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"}; 334static const char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"};
345 335
346static void tc574_config(dev_link_t *link) 336static int tc574_config(struct pcmcia_device *link)
347{ 337{
348 client_handle_t handle = link->handle;
349 struct net_device *dev = link->priv; 338 struct net_device *dev = link->priv;
350 struct el3_private *lp = netdev_priv(dev); 339 struct el3_private *lp = netdev_priv(dev);
351 tuple_t tuple; 340 tuple_t tuple;
@@ -363,30 +352,27 @@ static void tc574_config(dev_link_t *link)
363 352
364 tuple.Attributes = 0; 353 tuple.Attributes = 0;
365 tuple.DesiredTuple = CISTPL_CONFIG; 354 tuple.DesiredTuple = CISTPL_CONFIG;
366 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 355 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
367 tuple.TupleData = (cisdata_t *)buf; 356 tuple.TupleData = (cisdata_t *)buf;
368 tuple.TupleDataMax = 64; 357 tuple.TupleDataMax = 64;
369 tuple.TupleOffset = 0; 358 tuple.TupleOffset = 0;
370 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 359 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
371 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 360 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
372 link->conf.ConfigBase = parse.config.base; 361 link->conf.ConfigBase = parse.config.base;
373 link->conf.Present = parse.config.rmask[0]; 362 link->conf.Present = parse.config.rmask[0];
374 363
375 /* Configure card */
376 link->state |= DEV_CONFIG;
377
378 link->io.IOAddrLines = 16; 364 link->io.IOAddrLines = 16;
379 for (i = j = 0; j < 0x400; j += 0x20) { 365 for (i = j = 0; j < 0x400; j += 0x20) {
380 link->io.BasePort1 = j ^ 0x300; 366 link->io.BasePort1 = j ^ 0x300;
381 i = pcmcia_request_io(link->handle, &link->io); 367 i = pcmcia_request_io(link, &link->io);
382 if (i == CS_SUCCESS) break; 368 if (i == CS_SUCCESS) break;
383 } 369 }
384 if (i != CS_SUCCESS) { 370 if (i != CS_SUCCESS) {
385 cs_error(link->handle, RequestIO, i); 371 cs_error(link, RequestIO, i);
386 goto failed; 372 goto failed;
387 } 373 }
388 CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 374 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
389 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 375 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
390 376
391 dev->irq = link->irq.AssignedIRQ; 377 dev->irq = link->irq.AssignedIRQ;
392 dev->base_addr = link->io.BasePort1; 378 dev->base_addr = link->io.BasePort1;
@@ -397,8 +383,8 @@ static void tc574_config(dev_link_t *link)
397 the hardware address. The future products may include a modem chip 383 the hardware address. The future products may include a modem chip
398 and put the address in the CIS. */ 384 and put the address in the CIS. */
399 tuple.DesiredTuple = 0x88; 385 tuple.DesiredTuple = 0x88;
400 if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) { 386 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) {
401 pcmcia_get_tuple_data(handle, &tuple); 387 pcmcia_get_tuple_data(link, &tuple);
402 for (i = 0; i < 3; i++) 388 for (i = 0; i < 3; i++)
403 phys_addr[i] = htons(buf[i]); 389 phys_addr[i] = htons(buf[i]);
404 } else { 390 } else {
@@ -412,9 +398,9 @@ static void tc574_config(dev_link_t *link)
412 } 398 }
413 } 399 }
414 tuple.DesiredTuple = CISTPL_VERS_1; 400 tuple.DesiredTuple = CISTPL_VERS_1;
415 if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS && 401 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS &&
416 pcmcia_get_tuple_data(handle, &tuple) == CS_SUCCESS && 402 pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS &&
417 pcmcia_parse_tuple(handle, &tuple, &parse) == CS_SUCCESS) { 403 pcmcia_parse_tuple(link, &tuple, &parse) == CS_SUCCESS) {
418 cardname = parse.version_1.str + parse.version_1.ofs[1]; 404 cardname = parse.version_1.str + parse.version_1.ofs[1];
419 } else 405 } else
420 cardname = "3Com 3c574"; 406 cardname = "3Com 3c574";
@@ -473,13 +459,12 @@ static void tc574_config(dev_link_t *link)
473 } 459 }
474 } 460 }
475 461
476 link->state &= ~DEV_CONFIG_PENDING; 462 link->dev_node = &lp->node;
477 link->dev = &lp->node; 463 SET_NETDEV_DEV(dev, &handle_to_dev(link));
478 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
479 464
480 if (register_netdev(dev) != 0) { 465 if (register_netdev(dev) != 0) {
481 printk(KERN_NOTICE "3c574_cs: register_netdev() failed\n"); 466 printk(KERN_NOTICE "3c574_cs: register_netdev() failed\n");
482 link->dev = NULL; 467 link->dev_node = NULL;
483 goto failed; 468 goto failed;
484 } 469 }
485 470
@@ -493,13 +478,13 @@ static void tc574_config(dev_link_t *link)
493 8 << config.u.ram_size, ram_split[config.u.ram_split], 478 8 << config.u.ram_size, ram_split[config.u.ram_split],
494 config.u.autoselect ? "autoselect " : ""); 479 config.u.autoselect ? "autoselect " : "");
495 480
496 return; 481 return 0;
497 482
498cs_failed: 483cs_failed:
499 cs_error(link->handle, last_fn, last_ret); 484 cs_error(link, last_fn, last_ret);
500failed: 485failed:
501 tc574_release(link); 486 tc574_release(link);
502 return; 487 return -ENODEV;
503 488
504} /* tc574_config */ 489} /* tc574_config */
505 490
@@ -509,44 +494,28 @@ failed:
509 still open, this will be postponed until it is closed. 494 still open, this will be postponed until it is closed.
510*/ 495*/
511 496
512static void tc574_release(dev_link_t *link) 497static void tc574_release(struct pcmcia_device *link)
513{ 498{
514 DEBUG(0, "3c574_release(0x%p)\n", link); 499 pcmcia_disable_device(link);
515
516 pcmcia_release_configuration(link->handle);
517 pcmcia_release_io(link->handle, &link->io);
518 pcmcia_release_irq(link->handle, &link->irq);
519
520 link->state &= ~DEV_CONFIG;
521} 500}
522 501
523static int tc574_suspend(struct pcmcia_device *p_dev) 502static int tc574_suspend(struct pcmcia_device *link)
524{ 503{
525 dev_link_t *link = dev_to_instance(p_dev);
526 struct net_device *dev = link->priv; 504 struct net_device *dev = link->priv;
527 505
528 link->state |= DEV_SUSPEND; 506 if (link->open)
529 if (link->state & DEV_CONFIG) { 507 netif_device_detach(dev);
530 if (link->open)
531 netif_device_detach(dev);
532 pcmcia_release_configuration(link->handle);
533 }
534 508
535 return 0; 509 return 0;
536} 510}
537 511
538static int tc574_resume(struct pcmcia_device *p_dev) 512static int tc574_resume(struct pcmcia_device *link)
539{ 513{
540 dev_link_t *link = dev_to_instance(p_dev);
541 struct net_device *dev = link->priv; 514 struct net_device *dev = link->priv;
542 515
543 link->state &= ~DEV_SUSPEND; 516 if (link->open) {
544 if (link->state & DEV_CONFIG) { 517 tc574_reset(dev);
545 pcmcia_request_configuration(link->handle, &link->conf); 518 netif_device_attach(dev);
546 if (link->open) {
547 tc574_reset(dev);
548 netif_device_attach(dev);
549 }
550 } 519 }
551 520
552 return 0; 521 return 0;
@@ -757,9 +726,9 @@ static void tc574_reset(struct net_device *dev)
757static int el3_open(struct net_device *dev) 726static int el3_open(struct net_device *dev)
758{ 727{
759 struct el3_private *lp = netdev_priv(dev); 728 struct el3_private *lp = netdev_priv(dev);
760 dev_link_t *link = &lp->link; 729 struct pcmcia_device *link = lp->p_dev;
761 730
762 if (!DEV_OK(link)) 731 if (!pcmcia_dev_present(link))
763 return -ENODEV; 732 return -ENODEV;
764 733
765 link->open++; 734 link->open++;
@@ -1203,11 +1172,11 @@ static int el3_close(struct net_device *dev)
1203{ 1172{
1204 kio_addr_t ioaddr = dev->base_addr; 1173 kio_addr_t ioaddr = dev->base_addr;
1205 struct el3_private *lp = netdev_priv(dev); 1174 struct el3_private *lp = netdev_priv(dev);
1206 dev_link_t *link = &lp->link; 1175 struct pcmcia_device *link = lp->p_dev;
1207 1176
1208 DEBUG(2, "%s: shutting down ethercard.\n", dev->name); 1177 DEBUG(2, "%s: shutting down ethercard.\n", dev->name);
1209 1178
1210 if (DEV_OK(link)) { 1179 if (pcmcia_dev_present(link)) {
1211 unsigned long flags; 1180 unsigned long flags;
1212 1181
1213 /* Turn off statistics ASAP. We update lp->stats below. */ 1182 /* Turn off statistics ASAP. We update lp->stats below. */
@@ -1246,7 +1215,7 @@ static struct pcmcia_driver tc574_driver = {
1246 .drv = { 1215 .drv = {
1247 .name = "3c574_cs", 1216 .name = "3c574_cs",
1248 }, 1217 },
1249 .probe = tc574_attach, 1218 .probe = tc574_probe,
1250 .remove = tc574_detach, 1219 .remove = tc574_detach,
1251 .id_table = tc574_ids, 1220 .id_table = tc574_ids,
1252 .suspend = tc574_suspend, 1221 .suspend = tc574_suspend,
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index 3dba50849da7..875a0fe251e7 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -105,7 +105,7 @@ enum RxFilter {
105#define TX_TIMEOUT ((400*HZ)/1000) 105#define TX_TIMEOUT ((400*HZ)/1000)
106 106
107struct el3_private { 107struct el3_private {
108 dev_link_t link; 108 struct pcmcia_device *p_dev;
109 dev_node_t node; 109 dev_node_t node;
110 struct net_device_stats stats; 110 struct net_device_stats stats;
111 /* For transceiver monitoring */ 111 /* For transceiver monitoring */
@@ -142,8 +142,8 @@ DRV_NAME ".c " DRV_VERSION " 2001/10/13 00:08:50 (David Hinds)";
142 142
143/*====================================================================*/ 143/*====================================================================*/
144 144
145static void tc589_config(dev_link_t *link); 145static int tc589_config(struct pcmcia_device *link);
146static void tc589_release(dev_link_t *link); 146static void tc589_release(struct pcmcia_device *link);
147 147
148static u16 read_eeprom(kio_addr_t ioaddr, int index); 148static u16 read_eeprom(kio_addr_t ioaddr, int index);
149static void tc589_reset(struct net_device *dev); 149static void tc589_reset(struct net_device *dev);
@@ -170,10 +170,9 @@ static void tc589_detach(struct pcmcia_device *p_dev);
170 170
171======================================================================*/ 171======================================================================*/
172 172
173static int tc589_attach(struct pcmcia_device *p_dev) 173static int tc589_probe(struct pcmcia_device *link)
174{ 174{
175 struct el3_private *lp; 175 struct el3_private *lp;
176 dev_link_t *link;
177 struct net_device *dev; 176 struct net_device *dev;
178 177
179 DEBUG(0, "3c589_attach()\n"); 178 DEBUG(0, "3c589_attach()\n");
@@ -183,8 +182,8 @@ static int tc589_attach(struct pcmcia_device *p_dev)
183 if (!dev) 182 if (!dev)
184 return -ENOMEM; 183 return -ENOMEM;
185 lp = netdev_priv(dev); 184 lp = netdev_priv(dev);
186 link = &lp->link;
187 link->priv = dev; 185 link->priv = dev;
186 lp->p_dev = link;
188 187
189 spin_lock_init(&lp->lock); 188 spin_lock_init(&lp->lock);
190 link->io.NumPorts1 = 16; 189 link->io.NumPorts1 = 16;
@@ -194,7 +193,6 @@ static int tc589_attach(struct pcmcia_device *p_dev)
194 link->irq.Handler = &el3_interrupt; 193 link->irq.Handler = &el3_interrupt;
195 link->irq.Instance = dev; 194 link->irq.Instance = dev;
196 link->conf.Attributes = CONF_ENABLE_IRQ; 195 link->conf.Attributes = CONF_ENABLE_IRQ;
197 link->conf.Vcc = 50;
198 link->conf.IntType = INT_MEMORY_AND_IO; 196 link->conf.IntType = INT_MEMORY_AND_IO;
199 link->conf.ConfigIndex = 1; 197 link->conf.ConfigIndex = 1;
200 link->conf.Present = PRESENT_OPTION; 198 link->conf.Present = PRESENT_OPTION;
@@ -213,13 +211,7 @@ static int tc589_attach(struct pcmcia_device *p_dev)
213#endif 211#endif
214 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 212 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
215 213
216 link->handle = p_dev; 214 return tc589_config(link);
217 p_dev->instance = link;
218
219 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
220 tc589_config(link);
221
222 return 0;
223} /* tc589_attach */ 215} /* tc589_attach */
224 216
225/*====================================================================== 217/*======================================================================
@@ -231,18 +223,16 @@ static int tc589_attach(struct pcmcia_device *p_dev)
231 223
232======================================================================*/ 224======================================================================*/
233 225
234static void tc589_detach(struct pcmcia_device *p_dev) 226static void tc589_detach(struct pcmcia_device *link)
235{ 227{
236 dev_link_t *link = dev_to_instance(p_dev);
237 struct net_device *dev = link->priv; 228 struct net_device *dev = link->priv;
238 229
239 DEBUG(0, "3c589_detach(0x%p)\n", link); 230 DEBUG(0, "3c589_detach(0x%p)\n", link);
240 231
241 if (link->dev) 232 if (link->dev_node)
242 unregister_netdev(dev); 233 unregister_netdev(dev);
243 234
244 if (link->state & DEV_CONFIG) 235 tc589_release(link);
245 tc589_release(link);
246 236
247 free_netdev(dev); 237 free_netdev(dev);
248} /* tc589_detach */ 238} /* tc589_detach */
@@ -258,9 +248,8 @@ static void tc589_detach(struct pcmcia_device *p_dev)
258#define CS_CHECK(fn, ret) \ 248#define CS_CHECK(fn, ret) \
259do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 249do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
260 250
261static void tc589_config(dev_link_t *link) 251static int tc589_config(struct pcmcia_device *link)
262{ 252{
263 client_handle_t handle = link->handle;
264 struct net_device *dev = link->priv; 253 struct net_device *dev = link->priv;
265 struct el3_private *lp = netdev_priv(dev); 254 struct el3_private *lp = netdev_priv(dev);
266 tuple_t tuple; 255 tuple_t tuple;
@@ -275,43 +264,40 @@ static void tc589_config(dev_link_t *link)
275 phys_addr = (u16 *)dev->dev_addr; 264 phys_addr = (u16 *)dev->dev_addr;
276 tuple.Attributes = 0; 265 tuple.Attributes = 0;
277 tuple.DesiredTuple = CISTPL_CONFIG; 266 tuple.DesiredTuple = CISTPL_CONFIG;
278 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 267 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
279 tuple.TupleData = (cisdata_t *)buf; 268 tuple.TupleData = (cisdata_t *)buf;
280 tuple.TupleDataMax = sizeof(buf); 269 tuple.TupleDataMax = sizeof(buf);
281 tuple.TupleOffset = 0; 270 tuple.TupleOffset = 0;
282 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 271 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
283 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 272 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
284 link->conf.ConfigBase = parse.config.base; 273 link->conf.ConfigBase = parse.config.base;
285 link->conf.Present = parse.config.rmask[0]; 274 link->conf.Present = parse.config.rmask[0];
286 275
287 /* Is this a 3c562? */ 276 /* Is this a 3c562? */
288 tuple.DesiredTuple = CISTPL_MANFID; 277 tuple.DesiredTuple = CISTPL_MANFID;
289 tuple.Attributes = TUPLE_RETURN_COMMON; 278 tuple.Attributes = TUPLE_RETURN_COMMON;
290 if ((pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) && 279 if ((pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) &&
291 (pcmcia_get_tuple_data(handle, &tuple) == CS_SUCCESS)) { 280 (pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS)) {
292 if (le16_to_cpu(buf[0]) != MANFID_3COM) 281 if (le16_to_cpu(buf[0]) != MANFID_3COM)
293 printk(KERN_INFO "3c589_cs: hmmm, is this really a " 282 printk(KERN_INFO "3c589_cs: hmmm, is this really a "
294 "3Com card??\n"); 283 "3Com card??\n");
295 multi = (le16_to_cpu(buf[1]) == PRODID_3COM_3C562); 284 multi = (le16_to_cpu(buf[1]) == PRODID_3COM_3C562);
296 } 285 }
297
298 /* Configure card */
299 link->state |= DEV_CONFIG;
300 286
301 /* For the 3c562, the base address must be xx00-xx7f */ 287 /* For the 3c562, the base address must be xx00-xx7f */
302 link->io.IOAddrLines = 16; 288 link->io.IOAddrLines = 16;
303 for (i = j = 0; j < 0x400; j += 0x10) { 289 for (i = j = 0; j < 0x400; j += 0x10) {
304 if (multi && (j & 0x80)) continue; 290 if (multi && (j & 0x80)) continue;
305 link->io.BasePort1 = j ^ 0x300; 291 link->io.BasePort1 = j ^ 0x300;
306 i = pcmcia_request_io(link->handle, &link->io); 292 i = pcmcia_request_io(link, &link->io);
307 if (i == CS_SUCCESS) break; 293 if (i == CS_SUCCESS) break;
308 } 294 }
309 if (i != CS_SUCCESS) { 295 if (i != CS_SUCCESS) {
310 cs_error(link->handle, RequestIO, i); 296 cs_error(link, RequestIO, i);
311 goto failed; 297 goto failed;
312 } 298 }
313 CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 299 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
314 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 300 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
315 301
316 dev->irq = link->irq.AssignedIRQ; 302 dev->irq = link->irq.AssignedIRQ;
317 dev->base_addr = link->io.BasePort1; 303 dev->base_addr = link->io.BasePort1;
@@ -321,8 +307,8 @@ static void tc589_config(dev_link_t *link)
321 /* The 3c589 has an extra EEPROM for configuration info, including 307 /* The 3c589 has an extra EEPROM for configuration info, including
322 the hardware address. The 3c562 puts the address in the CIS. */ 308 the hardware address. The 3c562 puts the address in the CIS. */
323 tuple.DesiredTuple = 0x88; 309 tuple.DesiredTuple = 0x88;
324 if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) { 310 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) {
325 pcmcia_get_tuple_data(handle, &tuple); 311 pcmcia_get_tuple_data(link, &tuple);
326 for (i = 0; i < 3; i++) 312 for (i = 0; i < 3; i++)
327 phys_addr[i] = htons(buf[i]); 313 phys_addr[i] = htons(buf[i]);
328 } else { 314 } else {
@@ -346,13 +332,12 @@ static void tc589_config(dev_link_t *link)
346 else 332 else
347 printk(KERN_ERR "3c589_cs: invalid if_port requested\n"); 333 printk(KERN_ERR "3c589_cs: invalid if_port requested\n");
348 334
349 link->dev = &lp->node; 335 link->dev_node = &lp->node;
350 link->state &= ~DEV_CONFIG_PENDING; 336 SET_NETDEV_DEV(dev, &handle_to_dev(link));
351 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
352 337
353 if (register_netdev(dev) != 0) { 338 if (register_netdev(dev) != 0) {
354 printk(KERN_ERR "3c589_cs: register_netdev() failed\n"); 339 printk(KERN_ERR "3c589_cs: register_netdev() failed\n");
355 link->dev = NULL; 340 link->dev_node = NULL;
356 goto failed; 341 goto failed;
357 } 342 }
358 343
@@ -366,14 +351,13 @@ static void tc589_config(dev_link_t *link)
366 printk(KERN_INFO " %dK FIFO split %s Rx:Tx, %s xcvr\n", 351 printk(KERN_INFO " %dK FIFO split %s Rx:Tx, %s xcvr\n",
367 (fifo & 7) ? 32 : 8, ram_split[(fifo >> 16) & 3], 352 (fifo & 7) ? 32 : 8, ram_split[(fifo >> 16) & 3],
368 if_names[dev->if_port]); 353 if_names[dev->if_port]);
369 return; 354 return 0;
370 355
371cs_failed: 356cs_failed:
372 cs_error(link->handle, last_fn, last_ret); 357 cs_error(link, last_fn, last_ret);
373failed: 358failed:
374 tc589_release(link); 359 tc589_release(link);
375 return; 360 return -ENODEV;
376
377} /* tc589_config */ 361} /* tc589_config */
378 362
379/*====================================================================== 363/*======================================================================
@@ -384,44 +368,28 @@ failed:
384 368
385======================================================================*/ 369======================================================================*/
386 370
387static void tc589_release(dev_link_t *link) 371static void tc589_release(struct pcmcia_device *link)
388{ 372{
389 DEBUG(0, "3c589_release(0x%p)\n", link); 373 pcmcia_disable_device(link);
390
391 pcmcia_release_configuration(link->handle);
392 pcmcia_release_io(link->handle, &link->io);
393 pcmcia_release_irq(link->handle, &link->irq);
394
395 link->state &= ~DEV_CONFIG;
396} 374}
397 375
398static int tc589_suspend(struct pcmcia_device *p_dev) 376static int tc589_suspend(struct pcmcia_device *link)
399{ 377{
400 dev_link_t *link = dev_to_instance(p_dev);
401 struct net_device *dev = link->priv; 378 struct net_device *dev = link->priv;
402 379
403 link->state |= DEV_SUSPEND; 380 if (link->open)
404 if (link->state & DEV_CONFIG) { 381 netif_device_detach(dev);
405 if (link->open)
406 netif_device_detach(dev);
407 pcmcia_release_configuration(link->handle);
408 }
409 382
410 return 0; 383 return 0;
411} 384}
412 385
413static int tc589_resume(struct pcmcia_device *p_dev) 386static int tc589_resume(struct pcmcia_device *link)
414{ 387{
415 dev_link_t *link = dev_to_instance(p_dev);
416 struct net_device *dev = link->priv; 388 struct net_device *dev = link->priv;
417 389
418 link->state &= ~DEV_SUSPEND; 390 if (link->open) {
419 if (link->state & DEV_CONFIG) { 391 tc589_reset(dev);
420 pcmcia_request_configuration(link->handle, &link->conf); 392 netif_device_attach(dev);
421 if (link->open) {
422 tc589_reset(dev);
423 netif_device_attach(dev);
424 }
425 } 393 }
426 394
427 return 0; 395 return 0;
@@ -587,9 +555,9 @@ static int el3_config(struct net_device *dev, struct ifmap *map)
587static int el3_open(struct net_device *dev) 555static int el3_open(struct net_device *dev)
588{ 556{
589 struct el3_private *lp = netdev_priv(dev); 557 struct el3_private *lp = netdev_priv(dev);
590 dev_link_t *link = &lp->link; 558 struct pcmcia_device *link = lp->p_dev;
591 559
592 if (!DEV_OK(link)) 560 if (!pcmcia_dev_present(link))
593 return -ENODEV; 561 return -ENODEV;
594 562
595 link->open++; 563 link->open++;
@@ -848,9 +816,9 @@ static struct net_device_stats *el3_get_stats(struct net_device *dev)
848{ 816{
849 struct el3_private *lp = netdev_priv(dev); 817 struct el3_private *lp = netdev_priv(dev);
850 unsigned long flags; 818 unsigned long flags;
851 dev_link_t *link = &lp->link; 819 struct pcmcia_device *link = lp->p_dev;
852 820
853 if (DEV_OK(link)) { 821 if (pcmcia_dev_present(link)) {
854 spin_lock_irqsave(&lp->lock, flags); 822 spin_lock_irqsave(&lp->lock, flags);
855 update_stats(dev); 823 update_stats(dev);
856 spin_unlock_irqrestore(&lp->lock, flags); 824 spin_unlock_irqrestore(&lp->lock, flags);
@@ -950,11 +918,11 @@ static int el3_rx(struct net_device *dev)
950static void set_multicast_list(struct net_device *dev) 918static void set_multicast_list(struct net_device *dev)
951{ 919{
952 struct el3_private *lp = netdev_priv(dev); 920 struct el3_private *lp = netdev_priv(dev);
953 dev_link_t *link = &lp->link; 921 struct pcmcia_device *link = lp->p_dev;
954 kio_addr_t ioaddr = dev->base_addr; 922 kio_addr_t ioaddr = dev->base_addr;
955 u16 opts = SetRxFilter | RxStation | RxBroadcast; 923 u16 opts = SetRxFilter | RxStation | RxBroadcast;
956 924
957 if (!(DEV_OK(link))) return; 925 if (!pcmcia_dev_present(link)) return;
958 if (dev->flags & IFF_PROMISC) 926 if (dev->flags & IFF_PROMISC)
959 opts |= RxMulticast | RxProm; 927 opts |= RxMulticast | RxProm;
960 else if (dev->mc_count || (dev->flags & IFF_ALLMULTI)) 928 else if (dev->mc_count || (dev->flags & IFF_ALLMULTI))
@@ -965,12 +933,12 @@ static void set_multicast_list(struct net_device *dev)
965static int el3_close(struct net_device *dev) 933static int el3_close(struct net_device *dev)
966{ 934{
967 struct el3_private *lp = netdev_priv(dev); 935 struct el3_private *lp = netdev_priv(dev);
968 dev_link_t *link = &lp->link; 936 struct pcmcia_device *link = lp->p_dev;
969 kio_addr_t ioaddr = dev->base_addr; 937 kio_addr_t ioaddr = dev->base_addr;
970 938
971 DEBUG(1, "%s: shutting down ethercard.\n", dev->name); 939 DEBUG(1, "%s: shutting down ethercard.\n", dev->name);
972 940
973 if (DEV_OK(link)) { 941 if (pcmcia_dev_present(link)) {
974 /* Turn off statistics ASAP. We update lp->stats below. */ 942 /* Turn off statistics ASAP. We update lp->stats below. */
975 outw(StatsDisable, ioaddr + EL3_CMD); 943 outw(StatsDisable, ioaddr + EL3_CMD);
976 944
@@ -1020,7 +988,7 @@ static struct pcmcia_driver tc589_driver = {
1020 .drv = { 988 .drv = {
1021 .name = "3c589_cs", 989 .name = "3c589_cs",
1022 }, 990 },
1023 .probe = tc589_attach, 991 .probe = tc589_probe,
1024 .remove = tc589_detach, 992 .remove = tc589_detach,
1025 .id_table = tc589_ids, 993 .id_table = tc589_ids,
1026 .suspend = tc589_suspend, 994 .suspend = tc589_suspend,
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 1cc94b2d76c1..56233afcb2b3 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -86,8 +86,8 @@ static char *version =
86 86
87/*====================================================================*/ 87/*====================================================================*/
88 88
89static void axnet_config(dev_link_t *link); 89static int axnet_config(struct pcmcia_device *link);
90static void axnet_release(dev_link_t *link); 90static void axnet_release(struct pcmcia_device *link);
91static int axnet_open(struct net_device *dev); 91static int axnet_open(struct net_device *dev);
92static int axnet_close(struct net_device *dev); 92static int axnet_close(struct net_device *dev);
93static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 93static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
@@ -117,7 +117,7 @@ static irqreturn_t ax_interrupt(int irq, void *dev_id, struct pt_regs *regs);
117/*====================================================================*/ 117/*====================================================================*/
118 118
119typedef struct axnet_dev_t { 119typedef struct axnet_dev_t {
120 dev_link_t link; 120 struct pcmcia_device *p_dev;
121 dev_node_t node; 121 dev_node_t node;
122 caddr_t base; 122 caddr_t base;
123 struct timer_list watchdog; 123 struct timer_list watchdog;
@@ -142,10 +142,9 @@ static inline axnet_dev_t *PRIV(struct net_device *dev)
142 142
143======================================================================*/ 143======================================================================*/
144 144
145static int axnet_attach(struct pcmcia_device *p_dev) 145static int axnet_probe(struct pcmcia_device *link)
146{ 146{
147 axnet_dev_t *info; 147 axnet_dev_t *info;
148 dev_link_t *link;
149 struct net_device *dev; 148 struct net_device *dev;
150 149
151 DEBUG(0, "axnet_attach()\n"); 150 DEBUG(0, "axnet_attach()\n");
@@ -157,7 +156,7 @@ static int axnet_attach(struct pcmcia_device *p_dev)
157 return -ENOMEM; 156 return -ENOMEM;
158 157
159 info = PRIV(dev); 158 info = PRIV(dev);
160 link = &info->link; 159 info->p_dev = link;
161 link->priv = dev; 160 link->priv = dev;
162 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 161 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
163 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 162 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
@@ -169,13 +168,7 @@ static int axnet_attach(struct pcmcia_device *p_dev)
169 dev->do_ioctl = &axnet_ioctl; 168 dev->do_ioctl = &axnet_ioctl;
170 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 169 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
171 170
172 link->handle = p_dev; 171 return axnet_config(link);
173 p_dev->instance = link;
174
175 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
176 axnet_config(link);
177
178 return 0;
179} /* axnet_attach */ 172} /* axnet_attach */
180 173
181/*====================================================================== 174/*======================================================================
@@ -187,18 +180,16 @@ static int axnet_attach(struct pcmcia_device *p_dev)
187 180
188======================================================================*/ 181======================================================================*/
189 182
190static void axnet_detach(struct pcmcia_device *p_dev) 183static void axnet_detach(struct pcmcia_device *link)
191{ 184{
192 dev_link_t *link = dev_to_instance(p_dev);
193 struct net_device *dev = link->priv; 185 struct net_device *dev = link->priv;
194 186
195 DEBUG(0, "axnet_detach(0x%p)\n", link); 187 DEBUG(0, "axnet_detach(0x%p)\n", link);
196 188
197 if (link->dev) 189 if (link->dev_node)
198 unregister_netdev(dev); 190 unregister_netdev(dev);
199 191
200 if (link->state & DEV_CONFIG) 192 axnet_release(link);
201 axnet_release(link);
202 193
203 free_netdev(dev); 194 free_netdev(dev);
204} /* axnet_detach */ 195} /* axnet_detach */
@@ -209,7 +200,7 @@ static void axnet_detach(struct pcmcia_device *p_dev)
209 200
210======================================================================*/ 201======================================================================*/
211 202
212static int get_prom(dev_link_t *link) 203static int get_prom(struct pcmcia_device *link)
213{ 204{
214 struct net_device *dev = link->priv; 205 struct net_device *dev = link->priv;
215 kio_addr_t ioaddr = dev->base_addr; 206 kio_addr_t ioaddr = dev->base_addr;
@@ -263,7 +254,7 @@ static int get_prom(dev_link_t *link)
263#define CS_CHECK(fn, ret) \ 254#define CS_CHECK(fn, ret) \
264do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 255do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
265 256
266static int try_io_port(dev_link_t *link) 257static int try_io_port(struct pcmcia_device *link)
267{ 258{
268 int j, ret; 259 int j, ret;
269 if (link->io.NumPorts1 == 32) { 260 if (link->io.NumPorts1 == 32) {
@@ -284,25 +275,23 @@ static int try_io_port(dev_link_t *link)
284 for (j = 0; j < 0x400; j += 0x20) { 275 for (j = 0; j < 0x400; j += 0x20) {
285 link->io.BasePort1 = j ^ 0x300; 276 link->io.BasePort1 = j ^ 0x300;
286 link->io.BasePort2 = (j ^ 0x300) + 0x10; 277 link->io.BasePort2 = (j ^ 0x300) + 0x10;
287 ret = pcmcia_request_io(link->handle, &link->io); 278 ret = pcmcia_request_io(link, &link->io);
288 if (ret == CS_SUCCESS) return ret; 279 if (ret == CS_SUCCESS) return ret;
289 } 280 }
290 return ret; 281 return ret;
291 } else { 282 } else {
292 return pcmcia_request_io(link->handle, &link->io); 283 return pcmcia_request_io(link, &link->io);
293 } 284 }
294} 285}
295 286
296static void axnet_config(dev_link_t *link) 287static int axnet_config(struct pcmcia_device *link)
297{ 288{
298 client_handle_t handle = link->handle;
299 struct net_device *dev = link->priv; 289 struct net_device *dev = link->priv;
300 axnet_dev_t *info = PRIV(dev); 290 axnet_dev_t *info = PRIV(dev);
301 tuple_t tuple; 291 tuple_t tuple;
302 cisparse_t parse; 292 cisparse_t parse;
303 int i, j, last_ret, last_fn; 293 int i, j, last_ret, last_fn;
304 u_short buf[64]; 294 u_short buf[64];
305 config_info_t conf;
306 295
307 DEBUG(0, "axnet_config(0x%p)\n", link); 296 DEBUG(0, "axnet_config(0x%p)\n", link);
308 297
@@ -311,29 +300,22 @@ static void axnet_config(dev_link_t *link)
311 tuple.TupleDataMax = sizeof(buf); 300 tuple.TupleDataMax = sizeof(buf);
312 tuple.TupleOffset = 0; 301 tuple.TupleOffset = 0;
313 tuple.DesiredTuple = CISTPL_CONFIG; 302 tuple.DesiredTuple = CISTPL_CONFIG;
314 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 303 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
315 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 304 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
316 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 305 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
317 link->conf.ConfigBase = parse.config.base; 306 link->conf.ConfigBase = parse.config.base;
318 /* don't trust the CIS on this; Linksys got it wrong */ 307 /* don't trust the CIS on this; Linksys got it wrong */
319 link->conf.Present = 0x63; 308 link->conf.Present = 0x63;
320 309
321 /* Configure card */
322 link->state |= DEV_CONFIG;
323
324 /* Look up current Vcc */
325 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf));
326 link->conf.Vcc = conf.Vcc;
327
328 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 310 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
329 tuple.Attributes = 0; 311 tuple.Attributes = 0;
330 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 312 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
331 while (last_ret == CS_SUCCESS) { 313 while (last_ret == CS_SUCCESS) {
332 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 314 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
333 cistpl_io_t *io = &(parse.cftable_entry.io); 315 cistpl_io_t *io = &(parse.cftable_entry.io);
334 316
335 if (pcmcia_get_tuple_data(handle, &tuple) != 0 || 317 if (pcmcia_get_tuple_data(link, &tuple) != 0 ||
336 pcmcia_parse_tuple(handle, &tuple, &parse) != 0 || 318 pcmcia_parse_tuple(link, &tuple, &parse) != 0 ||
337 cfg->index == 0 || cfg->io.nwin == 0) 319 cfg->index == 0 || cfg->io.nwin == 0)
338 goto next_entry; 320 goto next_entry;
339 321
@@ -355,21 +337,21 @@ static void axnet_config(dev_link_t *link)
355 if (last_ret == CS_SUCCESS) break; 337 if (last_ret == CS_SUCCESS) break;
356 } 338 }
357 next_entry: 339 next_entry:
358 last_ret = pcmcia_get_next_tuple(handle, &tuple); 340 last_ret = pcmcia_get_next_tuple(link, &tuple);
359 } 341 }
360 if (last_ret != CS_SUCCESS) { 342 if (last_ret != CS_SUCCESS) {
361 cs_error(handle, RequestIO, last_ret); 343 cs_error(link, RequestIO, last_ret);
362 goto failed; 344 goto failed;
363 } 345 }
364 346
365 CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); 347 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
366 348
367 if (link->io.NumPorts2 == 8) { 349 if (link->io.NumPorts2 == 8) {
368 link->conf.Attributes |= CONF_ENABLE_SPKR; 350 link->conf.Attributes |= CONF_ENABLE_SPKR;
369 link->conf.Status = CCSR_AUDIO_ENA; 351 link->conf.Status = CCSR_AUDIO_ENA;
370 } 352 }
371 353
372 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); 354 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
373 dev->irq = link->irq.AssignedIRQ; 355 dev->irq = link->irq.AssignedIRQ;
374 dev->base_addr = link->io.BasePort1; 356 dev->base_addr = link->io.BasePort1;
375 357
@@ -406,7 +388,7 @@ static void axnet_config(dev_link_t *link)
406 Bit 2 of CCSR is active low. */ 388 Bit 2 of CCSR is active low. */
407 if (i == 32) { 389 if (i == 32) {
408 conf_reg_t reg = { 0, CS_WRITE, CISREG_CCSR, 0x04 }; 390 conf_reg_t reg = { 0, CS_WRITE, CISREG_CCSR, 0x04 };
409 pcmcia_access_configuration_register(link->handle, &reg); 391 pcmcia_access_configuration_register(link, &reg);
410 for (i = 0; i < 32; i++) { 392 for (i = 0; i < 32; i++) {
411 j = mdio_read(dev->base_addr + AXNET_MII_EEP, i, 1); 393 j = mdio_read(dev->base_addr + AXNET_MII_EEP, i, 1);
412 if ((j != 0) && (j != 0xffff)) break; 394 if ((j != 0) && (j != 0xffff)) break;
@@ -414,13 +396,12 @@ static void axnet_config(dev_link_t *link)
414 } 396 }
415 397
416 info->phy_id = (i < 32) ? i : -1; 398 info->phy_id = (i < 32) ? i : -1;
417 link->dev = &info->node; 399 link->dev_node = &info->node;
418 link->state &= ~DEV_CONFIG_PENDING; 400 SET_NETDEV_DEV(dev, &handle_to_dev(link));
419 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
420 401
421 if (register_netdev(dev) != 0) { 402 if (register_netdev(dev) != 0) {
422 printk(KERN_NOTICE "axnet_cs: register_netdev() failed\n"); 403 printk(KERN_NOTICE "axnet_cs: register_netdev() failed\n");
423 link->dev = NULL; 404 link->dev_node = NULL;
424 goto failed; 405 goto failed;
425 } 406 }
426 407
@@ -436,14 +417,13 @@ static void axnet_config(dev_link_t *link)
436 } else { 417 } else {
437 printk(KERN_NOTICE " No MII transceivers found!\n"); 418 printk(KERN_NOTICE " No MII transceivers found!\n");
438 } 419 }
439 return; 420 return 0;
440 421
441cs_failed: 422cs_failed:
442 cs_error(link->handle, last_fn, last_ret); 423 cs_error(link, last_fn, last_ret);
443failed: 424failed:
444 axnet_release(link); 425 axnet_release(link);
445 link->state &= ~DEV_CONFIG_PENDING; 426 return -ENODEV;
446 return;
447} /* axnet_config */ 427} /* axnet_config */
448 428
449/*====================================================================== 429/*======================================================================
@@ -454,45 +434,29 @@ failed:
454 434
455======================================================================*/ 435======================================================================*/
456 436
457static void axnet_release(dev_link_t *link) 437static void axnet_release(struct pcmcia_device *link)
458{ 438{
459 DEBUG(0, "axnet_release(0x%p)\n", link); 439 pcmcia_disable_device(link);
460
461 pcmcia_release_configuration(link->handle);
462 pcmcia_release_io(link->handle, &link->io);
463 pcmcia_release_irq(link->handle, &link->irq);
464
465 link->state &= ~DEV_CONFIG;
466} 440}
467 441
468static int axnet_suspend(struct pcmcia_device *p_dev) 442static int axnet_suspend(struct pcmcia_device *link)
469{ 443{
470 dev_link_t *link = dev_to_instance(p_dev);
471 struct net_device *dev = link->priv; 444 struct net_device *dev = link->priv;
472 445
473 link->state |= DEV_SUSPEND; 446 if (link->open)
474 if (link->state & DEV_CONFIG) { 447 netif_device_detach(dev);
475 if (link->open)
476 netif_device_detach(dev);
477 pcmcia_release_configuration(link->handle);
478 }
479 448
480 return 0; 449 return 0;
481} 450}
482 451
483static int axnet_resume(struct pcmcia_device *p_dev) 452static int axnet_resume(struct pcmcia_device *link)
484{ 453{
485 dev_link_t *link = dev_to_instance(p_dev);
486 struct net_device *dev = link->priv; 454 struct net_device *dev = link->priv;
487 455
488 link->state &= ~DEV_SUSPEND; 456 if (link->open) {
489 if (link->state & DEV_CONFIG) { 457 axnet_reset_8390(dev);
490 pcmcia_request_configuration(link->handle, &link->conf); 458 AX88190_init(dev, 1);
491 if (link->open) { 459 netif_device_attach(dev);
492 axnet_reset_8390(dev);
493 AX88190_init(dev, 1);
494 netif_device_attach(dev);
495 }
496 } 460 }
497 461
498 return 0; 462 return 0;
@@ -562,11 +526,11 @@ static void mdio_write(kio_addr_t addr, int phy_id, int loc, int value)
562static int axnet_open(struct net_device *dev) 526static int axnet_open(struct net_device *dev)
563{ 527{
564 axnet_dev_t *info = PRIV(dev); 528 axnet_dev_t *info = PRIV(dev);
565 dev_link_t *link = &info->link; 529 struct pcmcia_device *link = info->p_dev;
566 530
567 DEBUG(2, "axnet_open('%s')\n", dev->name); 531 DEBUG(2, "axnet_open('%s')\n", dev->name);
568 532
569 if (!DEV_OK(link)) 533 if (!pcmcia_dev_present(link))
570 return -ENODEV; 534 return -ENODEV;
571 535
572 link->open++; 536 link->open++;
@@ -588,7 +552,7 @@ static int axnet_open(struct net_device *dev)
588static int axnet_close(struct net_device *dev) 552static int axnet_close(struct net_device *dev)
589{ 553{
590 axnet_dev_t *info = PRIV(dev); 554 axnet_dev_t *info = PRIV(dev);
591 dev_link_t *link = &info->link; 555 struct pcmcia_device *link = info->p_dev;
592 556
593 DEBUG(2, "axnet_close('%s')\n", dev->name); 557 DEBUG(2, "axnet_close('%s')\n", dev->name);
594 558
@@ -833,7 +797,7 @@ static struct pcmcia_driver axnet_cs_driver = {
833 .drv = { 797 .drv = {
834 .name = "axnet_cs", 798 .name = "axnet_cs",
835 }, 799 },
836 .probe = axnet_attach, 800 .probe = axnet_probe,
837 .remove = axnet_detach, 801 .remove = axnet_detach,
838 .id_table = axnet_ids, 802 .id_table = axnet_ids,
839 .suspend = axnet_suspend, 803 .suspend = axnet_suspend,
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
index 2827a48ea37c..441de824ab6b 100644
--- a/drivers/net/pcmcia/com20020_cs.c
+++ b/drivers/net/pcmcia/com20020_cs.c
@@ -118,8 +118,8 @@ MODULE_LICENSE("GPL");
118 118
119/*====================================================================*/ 119/*====================================================================*/
120 120
121static void com20020_config(dev_link_t *link); 121static int com20020_config(struct pcmcia_device *link);
122static void com20020_release(dev_link_t *link); 122static void com20020_release(struct pcmcia_device *link);
123 123
124static void com20020_detach(struct pcmcia_device *p_dev); 124static void com20020_detach(struct pcmcia_device *p_dev);
125 125
@@ -138,9 +138,8 @@ typedef struct com20020_dev_t {
138 138
139======================================================================*/ 139======================================================================*/
140 140
141static int com20020_attach(struct pcmcia_device *p_dev) 141static int com20020_probe(struct pcmcia_device *p_dev)
142{ 142{
143 dev_link_t *link;
144 com20020_dev_t *info; 143 com20020_dev_t *info;
145 struct net_device *dev; 144 struct net_device *dev;
146 struct arcnet_local *lp; 145 struct arcnet_local *lp;
@@ -148,10 +147,6 @@ static int com20020_attach(struct pcmcia_device *p_dev)
148 DEBUG(0, "com20020_attach()\n"); 147 DEBUG(0, "com20020_attach()\n");
149 148
150 /* Create new network device */ 149 /* Create new network device */
151 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
152 if (!link)
153 return -ENOMEM;
154
155 info = kmalloc(sizeof(struct com20020_dev_t), GFP_KERNEL); 150 info = kmalloc(sizeof(struct com20020_dev_t), GFP_KERNEL);
156 if (!info) 151 if (!info)
157 goto fail_alloc_info; 152 goto fail_alloc_info;
@@ -161,7 +156,6 @@ static int com20020_attach(struct pcmcia_device *p_dev)
161 goto fail_alloc_dev; 156 goto fail_alloc_dev;
162 157
163 memset(info, 0, sizeof(struct com20020_dev_t)); 158 memset(info, 0, sizeof(struct com20020_dev_t));
164 memset(link, 0, sizeof(struct dev_link_t));
165 lp = dev->priv; 159 lp = dev->priv;
166 lp->timeout = timeout; 160 lp->timeout = timeout;
167 lp->backplane = backplane; 161 lp->backplane = backplane;
@@ -172,28 +166,23 @@ static int com20020_attach(struct pcmcia_device *p_dev)
172 /* fill in our module parameters as defaults */ 166 /* fill in our module parameters as defaults */
173 dev->dev_addr[0] = node; 167 dev->dev_addr[0] = node;
174 168
175 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 169 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
176 link->io.NumPorts1 = 16; 170 p_dev->io.NumPorts1 = 16;
177 link->io.IOAddrLines = 16; 171 p_dev->io.IOAddrLines = 16;
178 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 172 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
179 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 173 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
180 link->conf.Attributes = CONF_ENABLE_IRQ; 174 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
181 link->conf.Vcc = 50; 175 p_dev->conf.IntType = INT_MEMORY_AND_IO;
182 link->conf.IntType = INT_MEMORY_AND_IO; 176 p_dev->conf.Present = PRESENT_OPTION;
183 link->conf.Present = PRESENT_OPTION;
184
185 link->irq.Instance = info->dev = dev;
186 link->priv = info;
187 177
188 link->state |= DEV_PRESENT; 178 p_dev->irq.Instance = info->dev = dev;
189 com20020_config(link); 179 p_dev->priv = info;
190 180
191 return 0; 181 return com20020_config(p_dev);
192 182
193fail_alloc_dev: 183fail_alloc_dev:
194 kfree(info); 184 kfree(info);
195fail_alloc_info: 185fail_alloc_info:
196 kfree(link);
197 return -ENOMEM; 186 return -ENOMEM;
198} /* com20020_attach */ 187} /* com20020_attach */
199 188
@@ -206,9 +195,8 @@ fail_alloc_info:
206 195
207======================================================================*/ 196======================================================================*/
208 197
209static void com20020_detach(struct pcmcia_device *p_dev) 198static void com20020_detach(struct pcmcia_device *link)
210{ 199{
211 dev_link_t *link = dev_to_instance(p_dev);
212 struct com20020_dev_t *info = link->priv; 200 struct com20020_dev_t *info = link->priv;
213 struct net_device *dev = info->dev; 201 struct net_device *dev = info->dev;
214 202
@@ -216,7 +204,7 @@ static void com20020_detach(struct pcmcia_device *p_dev)
216 204
217 DEBUG(0, "com20020_detach(0x%p)\n", link); 205 DEBUG(0, "com20020_detach(0x%p)\n", link);
218 206
219 if (link->dev) { 207 if (link->dev_node) {
220 DEBUG(1,"unregister...\n"); 208 DEBUG(1,"unregister...\n");
221 209
222 unregister_netdev(dev); 210 unregister_netdev(dev);
@@ -229,8 +217,7 @@ static void com20020_detach(struct pcmcia_device *p_dev)
229 free_irq(dev->irq, dev); 217 free_irq(dev->irq, dev);
230 } 218 }
231 219
232 if (link->state & DEV_CONFIG) 220 com20020_release(link);
233 com20020_release(link);
234 221
235 /* Unlink device structure, free bits */ 222 /* Unlink device structure, free bits */
236 DEBUG(1,"unlinking...\n"); 223 DEBUG(1,"unlinking...\n");
@@ -245,8 +232,6 @@ static void com20020_detach(struct pcmcia_device *p_dev)
245 DEBUG(1,"kfree2...\n"); 232 DEBUG(1,"kfree2...\n");
246 kfree(info); 233 kfree(info);
247 } 234 }
248 DEBUG(1,"kfree3...\n");
249 kfree(link);
250 235
251} /* com20020_detach */ 236} /* com20020_detach */
252 237
@@ -261,10 +246,9 @@ static void com20020_detach(struct pcmcia_device *p_dev)
261#define CS_CHECK(fn, ret) \ 246#define CS_CHECK(fn, ret) \
262do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 247do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
263 248
264static void com20020_config(dev_link_t *link) 249static int com20020_config(struct pcmcia_device *link)
265{ 250{
266 struct arcnet_local *lp; 251 struct arcnet_local *lp;
267 client_handle_t handle;
268 tuple_t tuple; 252 tuple_t tuple;
269 cisparse_t parse; 253 cisparse_t parse;
270 com20020_dev_t *info; 254 com20020_dev_t *info;
@@ -273,7 +257,6 @@ static void com20020_config(dev_link_t *link)
273 u_char buf[64]; 257 u_char buf[64];
274 int ioaddr; 258 int ioaddr;
275 259
276 handle = link->handle;
277 info = link->priv; 260 info = link->priv;
278 dev = info->dev; 261 dev = info->dev;
279 262
@@ -286,14 +269,11 @@ static void com20020_config(dev_link_t *link)
286 tuple.TupleDataMax = 64; 269 tuple.TupleDataMax = 64;
287 tuple.TupleOffset = 0; 270 tuple.TupleOffset = 0;
288 tuple.DesiredTuple = CISTPL_CONFIG; 271 tuple.DesiredTuple = CISTPL_CONFIG;
289 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 272 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
290 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 273 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
291 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 274 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
292 link->conf.ConfigBase = parse.config.base; 275 link->conf.ConfigBase = parse.config.base;
293 276
294 /* Configure card */
295 link->state |= DEV_CONFIG;
296
297 DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1); 277 DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1);
298 i = !CS_SUCCESS; 278 i = !CS_SUCCESS;
299 if (!link->io.BasePort1) 279 if (!link->io.BasePort1)
@@ -301,13 +281,13 @@ static void com20020_config(dev_link_t *link)
301 for (ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x10) 281 for (ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x10)
302 { 282 {
303 link->io.BasePort1 = ioaddr; 283 link->io.BasePort1 = ioaddr;
304 i = pcmcia_request_io(link->handle, &link->io); 284 i = pcmcia_request_io(link, &link->io);
305 if (i == CS_SUCCESS) 285 if (i == CS_SUCCESS)
306 break; 286 break;
307 } 287 }
308 } 288 }
309 else 289 else
310 i = pcmcia_request_io(link->handle, &link->io); 290 i = pcmcia_request_io(link, &link->io);
311 291
312 if (i != CS_SUCCESS) 292 if (i != CS_SUCCESS)
313 { 293 {
@@ -321,7 +301,7 @@ static void com20020_config(dev_link_t *link)
321 DEBUG(1,"arcnet: request IRQ %d (%Xh/%Xh)\n", 301 DEBUG(1,"arcnet: request IRQ %d (%Xh/%Xh)\n",
322 link->irq.AssignedIRQ, 302 link->irq.AssignedIRQ,
323 link->irq.IRQInfo1, link->irq.IRQInfo2); 303 link->irq.IRQInfo1, link->irq.IRQInfo2);
324 i = pcmcia_request_irq(link->handle, &link->irq); 304 i = pcmcia_request_irq(link, &link->irq);
325 if (i != CS_SUCCESS) 305 if (i != CS_SUCCESS)
326 { 306 {
327 DEBUG(1,"arcnet: requestIRQ failed totally!\n"); 307 DEBUG(1,"arcnet: requestIRQ failed totally!\n");
@@ -330,7 +310,7 @@ static void com20020_config(dev_link_t *link)
330 310
331 dev->irq = link->irq.AssignedIRQ; 311 dev->irq = link->irq.AssignedIRQ;
332 312
333 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 313 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
334 314
335 if (com20020_check(dev)) 315 if (com20020_check(dev))
336 { 316 {
@@ -342,15 +322,14 @@ static void com20020_config(dev_link_t *link)
342 lp->card_name = "PCMCIA COM20020"; 322 lp->card_name = "PCMCIA COM20020";
343 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 */
344 324
345 link->dev = &info->node; 325 link->dev_node = &info->node;
346 link->state &= ~DEV_CONFIG_PENDING; 326 SET_NETDEV_DEV(dev, &handle_to_dev(link));
347 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
348 327
349 i = com20020_found(dev, 0); /* calls register_netdev */ 328 i = com20020_found(dev, 0); /* calls register_netdev */
350 329
351 if (i != 0) { 330 if (i != 0) {
352 DEBUG(1,KERN_NOTICE "com20020_cs: com20020_found() failed\n"); 331 DEBUG(1,KERN_NOTICE "com20020_cs: com20020_found() failed\n");
353 link->dev = NULL; 332 link->dev_node = NULL;
354 goto failed; 333 goto failed;
355 } 334 }
356 335
@@ -358,13 +337,14 @@ static void com20020_config(dev_link_t *link)
358 337
359 DEBUG(1,KERN_INFO "%s: port %#3lx, irq %d\n", 338 DEBUG(1,KERN_INFO "%s: port %#3lx, irq %d\n",
360 dev->name, dev->base_addr, dev->irq); 339 dev->name, dev->base_addr, dev->irq);
361 return; 340 return 0;
362 341
363cs_failed: 342cs_failed:
364 cs_error(link->handle, last_fn, last_ret); 343 cs_error(link, last_fn, last_ret);
365failed: 344failed:
366 DEBUG(1,"com20020_config failed...\n"); 345 DEBUG(1,"com20020_config failed...\n");
367 com20020_release(link); 346 com20020_release(link);
347 return -ENODEV;
368} /* com20020_config */ 348} /* com20020_config */
369 349
370/*====================================================================== 350/*======================================================================
@@ -375,52 +355,33 @@ failed:
375 355
376======================================================================*/ 356======================================================================*/
377 357
378static void com20020_release(dev_link_t *link) 358static void com20020_release(struct pcmcia_device *link)
379{ 359{
380 360 DEBUG(0, "com20020_release(0x%p)\n", link);
381 DEBUG(1,"release...\n"); 361 pcmcia_disable_device(link);
382
383 DEBUG(0, "com20020_release(0x%p)\n", link);
384
385 pcmcia_release_configuration(link->handle);
386 pcmcia_release_io(link->handle, &link->io);
387 pcmcia_release_irq(link->handle, &link->irq);
388
389 link->state &= ~(DEV_CONFIG | DEV_RELEASE_PENDING);
390} 362}
391 363
392static int com20020_suspend(struct pcmcia_device *p_dev) 364static int com20020_suspend(struct pcmcia_device *link)
393{ 365{
394 dev_link_t *link = dev_to_instance(p_dev);
395 com20020_dev_t *info = link->priv; 366 com20020_dev_t *info = link->priv;
396 struct net_device *dev = info->dev; 367 struct net_device *dev = info->dev;
397 368
398 link->state |= DEV_SUSPEND; 369 if (link->open)
399 if (link->state & DEV_CONFIG) { 370 netif_device_detach(dev);
400 if (link->open) {
401 netif_device_detach(dev);
402 }
403 pcmcia_release_configuration(link->handle);
404 }
405 371
406 return 0; 372 return 0;
407} 373}
408 374
409static int com20020_resume(struct pcmcia_device *p_dev) 375static int com20020_resume(struct pcmcia_device *link)
410{ 376{
411 dev_link_t *link = dev_to_instance(p_dev);
412 com20020_dev_t *info = link->priv; 377 com20020_dev_t *info = link->priv;
413 struct net_device *dev = info->dev; 378 struct net_device *dev = info->dev;
414 379
415 link->state &= ~DEV_SUSPEND; 380 if (link->open) {
416 if (link->state & DEV_CONFIG) { 381 int ioaddr = dev->base_addr;
417 pcmcia_request_configuration(link->handle, &link->conf); 382 struct arcnet_local *lp = dev->priv;
418 if (link->open) { 383 ARCRESET;
419 int ioaddr = dev->base_addr; 384 }
420 struct arcnet_local *lp = dev->priv;
421 ARCRESET;
422 }
423 }
424 385
425 return 0; 386 return 0;
426} 387}
@@ -436,7 +397,7 @@ static struct pcmcia_driver com20020_cs_driver = {
436 .drv = { 397 .drv = {
437 .name = "com20020_cs", 398 .name = "com20020_cs",
438 }, 399 },
439 .probe = com20020_attach, 400 .probe = com20020_probe,
440 .remove = com20020_detach, 401 .remove = com20020_detach,
441 .id_table = com20020_ids, 402 .id_table = com20020_ids,
442 .suspend = com20020_suspend, 403 .suspend = com20020_suspend,
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index b7ac14ba8877..09b11761cdfa 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -84,10 +84,10 @@ static char *version = DRV_NAME ".c " DRV_VERSION " 2002/03/23";
84/* 84/*
85 PCMCIA event handlers 85 PCMCIA event handlers
86 */ 86 */
87static void fmvj18x_config(dev_link_t *link); 87static int fmvj18x_config(struct pcmcia_device *link);
88static int fmvj18x_get_hwinfo(dev_link_t *link, u_char *node_id); 88static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id);
89static int fmvj18x_setup_mfc(dev_link_t *link); 89static int fmvj18x_setup_mfc(struct pcmcia_device *link);
90static void fmvj18x_release(dev_link_t *link); 90static void fmvj18x_release(struct pcmcia_device *link);
91static void fmvj18x_detach(struct pcmcia_device *p_dev); 91static void fmvj18x_detach(struct pcmcia_device *p_dev);
92 92
93/* 93/*
@@ -116,7 +116,7 @@ typedef enum { MBH10302, MBH10304, TDK, CONTEC, LA501, UNGERMANN,
116 driver specific data structure 116 driver specific data structure
117*/ 117*/
118typedef struct local_info_t { 118typedef struct local_info_t {
119 dev_link_t link; 119 struct pcmcia_device *p_dev;
120 dev_node_t node; 120 dev_node_t node;
121 struct net_device_stats stats; 121 struct net_device_stats stats;
122 long open_time; 122 long open_time;
@@ -228,10 +228,9 @@ typedef struct local_info_t {
228#define BANK_1U 0x24 /* bank 1 (CONFIG_1) */ 228#define BANK_1U 0x24 /* bank 1 (CONFIG_1) */
229#define BANK_2U 0x28 /* bank 2 (CONFIG_1) */ 229#define BANK_2U 0x28 /* bank 2 (CONFIG_1) */
230 230
231static int fmvj18x_attach(struct pcmcia_device *p_dev) 231static int fmvj18x_probe(struct pcmcia_device *link)
232{ 232{
233 local_info_t *lp; 233 local_info_t *lp;
234 dev_link_t *link;
235 struct net_device *dev; 234 struct net_device *dev;
236 235
237 DEBUG(0, "fmvj18x_attach()\n"); 236 DEBUG(0, "fmvj18x_attach()\n");
@@ -241,8 +240,8 @@ static int fmvj18x_attach(struct pcmcia_device *p_dev)
241 if (!dev) 240 if (!dev)
242 return -ENOMEM; 241 return -ENOMEM;
243 lp = netdev_priv(dev); 242 lp = netdev_priv(dev);
244 link = &lp->link;
245 link->priv = dev; 243 link->priv = dev;
244 lp->p_dev = link;
246 245
247 /* The io structure describes IO port mapping */ 246 /* The io structure describes IO port mapping */
248 link->io.NumPorts1 = 32; 247 link->io.NumPorts1 = 32;
@@ -257,7 +256,6 @@ static int fmvj18x_attach(struct pcmcia_device *p_dev)
257 256
258 /* General socket configuration */ 257 /* General socket configuration */
259 link->conf.Attributes = CONF_ENABLE_IRQ; 258 link->conf.Attributes = CONF_ENABLE_IRQ;
260 link->conf.Vcc = 50;
261 link->conf.IntType = INT_MEMORY_AND_IO; 259 link->conf.IntType = INT_MEMORY_AND_IO;
262 260
263 /* The FMVJ18x specific entries in the device structure. */ 261 /* The FMVJ18x specific entries in the device structure. */
@@ -274,29 +272,21 @@ static int fmvj18x_attach(struct pcmcia_device *p_dev)
274#endif 272#endif
275 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 273 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
276 274
277 link->handle = p_dev; 275 return fmvj18x_config(link);
278 p_dev->instance = link;
279
280 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
281 fmvj18x_config(link);
282
283 return 0;
284} /* fmvj18x_attach */ 276} /* fmvj18x_attach */
285 277
286/*====================================================================*/ 278/*====================================================================*/
287 279
288static void fmvj18x_detach(struct pcmcia_device *p_dev) 280static void fmvj18x_detach(struct pcmcia_device *link)
289{ 281{
290 dev_link_t *link = dev_to_instance(p_dev);
291 struct net_device *dev = link->priv; 282 struct net_device *dev = link->priv;
292 283
293 DEBUG(0, "fmvj18x_detach(0x%p)\n", link); 284 DEBUG(0, "fmvj18x_detach(0x%p)\n", link);
294 285
295 if (link->dev) 286 if (link->dev_node)
296 unregister_netdev(dev); 287 unregister_netdev(dev);
297 288
298 if (link->state & DEV_CONFIG) 289 fmvj18x_release(link);
299 fmvj18x_release(link);
300 290
301 free_netdev(dev); 291 free_netdev(dev);
302} /* fmvj18x_detach */ 292} /* fmvj18x_detach */
@@ -306,7 +296,7 @@ static void fmvj18x_detach(struct pcmcia_device *p_dev)
306#define CS_CHECK(fn, ret) \ 296#define CS_CHECK(fn, ret) \
307do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 297do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
308 298
309static int mfc_try_io_port(dev_link_t *link) 299static int mfc_try_io_port(struct pcmcia_device *link)
310{ 300{
311 int i, ret; 301 int i, ret;
312 static const kio_addr_t serial_base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 302 static const kio_addr_t serial_base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
@@ -318,13 +308,13 @@ static int mfc_try_io_port(dev_link_t *link)
318 link->io.NumPorts2 = 0; 308 link->io.NumPorts2 = 0;
319 printk(KERN_NOTICE "fmvj18x_cs: out of resource for serial\n"); 309 printk(KERN_NOTICE "fmvj18x_cs: out of resource for serial\n");
320 } 310 }
321 ret = pcmcia_request_io(link->handle, &link->io); 311 ret = pcmcia_request_io(link, &link->io);
322 if (ret == CS_SUCCESS) return ret; 312 if (ret == CS_SUCCESS) return ret;
323 } 313 }
324 return ret; 314 return ret;
325} 315}
326 316
327static int ungermann_try_io_port(dev_link_t *link) 317static int ungermann_try_io_port(struct pcmcia_device *link)
328{ 318{
329 int ret; 319 int ret;
330 kio_addr_t ioaddr; 320 kio_addr_t ioaddr;
@@ -334,7 +324,7 @@ static int ungermann_try_io_port(dev_link_t *link)
334 */ 324 */
335 for (ioaddr = 0x300; ioaddr < 0x3e0; ioaddr += 0x20) { 325 for (ioaddr = 0x300; ioaddr < 0x3e0; ioaddr += 0x20) {
336 link->io.BasePort1 = ioaddr; 326 link->io.BasePort1 = ioaddr;
337 ret = pcmcia_request_io(link->handle, &link->io); 327 ret = pcmcia_request_io(link, &link->io);
338 if (ret == CS_SUCCESS) { 328 if (ret == CS_SUCCESS) {
339 /* calculate ConfigIndex value */ 329 /* calculate ConfigIndex value */
340 link->conf.ConfigIndex = 330 link->conf.ConfigIndex =
@@ -345,9 +335,8 @@ static int ungermann_try_io_port(dev_link_t *link)
345 return ret; /* RequestIO failed */ 335 return ret; /* RequestIO failed */
346} 336}
347 337
348static void fmvj18x_config(dev_link_t *link) 338static int fmvj18x_config(struct pcmcia_device *link)
349{ 339{
350 client_handle_t handle = link->handle;
351 struct net_device *dev = link->priv; 340 struct net_device *dev = link->priv;
352 local_info_t *lp = netdev_priv(dev); 341 local_info_t *lp = netdev_priv(dev);
353 tuple_t tuple; 342 tuple_t tuple;
@@ -366,42 +355,34 @@ static void fmvj18x_config(dev_link_t *link)
366 registers. 355 registers.
367 */ 356 */
368 tuple.DesiredTuple = CISTPL_CONFIG; 357 tuple.DesiredTuple = CISTPL_CONFIG;
369 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 358 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
370 tuple.TupleData = (u_char *)buf; 359 tuple.TupleData = (u_char *)buf;
371 tuple.TupleDataMax = 64; 360 tuple.TupleDataMax = 64;
372 tuple.TupleOffset = 0; 361 tuple.TupleOffset = 0;
373 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 362 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
374 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 363 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
375
376 /* Configure card */
377 link->state |= DEV_CONFIG;
378 364
379 link->conf.ConfigBase = parse.config.base; 365 link->conf.ConfigBase = parse.config.base;
380 link->conf.Present = parse.config.rmask[0]; 366 link->conf.Present = parse.config.rmask[0];
381 367
382 tuple.DesiredTuple = CISTPL_FUNCE; 368 tuple.DesiredTuple = CISTPL_FUNCE;
383 tuple.TupleOffset = 0; 369 tuple.TupleOffset = 0;
384 if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) { 370 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) {
385 /* Yes, I have CISTPL_FUNCE. Let's check CISTPL_MANFID */ 371 /* Yes, I have CISTPL_FUNCE. Let's check CISTPL_MANFID */
386 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 372 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
387 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 373 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
388 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 374 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
389 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 375 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
390 link->conf.ConfigIndex = parse.cftable_entry.index; 376 link->conf.ConfigIndex = parse.cftable_entry.index;
391 tuple.DesiredTuple = CISTPL_MANFID; 377 tuple.DesiredTuple = CISTPL_MANFID;
392 if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) 378 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS)
393 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 379 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
394 else 380 else
395 buf[0] = 0xffff; 381 buf[0] = 0xffff;
396 switch (le16_to_cpu(buf[0])) { 382 switch (le16_to_cpu(buf[0])) {
397 case MANFID_TDK: 383 case MANFID_TDK:
398 cardtype = TDK; 384 cardtype = TDK;
399 if (le16_to_cpu(buf[1]) == PRODID_TDK_CF010) { 385 if (le16_to_cpu(buf[1]) == PRODID_TDK_GN3410
400 cs_status_t status;
401 pcmcia_get_status(handle, &status);
402 if (status.CardState & CS_EVENT_3VCARD)
403 link->conf.Vcc = 33; /* inserted in 3.3V slot */
404 } else if (le16_to_cpu(buf[1]) == PRODID_TDK_GN3410
405 || le16_to_cpu(buf[1]) == PRODID_TDK_NP9610 386 || le16_to_cpu(buf[1]) == PRODID_TDK_NP9610
406 || le16_to_cpu(buf[1]) == PRODID_TDK_MN3200) { 387 || le16_to_cpu(buf[1]) == PRODID_TDK_MN3200) {
407 /* MultiFunction Card */ 388 /* MultiFunction Card */
@@ -429,8 +410,8 @@ static void fmvj18x_config(dev_link_t *link)
429 } else { 410 } else {
430 /* old type card */ 411 /* old type card */
431 tuple.DesiredTuple = CISTPL_MANFID; 412 tuple.DesiredTuple = CISTPL_MANFID;
432 if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) 413 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS)
433 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 414 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
434 else 415 else
435 buf[0] = 0xffff; 416 buf[0] = 0xffff;
436 switch (le16_to_cpu(buf[0])) { 417 switch (le16_to_cpu(buf[0])) {
@@ -461,10 +442,10 @@ static void fmvj18x_config(dev_link_t *link)
461 ret = ungermann_try_io_port(link); 442 ret = ungermann_try_io_port(link);
462 if (ret != CS_SUCCESS) goto cs_failed; 443 if (ret != CS_SUCCESS) goto cs_failed;
463 } else { 444 } else {
464 CS_CHECK(RequestIO, pcmcia_request_io(link->handle, &link->io)); 445 CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io));
465 } 446 }
466 CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 447 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
467 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 448 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
468 dev->irq = link->irq.AssignedIRQ; 449 dev->irq = link->irq.AssignedIRQ;
469 dev->base_addr = link->io.BasePort1; 450 dev->base_addr = link->io.BasePort1;
470 451
@@ -493,17 +474,17 @@ static void fmvj18x_config(dev_link_t *link)
493 case CONTEC: 474 case CONTEC:
494 tuple.DesiredTuple = CISTPL_FUNCE; 475 tuple.DesiredTuple = CISTPL_FUNCE;
495 tuple.TupleOffset = 0; 476 tuple.TupleOffset = 0;
496 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 477 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
497 tuple.TupleOffset = 0; 478 tuple.TupleOffset = 0;
498 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 479 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
499 if (cardtype == MBH10304) { 480 if (cardtype == MBH10304) {
500 /* MBH10304's CIS_FUNCE is corrupted */ 481 /* MBH10304's CIS_FUNCE is corrupted */
501 node_id = &(tuple.TupleData[5]); 482 node_id = &(tuple.TupleData[5]);
502 card_name = "FMV-J182"; 483 card_name = "FMV-J182";
503 } else { 484 } else {
504 while (tuple.TupleData[0] != CISTPL_FUNCE_LAN_NODE_ID ) { 485 while (tuple.TupleData[0] != CISTPL_FUNCE_LAN_NODE_ID ) {
505 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); 486 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple));
506 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 487 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
507 } 488 }
508 node_id = &(tuple.TupleData[2]); 489 node_id = &(tuple.TupleData[2]);
509 if( cardtype == TDK ) { 490 if( cardtype == TDK ) {
@@ -545,13 +526,12 @@ static void fmvj18x_config(dev_link_t *link)
545 } 526 }
546 527
547 lp->cardtype = cardtype; 528 lp->cardtype = cardtype;
548 link->dev = &lp->node; 529 link->dev_node = &lp->node;
549 link->state &= ~DEV_CONFIG_PENDING; 530 SET_NETDEV_DEV(dev, &handle_to_dev(link));
550 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
551 531
552 if (register_netdev(dev) != 0) { 532 if (register_netdev(dev) != 0) {
553 printk(KERN_NOTICE "fmvj18x_cs: register_netdev() failed\n"); 533 printk(KERN_NOTICE "fmvj18x_cs: register_netdev() failed\n");
554 link->dev = NULL; 534 link->dev_node = NULL;
555 goto failed; 535 goto failed;
556 } 536 }
557 537
@@ -564,19 +544,18 @@ static void fmvj18x_config(dev_link_t *link)
564 for (i = 0; i < 6; i++) 544 for (i = 0; i < 6; i++)
565 printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n")); 545 printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n"));
566 546
567 return; 547 return 0;
568 548
569cs_failed: 549cs_failed:
570 /* All Card Services errors end up here */ 550 /* All Card Services errors end up here */
571 cs_error(link->handle, last_fn, last_ret); 551 cs_error(link, last_fn, last_ret);
572failed: 552failed:
573 fmvj18x_release(link); 553 fmvj18x_release(link);
574 link->state &= ~DEV_CONFIG_PENDING; 554 return -ENODEV;
575
576} /* fmvj18x_config */ 555} /* fmvj18x_config */
577/*====================================================================*/ 556/*====================================================================*/
578 557
579static int fmvj18x_get_hwinfo(dev_link_t *link, u_char *node_id) 558static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id)
580{ 559{
581 win_req_t req; 560 win_req_t req;
582 memreq_t mem; 561 memreq_t mem;
@@ -587,9 +566,9 @@ static int fmvj18x_get_hwinfo(dev_link_t *link, u_char *node_id)
587 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 566 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
588 req.Base = 0; req.Size = 0; 567 req.Base = 0; req.Size = 0;
589 req.AccessSpeed = 0; 568 req.AccessSpeed = 0;
590 i = pcmcia_request_window(&link->handle, &req, &link->win); 569 i = pcmcia_request_window(&link, &req, &link->win);
591 if (i != CS_SUCCESS) { 570 if (i != CS_SUCCESS) {
592 cs_error(link->handle, RequestWindow, i); 571 cs_error(link, RequestWindow, i);
593 return -1; 572 return -1;
594 } 573 }
595 574
@@ -623,13 +602,13 @@ static int fmvj18x_get_hwinfo(dev_link_t *link, u_char *node_id)
623 iounmap(base); 602 iounmap(base);
624 j = pcmcia_release_window(link->win); 603 j = pcmcia_release_window(link->win);
625 if (j != CS_SUCCESS) 604 if (j != CS_SUCCESS)
626 cs_error(link->handle, ReleaseWindow, j); 605 cs_error(link, ReleaseWindow, j);
627 return (i != 0x200) ? 0 : -1; 606 return (i != 0x200) ? 0 : -1;
628 607
629} /* fmvj18x_get_hwinfo */ 608} /* fmvj18x_get_hwinfo */
630/*====================================================================*/ 609/*====================================================================*/
631 610
632static int fmvj18x_setup_mfc(dev_link_t *link) 611static int fmvj18x_setup_mfc(struct pcmcia_device *link)
633{ 612{
634 win_req_t req; 613 win_req_t req;
635 memreq_t mem; 614 memreq_t mem;
@@ -642,9 +621,9 @@ static int fmvj18x_setup_mfc(dev_link_t *link)
642 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 621 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
643 req.Base = 0; req.Size = 0; 622 req.Base = 0; req.Size = 0;
644 req.AccessSpeed = 0; 623 req.AccessSpeed = 0;
645 i = pcmcia_request_window(&link->handle, &req, &link->win); 624 i = pcmcia_request_window(&link, &req, &link->win);
646 if (i != CS_SUCCESS) { 625 if (i != CS_SUCCESS) {
647 cs_error(link->handle, RequestWindow, i); 626 cs_error(link, RequestWindow, i);
648 return -1; 627 return -1;
649 } 628 }
650 629
@@ -666,54 +645,35 @@ static int fmvj18x_setup_mfc(dev_link_t *link)
666 iounmap(base); 645 iounmap(base);
667 j = pcmcia_release_window(link->win); 646 j = pcmcia_release_window(link->win);
668 if (j != CS_SUCCESS) 647 if (j != CS_SUCCESS)
669 cs_error(link->handle, ReleaseWindow, j); 648 cs_error(link, ReleaseWindow, j);
670 return 0; 649 return 0;
671 650
672} 651}
673/*====================================================================*/ 652/*====================================================================*/
674 653
675static void fmvj18x_release(dev_link_t *link) 654static void fmvj18x_release(struct pcmcia_device *link)
676{ 655{
677 656 DEBUG(0, "fmvj18x_release(0x%p)\n", link);
678 DEBUG(0, "fmvj18x_release(0x%p)\n", link); 657 pcmcia_disable_device(link);
679
680 /* Don't bother checking to see if these succeed or not */
681 pcmcia_release_window(link->win);
682 pcmcia_release_configuration(link->handle);
683 pcmcia_release_io(link->handle, &link->io);
684 pcmcia_release_irq(link->handle, &link->irq);
685
686 link->state &= ~DEV_CONFIG;
687} 658}
688 659
689static int fmvj18x_suspend(struct pcmcia_device *p_dev) 660static int fmvj18x_suspend(struct pcmcia_device *link)
690{ 661{
691 dev_link_t *link = dev_to_instance(p_dev);
692 struct net_device *dev = link->priv; 662 struct net_device *dev = link->priv;
693 663
694 link->state |= DEV_SUSPEND; 664 if (link->open)
695 if (link->state & DEV_CONFIG) { 665 netif_device_detach(dev);
696 if (link->open)
697 netif_device_detach(dev);
698 pcmcia_release_configuration(link->handle);
699 }
700
701 666
702 return 0; 667 return 0;
703} 668}
704 669
705static int fmvj18x_resume(struct pcmcia_device *p_dev) 670static int fmvj18x_resume(struct pcmcia_device *link)
706{ 671{
707 dev_link_t *link = dev_to_instance(p_dev);
708 struct net_device *dev = link->priv; 672 struct net_device *dev = link->priv;
709 673
710 link->state &= ~DEV_SUSPEND; 674 if (link->open) {
711 if (link->state & DEV_CONFIG) { 675 fjn_reset(dev);
712 pcmcia_request_configuration(link->handle, &link->conf); 676 netif_device_attach(dev);
713 if (link->open) {
714 fjn_reset(dev);
715 netif_device_attach(dev);
716 }
717 } 677 }
718 678
719 return 0; 679 return 0;
@@ -751,7 +711,7 @@ static struct pcmcia_driver fmvj18x_cs_driver = {
751 .drv = { 711 .drv = {
752 .name = "fmvj18x_cs", 712 .name = "fmvj18x_cs",
753 }, 713 },
754 .probe = fmvj18x_attach, 714 .probe = fmvj18x_probe,
755 .remove = fmvj18x_detach, 715 .remove = fmvj18x_detach,
756 .id_table = fmvj18x_ids, 716 .id_table = fmvj18x_ids,
757 .suspend = fmvj18x_suspend, 717 .suspend = fmvj18x_suspend,
@@ -1148,11 +1108,11 @@ static int fjn_config(struct net_device *dev, struct ifmap *map){
1148static int fjn_open(struct net_device *dev) 1108static int fjn_open(struct net_device *dev)
1149{ 1109{
1150 struct local_info_t *lp = netdev_priv(dev); 1110 struct local_info_t *lp = netdev_priv(dev);
1151 dev_link_t *link = &lp->link; 1111 struct pcmcia_device *link = lp->p_dev;
1152 1112
1153 DEBUG(4, "fjn_open('%s').\n", dev->name); 1113 DEBUG(4, "fjn_open('%s').\n", dev->name);
1154 1114
1155 if (!DEV_OK(link)) 1115 if (!pcmcia_dev_present(link))
1156 return -ENODEV; 1116 return -ENODEV;
1157 1117
1158 link->open++; 1118 link->open++;
@@ -1173,7 +1133,7 @@ static int fjn_open(struct net_device *dev)
1173static int fjn_close(struct net_device *dev) 1133static int fjn_close(struct net_device *dev)
1174{ 1134{
1175 struct local_info_t *lp = netdev_priv(dev); 1135 struct local_info_t *lp = netdev_priv(dev);
1176 dev_link_t *link = &lp->link; 1136 struct pcmcia_device *link = lp->p_dev;
1177 kio_addr_t ioaddr = dev->base_addr; 1137 kio_addr_t ioaddr = dev->base_addr;
1178 1138
1179 DEBUG(4, "fjn_close('%s').\n", dev->name); 1139 DEBUG(4, "fjn_close('%s').\n", dev->name);
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
index b9c7e39576f5..b8fe70b85641 100644
--- a/drivers/net/pcmcia/ibmtr_cs.c
+++ b/drivers/net/pcmcia/ibmtr_cs.c
@@ -105,15 +105,15 @@ MODULE_LICENSE("GPL");
105 105
106/*====================================================================*/ 106/*====================================================================*/
107 107
108static void ibmtr_config(dev_link_t *link); 108static int ibmtr_config(struct pcmcia_device *link);
109static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase); 109static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase);
110static void ibmtr_release(dev_link_t *link); 110static void ibmtr_release(struct pcmcia_device *link);
111static void ibmtr_detach(struct pcmcia_device *p_dev); 111static void ibmtr_detach(struct pcmcia_device *p_dev);
112 112
113/*====================================================================*/ 113/*====================================================================*/
114 114
115typedef struct ibmtr_dev_t { 115typedef struct ibmtr_dev_t {
116 dev_link_t link; 116 struct pcmcia_device *p_dev;
117 struct net_device *dev; 117 struct net_device *dev;
118 dev_node_t node; 118 dev_node_t node;
119 window_handle_t sram_win_handle; 119 window_handle_t sram_win_handle;
@@ -138,12 +138,11 @@ static struct ethtool_ops netdev_ethtool_ops = {
138 138
139======================================================================*/ 139======================================================================*/
140 140
141static int ibmtr_attach(struct pcmcia_device *p_dev) 141static int ibmtr_attach(struct pcmcia_device *link)
142{ 142{
143 ibmtr_dev_t *info; 143 ibmtr_dev_t *info;
144 dev_link_t *link;
145 struct net_device *dev; 144 struct net_device *dev;
146 145
147 DEBUG(0, "ibmtr_attach()\n"); 146 DEBUG(0, "ibmtr_attach()\n");
148 147
149 /* Create new token-ring device */ 148 /* Create new token-ring device */
@@ -156,7 +155,7 @@ static int ibmtr_attach(struct pcmcia_device *p_dev)
156 return -ENOMEM; 155 return -ENOMEM;
157 } 156 }
158 157
159 link = &info->link; 158 info->p_dev = link;
160 link->priv = info; 159 link->priv = info;
161 info->ti = netdev_priv(dev); 160 info->ti = netdev_priv(dev);
162 161
@@ -167,21 +166,14 @@ static int ibmtr_attach(struct pcmcia_device *p_dev)
167 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 166 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
168 link->irq.Handler = &tok_interrupt; 167 link->irq.Handler = &tok_interrupt;
169 link->conf.Attributes = CONF_ENABLE_IRQ; 168 link->conf.Attributes = CONF_ENABLE_IRQ;
170 link->conf.Vcc = 50;
171 link->conf.IntType = INT_MEMORY_AND_IO; 169 link->conf.IntType = INT_MEMORY_AND_IO;
172 link->conf.Present = PRESENT_OPTION; 170 link->conf.Present = PRESENT_OPTION;
173 171
174 link->irq.Instance = info->dev = dev; 172 link->irq.Instance = info->dev = dev;
175
176 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
177
178 link->handle = p_dev;
179 p_dev->instance = link;
180 173
181 link->state |= DEV_PRESENT; 174 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
182 ibmtr_config(link);
183 175
184 return 0; 176 return ibmtr_config(link);
185} /* ibmtr_attach */ 177} /* ibmtr_attach */
186 178
187/*====================================================================== 179/*======================================================================
@@ -193,23 +185,22 @@ static int ibmtr_attach(struct pcmcia_device *p_dev)
193 185
194======================================================================*/ 186======================================================================*/
195 187
196static void ibmtr_detach(struct pcmcia_device *p_dev) 188static void ibmtr_detach(struct pcmcia_device *link)
197{ 189{
198 dev_link_t *link = dev_to_instance(p_dev);
199 struct ibmtr_dev_t *info = link->priv; 190 struct ibmtr_dev_t *info = link->priv;
200 struct net_device *dev = info->dev; 191 struct net_device *dev = info->dev;
201 192
202 DEBUG(0, "ibmtr_detach(0x%p)\n", link); 193 DEBUG(0, "ibmtr_detach(0x%p)\n", link);
203 194
204 if (link->dev) 195 if (link->dev_node)
205 unregister_netdev(dev); 196 unregister_netdev(dev);
206 197
207 { 198 {
208 struct tok_info *ti = netdev_priv(dev); 199 struct tok_info *ti = netdev_priv(dev);
209 del_timer_sync(&(ti->tr_timer)); 200 del_timer_sync(&(ti->tr_timer));
210 } 201 }
211 if (link->state & DEV_CONFIG) 202
212 ibmtr_release(link); 203 ibmtr_release(link);
213 204
214 free_netdev(dev); 205 free_netdev(dev);
215 kfree(info); 206 kfree(info);
@@ -226,9 +217,8 @@ static void ibmtr_detach(struct pcmcia_device *p_dev)
226#define CS_CHECK(fn, ret) \ 217#define CS_CHECK(fn, ret) \
227do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 218do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
228 219
229static void ibmtr_config(dev_link_t *link) 220static int ibmtr_config(struct pcmcia_device *link)
230{ 221{
231 client_handle_t handle = link->handle;
232 ibmtr_dev_t *info = link->priv; 222 ibmtr_dev_t *info = link->priv;
233 struct net_device *dev = info->dev; 223 struct net_device *dev = info->dev;
234 struct tok_info *ti = netdev_priv(dev); 224 struct tok_info *ti = netdev_priv(dev);
@@ -246,29 +236,25 @@ static void ibmtr_config(dev_link_t *link)
246 tuple.TupleDataMax = 64; 236 tuple.TupleDataMax = 64;
247 tuple.TupleOffset = 0; 237 tuple.TupleOffset = 0;
248 tuple.DesiredTuple = CISTPL_CONFIG; 238 tuple.DesiredTuple = CISTPL_CONFIG;
249 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 239 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
250 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 240 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
251 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 241 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
252 link->conf.ConfigBase = parse.config.base; 242 link->conf.ConfigBase = parse.config.base;
253
254 /* Configure card */
255 link->state |= DEV_CONFIG;
256
257 link->conf.ConfigIndex = 0x61; 243 link->conf.ConfigIndex = 0x61;
258 244
259 /* Determine if this is PRIMARY or ALTERNATE. */ 245 /* Determine if this is PRIMARY or ALTERNATE. */
260 246
261 /* Try PRIMARY card at 0xA20-0xA23 */ 247 /* Try PRIMARY card at 0xA20-0xA23 */
262 link->io.BasePort1 = 0xA20; 248 link->io.BasePort1 = 0xA20;
263 i = pcmcia_request_io(link->handle, &link->io); 249 i = pcmcia_request_io(link, &link->io);
264 if (i != CS_SUCCESS) { 250 if (i != CS_SUCCESS) {
265 /* Couldn't get 0xA20-0xA23. Try ALTERNATE at 0xA24-0xA27. */ 251 /* Couldn't get 0xA20-0xA23. Try ALTERNATE at 0xA24-0xA27. */
266 link->io.BasePort1 = 0xA24; 252 link->io.BasePort1 = 0xA24;
267 CS_CHECK(RequestIO, pcmcia_request_io(link->handle, &link->io)); 253 CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io));
268 } 254 }
269 dev->base_addr = link->io.BasePort1; 255 dev->base_addr = link->io.BasePort1;
270 256
271 CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 257 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
272 dev->irq = link->irq.AssignedIRQ; 258 dev->irq = link->irq.AssignedIRQ;
273 ti->irq = link->irq.AssignedIRQ; 259 ti->irq = link->irq.AssignedIRQ;
274 ti->global_int_enable=GLOBAL_INT_ENABLE+((dev->irq==9) ? 2 : dev->irq); 260 ti->global_int_enable=GLOBAL_INT_ENABLE+((dev->irq==9) ? 2 : dev->irq);
@@ -279,7 +265,7 @@ static void ibmtr_config(dev_link_t *link)
279 req.Base = 0; 265 req.Base = 0;
280 req.Size = 0x2000; 266 req.Size = 0x2000;
281 req.AccessSpeed = 250; 267 req.AccessSpeed = 250;
282 CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &link->win)); 268 CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win));
283 269
284 mem.CardOffset = mmiobase; 270 mem.CardOffset = mmiobase;
285 mem.Page = 0; 271 mem.Page = 0;
@@ -292,7 +278,7 @@ static void ibmtr_config(dev_link_t *link)
292 req.Base = 0; 278 req.Base = 0;
293 req.Size = sramsize * 1024; 279 req.Size = sramsize * 1024;
294 req.AccessSpeed = 250; 280 req.AccessSpeed = 250;
295 CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &info->sram_win_handle)); 281 CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &info->sram_win_handle));
296 282
297 mem.CardOffset = srambase; 283 mem.CardOffset = srambase;
298 mem.Page = 0; 284 mem.Page = 0;
@@ -302,21 +288,20 @@ static void ibmtr_config(dev_link_t *link)
302 ti->sram_virt = ioremap(req.Base, req.Size); 288 ti->sram_virt = ioremap(req.Base, req.Size);
303 ti->sram_phys = req.Base; 289 ti->sram_phys = req.Base;
304 290
305 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 291 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
306 292
307 /* Set up the Token-Ring Controller Configuration Register and 293 /* Set up the Token-Ring Controller Configuration Register and
308 turn on the card. Check the "Local Area Network Credit Card 294 turn on the card. Check the "Local Area Network Credit Card
309 Adapters Technical Reference" SC30-3585 for this info. */ 295 Adapters Technical Reference" SC30-3585 for this info. */
310 ibmtr_hw_setup(dev, mmiobase); 296 ibmtr_hw_setup(dev, mmiobase);
311 297
312 link->dev = &info->node; 298 link->dev_node = &info->node;
313 link->state &= ~DEV_CONFIG_PENDING; 299 SET_NETDEV_DEV(dev, &handle_to_dev(link));
314 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
315 300
316 i = ibmtr_probe_card(dev); 301 i = ibmtr_probe_card(dev);
317 if (i != 0) { 302 if (i != 0) {
318 printk(KERN_NOTICE "ibmtr_cs: register_netdev() failed\n"); 303 printk(KERN_NOTICE "ibmtr_cs: register_netdev() failed\n");
319 link->dev = NULL; 304 link->dev_node = NULL;
320 goto failed; 305 goto failed;
321 } 306 }
322 307
@@ -330,12 +315,13 @@ static void ibmtr_config(dev_link_t *link)
330 for (i = 0; i < TR_ALEN; i++) 315 for (i = 0; i < TR_ALEN; i++)
331 printk("%02X", dev->dev_addr[i]); 316 printk("%02X", dev->dev_addr[i]);
332 printk("\n"); 317 printk("\n");
333 return; 318 return 0;
334 319
335cs_failed: 320cs_failed:
336 cs_error(link->handle, last_fn, last_ret); 321 cs_error(link, last_fn, last_ret);
337failed: 322failed:
338 ibmtr_release(link); 323 ibmtr_release(link);
324 return -ENODEV;
339} /* ibmtr_config */ 325} /* ibmtr_config */
340 326
341/*====================================================================== 327/*======================================================================
@@ -346,56 +332,41 @@ failed:
346 332
347======================================================================*/ 333======================================================================*/
348 334
349static void ibmtr_release(dev_link_t *link) 335static void ibmtr_release(struct pcmcia_device *link)
350{ 336{
351 ibmtr_dev_t *info = link->priv; 337 ibmtr_dev_t *info = link->priv;
352 struct net_device *dev = info->dev; 338 struct net_device *dev = info->dev;
353
354 DEBUG(0, "ibmtr_release(0x%p)\n", link);
355 339
356 pcmcia_release_configuration(link->handle); 340 DEBUG(0, "ibmtr_release(0x%p)\n", link);
357 pcmcia_release_io(link->handle, &link->io);
358 pcmcia_release_irq(link->handle, &link->irq);
359 if (link->win) {
360 struct tok_info *ti = netdev_priv(dev);
361 iounmap(ti->mmio);
362 pcmcia_release_window(link->win);
363 pcmcia_release_window(info->sram_win_handle);
364 }
365 341
366 link->state &= ~DEV_CONFIG; 342 if (link->win) {
343 struct tok_info *ti = netdev_priv(dev);
344 iounmap(ti->mmio);
345 pcmcia_release_window(info->sram_win_handle);
346 }
347 pcmcia_disable_device(link);
367} 348}
368 349
369static int ibmtr_suspend(struct pcmcia_device *p_dev) 350static int ibmtr_suspend(struct pcmcia_device *link)
370{ 351{
371 dev_link_t *link = dev_to_instance(p_dev);
372 ibmtr_dev_t *info = link->priv; 352 ibmtr_dev_t *info = link->priv;
373 struct net_device *dev = info->dev; 353 struct net_device *dev = info->dev;
374 354
375 link->state |= DEV_SUSPEND; 355 if (link->open)
376 if (link->state & DEV_CONFIG) { 356 netif_device_detach(dev);
377 if (link->open)
378 netif_device_detach(dev);
379 pcmcia_release_configuration(link->handle);
380 }
381 357
382 return 0; 358 return 0;
383} 359}
384 360
385static int ibmtr_resume(struct pcmcia_device *p_dev) 361static int ibmtr_resume(struct pcmcia_device *link)
386{ 362{
387 dev_link_t *link = dev_to_instance(p_dev);
388 ibmtr_dev_t *info = link->priv; 363 ibmtr_dev_t *info = link->priv;
389 struct net_device *dev = info->dev; 364 struct net_device *dev = info->dev;
390 365
391 link->state &= ~DEV_SUSPEND; 366 if (link->open) {
392 if (link->state & DEV_CONFIG) { 367 ibmtr_probe(dev); /* really? */
393 pcmcia_request_configuration(link->handle, &link->conf); 368 netif_device_attach(dev);
394 if (link->open) { 369 }
395 ibmtr_probe(dev); /* really? */
396 netif_device_attach(dev);
397 }
398 }
399 370
400 return 0; 371 return 0;
401} 372}
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index 787176c57fd9..4260c2128f47 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -362,7 +362,7 @@ typedef struct _mace_statistics {
362} mace_statistics; 362} mace_statistics;
363 363
364typedef struct _mace_private { 364typedef struct _mace_private {
365 dev_link_t link; 365 struct pcmcia_device *p_dev;
366 dev_node_t node; 366 dev_node_t node;
367 struct net_device_stats linux_stats; /* Linux statistics counters */ 367 struct net_device_stats linux_stats; /* Linux statistics counters */
368 mace_statistics mace_stats; /* MACE chip statistics counters */ 368 mace_statistics mace_stats; /* MACE chip statistics counters */
@@ -417,8 +417,8 @@ INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG);
417Function Prototypes 417Function Prototypes
418---------------------------------------------------------------------------- */ 418---------------------------------------------------------------------------- */
419 419
420static void nmclan_config(dev_link_t *link); 420static int nmclan_config(struct pcmcia_device *link);
421static void nmclan_release(dev_link_t *link); 421static void nmclan_release(struct pcmcia_device *link);
422 422
423static void nmclan_reset(struct net_device *dev); 423static void nmclan_reset(struct net_device *dev);
424static int mace_config(struct net_device *dev, struct ifmap *map); 424static int mace_config(struct net_device *dev, struct ifmap *map);
@@ -443,10 +443,9 @@ nmclan_attach
443 Services. 443 Services.
444---------------------------------------------------------------------------- */ 444---------------------------------------------------------------------------- */
445 445
446static int nmclan_attach(struct pcmcia_device *p_dev) 446static int nmclan_probe(struct pcmcia_device *link)
447{ 447{
448 mace_private *lp; 448 mace_private *lp;
449 dev_link_t *link;
450 struct net_device *dev; 449 struct net_device *dev;
451 450
452 DEBUG(0, "nmclan_attach()\n"); 451 DEBUG(0, "nmclan_attach()\n");
@@ -457,7 +456,7 @@ static int nmclan_attach(struct pcmcia_device *p_dev)
457 if (!dev) 456 if (!dev)
458 return -ENOMEM; 457 return -ENOMEM;
459 lp = netdev_priv(dev); 458 lp = netdev_priv(dev);
460 link = &lp->link; 459 lp->p_dev = link;
461 link->priv = dev; 460 link->priv = dev;
462 461
463 spin_lock_init(&lp->bank_lock); 462 spin_lock_init(&lp->bank_lock);
@@ -469,7 +468,6 @@ static int nmclan_attach(struct pcmcia_device *p_dev)
469 link->irq.Handler = &mace_interrupt; 468 link->irq.Handler = &mace_interrupt;
470 link->irq.Instance = dev; 469 link->irq.Instance = dev;
471 link->conf.Attributes = CONF_ENABLE_IRQ; 470 link->conf.Attributes = CONF_ENABLE_IRQ;
472 link->conf.Vcc = 50;
473 link->conf.IntType = INT_MEMORY_AND_IO; 471 link->conf.IntType = INT_MEMORY_AND_IO;
474 link->conf.ConfigIndex = 1; 472 link->conf.ConfigIndex = 1;
475 link->conf.Present = PRESENT_OPTION; 473 link->conf.Present = PRESENT_OPTION;
@@ -489,13 +487,7 @@ static int nmclan_attach(struct pcmcia_device *p_dev)
489 dev->watchdog_timeo = TX_TIMEOUT; 487 dev->watchdog_timeo = TX_TIMEOUT;
490#endif 488#endif
491 489
492 link->handle = p_dev; 490 return nmclan_config(link);
493 p_dev->instance = link;
494
495 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
496 nmclan_config(link);
497
498 return 0;
499} /* nmclan_attach */ 491} /* nmclan_attach */
500 492
501/* ---------------------------------------------------------------------------- 493/* ----------------------------------------------------------------------------
@@ -506,18 +498,16 @@ nmclan_detach
506 when the device is released. 498 when the device is released.
507---------------------------------------------------------------------------- */ 499---------------------------------------------------------------------------- */
508 500
509static void nmclan_detach(struct pcmcia_device *p_dev) 501static void nmclan_detach(struct pcmcia_device *link)
510{ 502{
511 dev_link_t *link = dev_to_instance(p_dev);
512 struct net_device *dev = link->priv; 503 struct net_device *dev = link->priv;
513 504
514 DEBUG(0, "nmclan_detach(0x%p)\n", link); 505 DEBUG(0, "nmclan_detach(0x%p)\n", link);
515 506
516 if (link->dev) 507 if (link->dev_node)
517 unregister_netdev(dev); 508 unregister_netdev(dev);
518 509
519 if (link->state & DEV_CONFIG) 510 nmclan_release(link);
520 nmclan_release(link);
521 511
522 free_netdev(dev); 512 free_netdev(dev);
523} /* nmclan_detach */ 513} /* nmclan_detach */
@@ -661,9 +651,8 @@ nmclan_config
661#define CS_CHECK(fn, ret) \ 651#define CS_CHECK(fn, ret) \
662 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 652 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
663 653
664static void nmclan_config(dev_link_t *link) 654static int nmclan_config(struct pcmcia_device *link)
665{ 655{
666 client_handle_t handle = link->handle;
667 struct net_device *dev = link->priv; 656 struct net_device *dev = link->priv;
668 mace_private *lp = netdev_priv(dev); 657 mace_private *lp = netdev_priv(dev);
669 tuple_t tuple; 658 tuple_t tuple;
@@ -679,17 +668,14 @@ static void nmclan_config(dev_link_t *link)
679 tuple.TupleDataMax = 64; 668 tuple.TupleDataMax = 64;
680 tuple.TupleOffset = 0; 669 tuple.TupleOffset = 0;
681 tuple.DesiredTuple = CISTPL_CONFIG; 670 tuple.DesiredTuple = CISTPL_CONFIG;
682 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 671 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
683 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 672 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
684 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 673 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
685 link->conf.ConfigBase = parse.config.base; 674 link->conf.ConfigBase = parse.config.base;
686 675
687 /* Configure card */ 676 CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io));
688 link->state |= DEV_CONFIG; 677 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
689 678 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
690 CS_CHECK(RequestIO, pcmcia_request_io(handle, &link->io));
691 CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq));
692 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf));
693 dev->irq = link->irq.AssignedIRQ; 679 dev->irq = link->irq.AssignedIRQ;
694 dev->base_addr = link->io.BasePort1; 680 dev->base_addr = link->io.BasePort1;
695 681
@@ -700,8 +686,8 @@ static void nmclan_config(dev_link_t *link)
700 tuple.TupleData = buf; 686 tuple.TupleData = buf;
701 tuple.TupleDataMax = 64; 687 tuple.TupleDataMax = 64;
702 tuple.TupleOffset = 0; 688 tuple.TupleOffset = 0;
703 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 689 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
704 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 690 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
705 memcpy(dev->dev_addr, tuple.TupleData, ETHER_ADDR_LEN); 691 memcpy(dev->dev_addr, tuple.TupleData, ETHER_ADDR_LEN);
706 692
707 /* Verify configuration by reading the MACE ID. */ 693 /* Verify configuration by reading the MACE ID. */
@@ -716,8 +702,7 @@ static void nmclan_config(dev_link_t *link)
716 } else { 702 } else {
717 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"
718 " be 0x40 0x?9\n", sig[0], sig[1]); 704 " be 0x40 0x?9\n", sig[0], sig[1]);
719 link->state &= ~DEV_CONFIG_PENDING; 705 return -ENODEV;
720 return;
721 } 706 }
722 } 707 }
723 708
@@ -730,14 +715,13 @@ static void nmclan_config(dev_link_t *link)
730 else 715 else
731 printk(KERN_NOTICE "nmclan_cs: invalid if_port requested\n"); 716 printk(KERN_NOTICE "nmclan_cs: invalid if_port requested\n");
732 717
733 link->dev = &lp->node; 718 link->dev_node = &lp->node;
734 link->state &= ~DEV_CONFIG_PENDING; 719 SET_NETDEV_DEV(dev, &handle_to_dev(link));
735 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
736 720
737 i = register_netdev(dev); 721 i = register_netdev(dev);
738 if (i != 0) { 722 if (i != 0) {
739 printk(KERN_NOTICE "nmclan_cs: register_netdev() failed\n"); 723 printk(KERN_NOTICE "nmclan_cs: register_netdev() failed\n");
740 link->dev = NULL; 724 link->dev_node = NULL;
741 goto failed; 725 goto failed;
742 } 726 }
743 727
@@ -747,14 +731,13 @@ static void nmclan_config(dev_link_t *link)
747 dev->name, dev->base_addr, dev->irq, if_names[dev->if_port]); 731 dev->name, dev->base_addr, dev->irq, if_names[dev->if_port]);
748 for (i = 0; i < 6; i++) 732 for (i = 0; i < 6; i++)
749 printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n")); 733 printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n"));
750 return; 734 return 0;
751 735
752cs_failed: 736cs_failed:
753 cs_error(link->handle, last_fn, last_ret); 737 cs_error(link, last_fn, last_ret);
754failed: 738failed:
755 nmclan_release(link); 739 nmclan_release(link);
756 return; 740 return -ENODEV;
757
758} /* nmclan_config */ 741} /* nmclan_config */
759 742
760/* ---------------------------------------------------------------------------- 743/* ----------------------------------------------------------------------------
@@ -763,46 +746,29 @@ nmclan_release
763 net device, and release the PCMCIA configuration. If the device 746 net device, and release the PCMCIA configuration. If the device
764 is still open, this will be postponed until it is closed. 747 is still open, this will be postponed until it is closed.
765---------------------------------------------------------------------------- */ 748---------------------------------------------------------------------------- */
766static void nmclan_release(dev_link_t *link) 749static void nmclan_release(struct pcmcia_device *link)
767{ 750{
768 751 DEBUG(0, "nmclan_release(0x%p)\n", link);
769 DEBUG(0, "nmclan_release(0x%p)\n", link); 752 pcmcia_disable_device(link);
770
771 pcmcia_release_configuration(link->handle);
772 pcmcia_release_io(link->handle, &link->io);
773 pcmcia_release_irq(link->handle, &link->irq);
774
775 link->state &= ~DEV_CONFIG;
776} 753}
777 754
778static int nmclan_suspend(struct pcmcia_device *p_dev) 755static int nmclan_suspend(struct pcmcia_device *link)
779{ 756{
780 dev_link_t *link = dev_to_instance(p_dev);
781 struct net_device *dev = link->priv; 757 struct net_device *dev = link->priv;
782 758
783 link->state |= DEV_SUSPEND; 759 if (link->open)
784 if (link->state & DEV_CONFIG) { 760 netif_device_detach(dev);
785 if (link->open)
786 netif_device_detach(dev);
787 pcmcia_release_configuration(link->handle);
788 }
789
790 761
791 return 0; 762 return 0;
792} 763}
793 764
794static int nmclan_resume(struct pcmcia_device *p_dev) 765static int nmclan_resume(struct pcmcia_device *link)
795{ 766{
796 dev_link_t *link = dev_to_instance(p_dev);
797 struct net_device *dev = link->priv; 767 struct net_device *dev = link->priv;
798 768
799 link->state &= ~DEV_SUSPEND; 769 if (link->open) {
800 if (link->state & DEV_CONFIG) { 770 nmclan_reset(dev);
801 pcmcia_request_configuration(link->handle, &link->conf); 771 netif_device_attach(dev);
802 if (link->open) {
803 nmclan_reset(dev);
804 netif_device_attach(dev);
805 }
806 } 772 }
807 773
808 return 0; 774 return 0;
@@ -818,7 +784,7 @@ static void nmclan_reset(struct net_device *dev)
818 mace_private *lp = netdev_priv(dev); 784 mace_private *lp = netdev_priv(dev);
819 785
820#if RESET_XILINX 786#if RESET_XILINX
821 dev_link_t *link = &lp->link; 787 struct pcmcia_device *link = &lp->link;
822 conf_reg_t reg; 788 conf_reg_t reg;
823 u_long OrigCorValue; 789 u_long OrigCorValue;
824 790
@@ -827,7 +793,7 @@ static void nmclan_reset(struct net_device *dev)
827 reg.Action = CS_READ; 793 reg.Action = CS_READ;
828 reg.Offset = CISREG_COR; 794 reg.Offset = CISREG_COR;
829 reg.Value = 0; 795 reg.Value = 0;
830 pcmcia_access_configuration_register(link->handle, &reg); 796 pcmcia_access_configuration_register(link, &reg);
831 OrigCorValue = reg.Value; 797 OrigCorValue = reg.Value;
832 798
833 /* Reset Xilinx */ 799 /* Reset Xilinx */
@@ -836,12 +802,12 @@ static void nmclan_reset(struct net_device *dev)
836 DEBUG(1, "nmclan_reset: OrigCorValue=0x%lX, resetting...\n", 802 DEBUG(1, "nmclan_reset: OrigCorValue=0x%lX, resetting...\n",
837 OrigCorValue); 803 OrigCorValue);
838 reg.Value = COR_SOFT_RESET; 804 reg.Value = COR_SOFT_RESET;
839 pcmcia_access_configuration_register(link->handle, &reg); 805 pcmcia_access_configuration_register(link, &reg);
840 /* Need to wait for 20 ms for PCMCIA to finish reset. */ 806 /* Need to wait for 20 ms for PCMCIA to finish reset. */
841 807
842 /* Restore original COR configuration index */ 808 /* Restore original COR configuration index */
843 reg.Value = COR_LEVEL_REQ | (OrigCorValue & COR_CONFIG_MASK); 809 reg.Value = COR_LEVEL_REQ | (OrigCorValue & COR_CONFIG_MASK);
844 pcmcia_access_configuration_register(link->handle, &reg); 810 pcmcia_access_configuration_register(link, &reg);
845 /* Xilinx is now completely reset along with the MACE chip. */ 811 /* Xilinx is now completely reset along with the MACE chip. */
846 lp->tx_free_frames=AM2150_MAX_TX_FRAMES; 812 lp->tx_free_frames=AM2150_MAX_TX_FRAMES;
847 813
@@ -885,9 +851,9 @@ static int mace_open(struct net_device *dev)
885{ 851{
886 kio_addr_t ioaddr = dev->base_addr; 852 kio_addr_t ioaddr = dev->base_addr;
887 mace_private *lp = netdev_priv(dev); 853 mace_private *lp = netdev_priv(dev);
888 dev_link_t *link = &lp->link; 854 struct pcmcia_device *link = lp->p_dev;
889 855
890 if (!DEV_OK(link)) 856 if (!pcmcia_dev_present(link))
891 return -ENODEV; 857 return -ENODEV;
892 858
893 link->open++; 859 link->open++;
@@ -908,7 +874,7 @@ static int mace_close(struct net_device *dev)
908{ 874{
909 kio_addr_t ioaddr = dev->base_addr; 875 kio_addr_t ioaddr = dev->base_addr;
910 mace_private *lp = netdev_priv(dev); 876 mace_private *lp = netdev_priv(dev);
911 dev_link_t *link = &lp->link; 877 struct pcmcia_device *link = lp->p_dev;
912 878
913 DEBUG(2, "%s: shutting down ethercard.\n", dev->name); 879 DEBUG(2, "%s: shutting down ethercard.\n", dev->name);
914 880
@@ -963,12 +929,12 @@ mace_start_xmit
963static void mace_tx_timeout(struct net_device *dev) 929static void mace_tx_timeout(struct net_device *dev)
964{ 930{
965 mace_private *lp = netdev_priv(dev); 931 mace_private *lp = netdev_priv(dev);
966 dev_link_t *link = &lp->link; 932 struct pcmcia_device *link = lp->p_dev;
967 933
968 printk(KERN_NOTICE "%s: transmit timed out -- ", dev->name); 934 printk(KERN_NOTICE "%s: transmit timed out -- ", dev->name);
969#if RESET_ON_TIMEOUT 935#if RESET_ON_TIMEOUT
970 printk("resetting card\n"); 936 printk("resetting card\n");
971 pcmcia_reset_card(link->handle, NULL); 937 pcmcia_reset_card(link, NULL);
972#else /* #if RESET_ON_TIMEOUT */ 938#else /* #if RESET_ON_TIMEOUT */
973 printk("NOT resetting card\n"); 939 printk("NOT resetting card\n");
974#endif /* #if RESET_ON_TIMEOUT */ 940#endif /* #if RESET_ON_TIMEOUT */
@@ -1635,7 +1601,7 @@ static struct pcmcia_driver nmclan_cs_driver = {
1635 .drv = { 1601 .drv = {
1636 .name = "nmclan_cs", 1602 .name = "nmclan_cs",
1637 }, 1603 },
1638 .probe = nmclan_attach, 1604 .probe = nmclan_probe,
1639 .remove = nmclan_detach, 1605 .remove = nmclan_detach,
1640 .id_table = nmclan_ids, 1606 .id_table = nmclan_ids,
1641 .suspend = nmclan_suspend, 1607 .suspend = nmclan_suspend,
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index b46e5f703efa..506e777c5f06 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -103,8 +103,8 @@ module_param_array(hw_addr, int, NULL, 0);
103/*====================================================================*/ 103/*====================================================================*/
104 104
105static void mii_phy_probe(struct net_device *dev); 105static void mii_phy_probe(struct net_device *dev);
106static void pcnet_config(dev_link_t *link); 106static int pcnet_config(struct pcmcia_device *link);
107static void pcnet_release(dev_link_t *link); 107static void pcnet_release(struct pcmcia_device *link);
108static int pcnet_open(struct net_device *dev); 108static int pcnet_open(struct net_device *dev);
109static int pcnet_close(struct net_device *dev); 109static int pcnet_close(struct net_device *dev);
110static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 110static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
@@ -113,9 +113,9 @@ static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs);
113static void ei_watchdog(u_long arg); 113static void ei_watchdog(u_long arg);
114static void pcnet_reset_8390(struct net_device *dev); 114static void pcnet_reset_8390(struct net_device *dev);
115static int set_config(struct net_device *dev, struct ifmap *map); 115static int set_config(struct net_device *dev, struct ifmap *map);
116static int setup_shmem_window(dev_link_t *link, int start_pg, 116static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
117 int stop_pg, int cm_offset); 117 int stop_pg, int cm_offset);
118static int setup_dma_config(dev_link_t *link, int start_pg, 118static int setup_dma_config(struct pcmcia_device *link, int start_pg,
119 int stop_pg); 119 int stop_pg);
120 120
121static void pcnet_detach(struct pcmcia_device *p_dev); 121static void pcnet_detach(struct pcmcia_device *p_dev);
@@ -214,7 +214,7 @@ static hw_info_t dl10019_info = { 0, 0, 0, 0, IS_DL10019|HAS_MII };
214static hw_info_t dl10022_info = { 0, 0, 0, 0, IS_DL10022|HAS_MII }; 214static hw_info_t dl10022_info = { 0, 0, 0, 0, IS_DL10022|HAS_MII };
215 215
216typedef struct pcnet_dev_t { 216typedef struct pcnet_dev_t {
217 dev_link_t link; 217 struct pcmcia_device *p_dev;
218 dev_node_t node; 218 dev_node_t node;
219 u_int flags; 219 u_int flags;
220 void __iomem *base; 220 void __iomem *base;
@@ -240,10 +240,9 @@ static inline pcnet_dev_t *PRIV(struct net_device *dev)
240 240
241======================================================================*/ 241======================================================================*/
242 242
243static int pcnet_probe(struct pcmcia_device *p_dev) 243static int pcnet_probe(struct pcmcia_device *link)
244{ 244{
245 pcnet_dev_t *info; 245 pcnet_dev_t *info;
246 dev_link_t *link;
247 struct net_device *dev; 246 struct net_device *dev;
248 247
249 DEBUG(0, "pcnet_attach()\n"); 248 DEBUG(0, "pcnet_attach()\n");
@@ -252,7 +251,7 @@ static int pcnet_probe(struct pcmcia_device *p_dev)
252 dev = __alloc_ei_netdev(sizeof(pcnet_dev_t)); 251 dev = __alloc_ei_netdev(sizeof(pcnet_dev_t));
253 if (!dev) return -ENOMEM; 252 if (!dev) return -ENOMEM;
254 info = PRIV(dev); 253 info = PRIV(dev);
255 link = &info->link; 254 info->p_dev = link;
256 link->priv = dev; 255 link->priv = dev;
257 256
258 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 257 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
@@ -265,13 +264,7 @@ static int pcnet_probe(struct pcmcia_device *p_dev)
265 dev->stop = &pcnet_close; 264 dev->stop = &pcnet_close;
266 dev->set_config = &set_config; 265 dev->set_config = &set_config;
267 266
268 link->handle = p_dev; 267 return pcnet_config(link);
269 p_dev->instance = link;
270
271 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
272 pcnet_config(link);
273
274 return 0;
275} /* pcnet_attach */ 268} /* pcnet_attach */
276 269
277/*====================================================================== 270/*======================================================================
@@ -283,18 +276,16 @@ static int pcnet_probe(struct pcmcia_device *p_dev)
283 276
284======================================================================*/ 277======================================================================*/
285 278
286static void pcnet_detach(struct pcmcia_device *p_dev) 279static void pcnet_detach(struct pcmcia_device *link)
287{ 280{
288 dev_link_t *link = dev_to_instance(p_dev);
289 struct net_device *dev = link->priv; 281 struct net_device *dev = link->priv;
290 282
291 DEBUG(0, "pcnet_detach(0x%p)\n", link); 283 DEBUG(0, "pcnet_detach(0x%p)\n", link);
292 284
293 if (link->dev) 285 if (link->dev_node)
294 unregister_netdev(dev); 286 unregister_netdev(dev);
295 287
296 if (link->state & DEV_CONFIG) 288 pcnet_release(link);
297 pcnet_release(link);
298 289
299 free_netdev(dev); 290 free_netdev(dev);
300} /* pcnet_detach */ 291} /* pcnet_detach */
@@ -306,7 +297,7 @@ static void pcnet_detach(struct pcmcia_device *p_dev)
306 297
307======================================================================*/ 298======================================================================*/
308 299
309static hw_info_t *get_hwinfo(dev_link_t *link) 300static hw_info_t *get_hwinfo(struct pcmcia_device *link)
310{ 301{
311 struct net_device *dev = link->priv; 302 struct net_device *dev = link->priv;
312 win_req_t req; 303 win_req_t req;
@@ -318,9 +309,9 @@ static hw_info_t *get_hwinfo(dev_link_t *link)
318 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 309 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
319 req.Base = 0; req.Size = 0; 310 req.Base = 0; req.Size = 0;
320 req.AccessSpeed = 0; 311 req.AccessSpeed = 0;
321 i = pcmcia_request_window(&link->handle, &req, &link->win); 312 i = pcmcia_request_window(&link, &req, &link->win);
322 if (i != CS_SUCCESS) { 313 if (i != CS_SUCCESS) {
323 cs_error(link->handle, RequestWindow, i); 314 cs_error(link, RequestWindow, i);
324 return NULL; 315 return NULL;
325 } 316 }
326 317
@@ -343,7 +334,7 @@ static hw_info_t *get_hwinfo(dev_link_t *link)
343 iounmap(virt); 334 iounmap(virt);
344 j = pcmcia_release_window(link->win); 335 j = pcmcia_release_window(link->win);
345 if (j != CS_SUCCESS) 336 if (j != CS_SUCCESS)
346 cs_error(link->handle, ReleaseWindow, j); 337 cs_error(link, ReleaseWindow, j);
347 return (i < NR_INFO) ? hw_info+i : NULL; 338 return (i < NR_INFO) ? hw_info+i : NULL;
348} /* get_hwinfo */ 339} /* get_hwinfo */
349 340
@@ -355,7 +346,7 @@ static hw_info_t *get_hwinfo(dev_link_t *link)
355 346
356======================================================================*/ 347======================================================================*/
357 348
358static hw_info_t *get_prom(dev_link_t *link) 349static hw_info_t *get_prom(struct pcmcia_device *link)
359{ 350{
360 struct net_device *dev = link->priv; 351 struct net_device *dev = link->priv;
361 kio_addr_t ioaddr = dev->base_addr; 352 kio_addr_t ioaddr = dev->base_addr;
@@ -409,7 +400,7 @@ static hw_info_t *get_prom(dev_link_t *link)
409 400
410======================================================================*/ 401======================================================================*/
411 402
412static hw_info_t *get_dl10019(dev_link_t *link) 403static hw_info_t *get_dl10019(struct pcmcia_device *link)
413{ 404{
414 struct net_device *dev = link->priv; 405 struct net_device *dev = link->priv;
415 int i; 406 int i;
@@ -431,7 +422,7 @@ static hw_info_t *get_dl10019(dev_link_t *link)
431 422
432======================================================================*/ 423======================================================================*/
433 424
434static hw_info_t *get_ax88190(dev_link_t *link) 425static hw_info_t *get_ax88190(struct pcmcia_device *link)
435{ 426{
436 struct net_device *dev = link->priv; 427 struct net_device *dev = link->priv;
437 kio_addr_t ioaddr = dev->base_addr; 428 kio_addr_t ioaddr = dev->base_addr;
@@ -464,7 +455,7 @@ static hw_info_t *get_ax88190(dev_link_t *link)
464 455
465======================================================================*/ 456======================================================================*/
466 457
467static hw_info_t *get_hwired(dev_link_t *link) 458static hw_info_t *get_hwired(struct pcmcia_device *link)
468{ 459{
469 struct net_device *dev = link->priv; 460 struct net_device *dev = link->priv;
470 int i; 461 int i;
@@ -491,7 +482,7 @@ static hw_info_t *get_hwired(dev_link_t *link)
491#define CS_CHECK(fn, ret) \ 482#define CS_CHECK(fn, ret) \
492do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 483do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
493 484
494static int try_io_port(dev_link_t *link) 485static int try_io_port(struct pcmcia_device *link)
495{ 486{
496 int j, ret; 487 int j, ret;
497 if (link->io.NumPorts1 == 32) { 488 if (link->io.NumPorts1 == 32) {
@@ -512,18 +503,17 @@ static int try_io_port(dev_link_t *link)
512 for (j = 0; j < 0x400; j += 0x20) { 503 for (j = 0; j < 0x400; j += 0x20) {
513 link->io.BasePort1 = j ^ 0x300; 504 link->io.BasePort1 = j ^ 0x300;
514 link->io.BasePort2 = (j ^ 0x300) + 0x10; 505 link->io.BasePort2 = (j ^ 0x300) + 0x10;
515 ret = pcmcia_request_io(link->handle, &link->io); 506 ret = pcmcia_request_io(link, &link->io);
516 if (ret == CS_SUCCESS) return ret; 507 if (ret == CS_SUCCESS) return ret;
517 } 508 }
518 return ret; 509 return ret;
519 } else { 510 } else {
520 return pcmcia_request_io(link->handle, &link->io); 511 return pcmcia_request_io(link, &link->io);
521 } 512 }
522} 513}
523 514
524static void pcnet_config(dev_link_t *link) 515static int pcnet_config(struct pcmcia_device *link)
525{ 516{
526 client_handle_t handle = link->handle;
527 struct net_device *dev = link->priv; 517 struct net_device *dev = link->priv;
528 pcnet_dev_t *info = PRIV(dev); 518 pcnet_dev_t *info = PRIV(dev);
529 tuple_t tuple; 519 tuple_t tuple;
@@ -531,7 +521,6 @@ static void pcnet_config(dev_link_t *link)
531 int i, last_ret, last_fn, start_pg, stop_pg, cm_offset; 521 int i, last_ret, last_fn, start_pg, stop_pg, cm_offset;
532 int manfid = 0, prodid = 0, has_shmem = 0; 522 int manfid = 0, prodid = 0, has_shmem = 0;
533 u_short buf[64]; 523 u_short buf[64];
534 config_info_t conf;
535 hw_info_t *hw_info; 524 hw_info_t *hw_info;
536 525
537 DEBUG(0, "pcnet_config(0x%p)\n", link); 526 DEBUG(0, "pcnet_config(0x%p)\n", link);
@@ -541,36 +530,29 @@ static void pcnet_config(dev_link_t *link)
541 tuple.TupleDataMax = sizeof(buf); 530 tuple.TupleDataMax = sizeof(buf);
542 tuple.TupleOffset = 0; 531 tuple.TupleOffset = 0;
543 tuple.DesiredTuple = CISTPL_CONFIG; 532 tuple.DesiredTuple = CISTPL_CONFIG;
544 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 533 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
545 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 534 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
546 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 535 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
547 link->conf.ConfigBase = parse.config.base; 536 link->conf.ConfigBase = parse.config.base;
548 link->conf.Present = parse.config.rmask[0]; 537 link->conf.Present = parse.config.rmask[0];
549 538
550 /* Configure card */
551 link->state |= DEV_CONFIG;
552
553 /* Look up current Vcc */
554 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf));
555 link->conf.Vcc = conf.Vcc;
556
557 tuple.DesiredTuple = CISTPL_MANFID; 539 tuple.DesiredTuple = CISTPL_MANFID;
558 tuple.Attributes = TUPLE_RETURN_COMMON; 540 tuple.Attributes = TUPLE_RETURN_COMMON;
559 if ((pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) && 541 if ((pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) &&
560 (pcmcia_get_tuple_data(handle, &tuple) == CS_SUCCESS)) { 542 (pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS)) {
561 manfid = le16_to_cpu(buf[0]); 543 manfid = le16_to_cpu(buf[0]);
562 prodid = le16_to_cpu(buf[1]); 544 prodid = le16_to_cpu(buf[1]);
563 } 545 }
564 546
565 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 547 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
566 tuple.Attributes = 0; 548 tuple.Attributes = 0;
567 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 549 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
568 while (last_ret == CS_SUCCESS) { 550 while (last_ret == CS_SUCCESS) {
569 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 551 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
570 cistpl_io_t *io = &(parse.cftable_entry.io); 552 cistpl_io_t *io = &(parse.cftable_entry.io);
571 553
572 if (pcmcia_get_tuple_data(handle, &tuple) != 0 || 554 if (pcmcia_get_tuple_data(link, &tuple) != 0 ||
573 pcmcia_parse_tuple(handle, &tuple, &parse) != 0 || 555 pcmcia_parse_tuple(link, &tuple, &parse) != 0 ||
574 cfg->index == 0 || cfg->io.nwin == 0) 556 cfg->index == 0 || cfg->io.nwin == 0)
575 goto next_entry; 557 goto next_entry;
576 558
@@ -594,14 +576,14 @@ static void pcnet_config(dev_link_t *link)
594 if (last_ret == CS_SUCCESS) break; 576 if (last_ret == CS_SUCCESS) break;
595 } 577 }
596 next_entry: 578 next_entry:
597 last_ret = pcmcia_get_next_tuple(handle, &tuple); 579 last_ret = pcmcia_get_next_tuple(link, &tuple);
598 } 580 }
599 if (last_ret != CS_SUCCESS) { 581 if (last_ret != CS_SUCCESS) {
600 cs_error(handle, RequestIO, last_ret); 582 cs_error(link, RequestIO, last_ret);
601 goto failed; 583 goto failed;
602 } 584 }
603 585
604 CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); 586 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
605 587
606 if (link->io.NumPorts2 == 8) { 588 if (link->io.NumPorts2 == 8) {
607 link->conf.Attributes |= CONF_ENABLE_SPKR; 589 link->conf.Attributes |= CONF_ENABLE_SPKR;
@@ -611,7 +593,7 @@ static void pcnet_config(dev_link_t *link)
611 (prodid == PRODID_IBM_HOME_AND_AWAY)) 593 (prodid == PRODID_IBM_HOME_AND_AWAY))
612 link->conf.ConfigIndex |= 0x10; 594 link->conf.ConfigIndex |= 0x10;
613 595
614 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); 596 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
615 dev->irq = link->irq.AssignedIRQ; 597 dev->irq = link->irq.AssignedIRQ;
616 dev->base_addr = link->io.BasePort1; 598 dev->base_addr = link->io.BasePort1;
617 if (info->flags & HAS_MISC_REG) { 599 if (info->flags & HAS_MISC_REG) {
@@ -679,9 +661,8 @@ static void pcnet_config(dev_link_t *link)
679 info->eth_phy = 0; 661 info->eth_phy = 0;
680 } 662 }
681 663
682 link->dev = &info->node; 664 link->dev_node = &info->node;
683 link->state &= ~DEV_CONFIG_PENDING; 665 SET_NETDEV_DEV(dev, &handle_to_dev(link));
684 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
685 666
686#ifdef CONFIG_NET_POLL_CONTROLLER 667#ifdef CONFIG_NET_POLL_CONTROLLER
687 dev->poll_controller = ei_poll; 668 dev->poll_controller = ei_poll;
@@ -689,7 +670,7 @@ static void pcnet_config(dev_link_t *link)
689 670
690 if (register_netdev(dev) != 0) { 671 if (register_netdev(dev) != 0) {
691 printk(KERN_NOTICE "pcnet_cs: register_netdev() failed\n"); 672 printk(KERN_NOTICE "pcnet_cs: register_netdev() failed\n");
692 link->dev = NULL; 673 link->dev_node = NULL;
693 goto failed; 674 goto failed;
694 } 675 }
695 676
@@ -712,14 +693,13 @@ static void pcnet_config(dev_link_t *link)
712 printk(" hw_addr "); 693 printk(" hw_addr ");
713 for (i = 0; i < 6; i++) 694 for (i = 0; i < 6; i++)
714 printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n")); 695 printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n"));
715 return; 696 return 0;
716 697
717cs_failed: 698cs_failed:
718 cs_error(link->handle, last_fn, last_ret); 699 cs_error(link, last_fn, last_ret);
719failed: 700failed:
720 pcnet_release(link); 701 pcnet_release(link);
721 link->state &= ~DEV_CONFIG_PENDING; 702 return -ENODEV;
722 return;
723} /* pcnet_config */ 703} /* pcnet_config */
724 704
725/*====================================================================== 705/*======================================================================
@@ -730,21 +710,16 @@ failed:
730 710
731======================================================================*/ 711======================================================================*/
732 712
733static void pcnet_release(dev_link_t *link) 713static void pcnet_release(struct pcmcia_device *link)
734{ 714{
735 pcnet_dev_t *info = PRIV(link->priv); 715 pcnet_dev_t *info = PRIV(link->priv);
736 716
737 DEBUG(0, "pcnet_release(0x%p)\n", link); 717 DEBUG(0, "pcnet_release(0x%p)\n", link);
738 718
739 if (info->flags & USE_SHMEM) { 719 if (info->flags & USE_SHMEM)
740 iounmap(info->base); 720 iounmap(info->base);
741 pcmcia_release_window(link->win);
742 }
743 pcmcia_release_configuration(link->handle);
744 pcmcia_release_io(link->handle, &link->io);
745 pcmcia_release_irq(link->handle, &link->irq);
746 721
747 link->state &= ~DEV_CONFIG; 722 pcmcia_disable_device(link);
748} 723}
749 724
750/*====================================================================== 725/*======================================================================
@@ -756,34 +731,24 @@ static void pcnet_release(dev_link_t *link)
756 731
757======================================================================*/ 732======================================================================*/
758 733
759static int pcnet_suspend(struct pcmcia_device *p_dev) 734static int pcnet_suspend(struct pcmcia_device *link)
760{ 735{
761 dev_link_t *link = dev_to_instance(p_dev);
762 struct net_device *dev = link->priv; 736 struct net_device *dev = link->priv;
763 737
764 link->state |= DEV_SUSPEND; 738 if (link->open)
765 if (link->state & DEV_CONFIG) { 739 netif_device_detach(dev);
766 if (link->open)
767 netif_device_detach(dev);
768 pcmcia_release_configuration(link->handle);
769 }
770 740
771 return 0; 741 return 0;
772} 742}
773 743
774static int pcnet_resume(struct pcmcia_device *p_dev) 744static int pcnet_resume(struct pcmcia_device *link)
775{ 745{
776 dev_link_t *link = dev_to_instance(p_dev);
777 struct net_device *dev = link->priv; 746 struct net_device *dev = link->priv;
778 747
779 link->state &= ~DEV_SUSPEND; 748 if (link->open) {
780 if (link->state & DEV_CONFIG) { 749 pcnet_reset_8390(dev);
781 pcmcia_request_configuration(link->handle, &link->conf); 750 NS8390_init(dev, 1);
782 if (link->open) { 751 netif_device_attach(dev);
783 pcnet_reset_8390(dev);
784 NS8390_init(dev, 1);
785 netif_device_attach(dev);
786 }
787 } 752 }
788 753
789 return 0; 754 return 0;
@@ -1023,11 +988,11 @@ static void mii_phy_probe(struct net_device *dev)
1023static int pcnet_open(struct net_device *dev) 988static int pcnet_open(struct net_device *dev)
1024{ 989{
1025 pcnet_dev_t *info = PRIV(dev); 990 pcnet_dev_t *info = PRIV(dev);
1026 dev_link_t *link = &info->link; 991 struct pcmcia_device *link = info->p_dev;
1027 992
1028 DEBUG(2, "pcnet_open('%s')\n", dev->name); 993 DEBUG(2, "pcnet_open('%s')\n", dev->name);
1029 994
1030 if (!DEV_OK(link)) 995 if (!pcmcia_dev_present(link))
1031 return -ENODEV; 996 return -ENODEV;
1032 997
1033 link->open++; 998 link->open++;
@@ -1051,7 +1016,7 @@ static int pcnet_open(struct net_device *dev)
1051static int pcnet_close(struct net_device *dev) 1016static int pcnet_close(struct net_device *dev)
1052{ 1017{
1053 pcnet_dev_t *info = PRIV(dev); 1018 pcnet_dev_t *info = PRIV(dev);
1054 dev_link_t *link = &info->link; 1019 struct pcmcia_device *link = info->p_dev;
1055 1020
1056 DEBUG(2, "pcnet_close('%s')\n", dev->name); 1021 DEBUG(2, "pcnet_close('%s')\n", dev->name);
1057 1022
@@ -1429,7 +1394,7 @@ static void dma_block_output(struct net_device *dev, int count,
1429 1394
1430/*====================================================================*/ 1395/*====================================================================*/
1431 1396
1432static int setup_dma_config(dev_link_t *link, int start_pg, 1397static int setup_dma_config(struct pcmcia_device *link, int start_pg,
1433 int stop_pg) 1398 int stop_pg)
1434{ 1399{
1435 struct net_device *dev = link->priv; 1400 struct net_device *dev = link->priv;
@@ -1532,7 +1497,7 @@ static void shmem_block_output(struct net_device *dev, int count,
1532 1497
1533/*====================================================================*/ 1498/*====================================================================*/
1534 1499
1535static int setup_shmem_window(dev_link_t *link, int start_pg, 1500static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
1536 int stop_pg, int cm_offset) 1501 int stop_pg, int cm_offset)
1537{ 1502{
1538 struct net_device *dev = link->priv; 1503 struct net_device *dev = link->priv;
@@ -1554,7 +1519,7 @@ static int setup_shmem_window(dev_link_t *link, int start_pg,
1554 req.Attributes |= WIN_USE_WAIT; 1519 req.Attributes |= WIN_USE_WAIT;
1555 req.Base = 0; req.Size = window_size; 1520 req.Base = 0; req.Size = window_size;
1556 req.AccessSpeed = mem_speed; 1521 req.AccessSpeed = mem_speed;
1557 CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &link->win)); 1522 CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win));
1558 1523
1559 mem.CardOffset = (start_pg << 8) + cm_offset; 1524 mem.CardOffset = (start_pg << 8) + cm_offset;
1560 offset = mem.CardOffset % window_size; 1525 offset = mem.CardOffset % window_size;
@@ -1595,7 +1560,7 @@ static int setup_shmem_window(dev_link_t *link, int start_pg,
1595 return 0; 1560 return 0;
1596 1561
1597cs_failed: 1562cs_failed:
1598 cs_error(link->handle, last_fn, last_ret); 1563 cs_error(link, last_fn, last_ret);
1599failed: 1564failed:
1600 return 1; 1565 return 1;
1601} 1566}
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index 8839c4faafd6..e74bf5014ef6 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -49,6 +49,7 @@
49#include <pcmcia/cisreg.h> 49#include <pcmcia/cisreg.h>
50#include <pcmcia/ciscode.h> 50#include <pcmcia/ciscode.h>
51#include <pcmcia/ds.h> 51#include <pcmcia/ds.h>
52#include <pcmcia/ss.h>
52 53
53#include <asm/io.h> 54#include <asm/io.h>
54#include <asm/system.h> 55#include <asm/system.h>
@@ -103,7 +104,7 @@ static const char *version =
103#define MEMORY_WAIT_TIME 8 104#define MEMORY_WAIT_TIME 8
104 105
105struct smc_private { 106struct smc_private {
106 dev_link_t link; 107 struct pcmcia_device *p_dev;
107 spinlock_t lock; 108 spinlock_t lock;
108 u_short manfid; 109 u_short manfid;
109 u_short cardid; 110 u_short cardid;
@@ -278,8 +279,8 @@ enum RxCfg { RxAllMulti = 0x0004, RxPromisc = 0x0002,
278/*====================================================================*/ 279/*====================================================================*/
279 280
280static void smc91c92_detach(struct pcmcia_device *p_dev); 281static void smc91c92_detach(struct pcmcia_device *p_dev);
281static void smc91c92_config(dev_link_t *link); 282static int smc91c92_config(struct pcmcia_device *link);
282static void smc91c92_release(dev_link_t *link); 283static void smc91c92_release(struct pcmcia_device *link);
283 284
284static int smc_open(struct net_device *dev); 285static int smc_open(struct net_device *dev);
285static int smc_close(struct net_device *dev); 286static int smc_close(struct net_device *dev);
@@ -308,10 +309,9 @@ static struct ethtool_ops ethtool_ops;
308 309
309======================================================================*/ 310======================================================================*/
310 311
311static int smc91c92_attach(struct pcmcia_device *p_dev) 312static int smc91c92_probe(struct pcmcia_device *link)
312{ 313{
313 struct smc_private *smc; 314 struct smc_private *smc;
314 dev_link_t *link;
315 struct net_device *dev; 315 struct net_device *dev;
316 316
317 DEBUG(0, "smc91c92_attach()\n"); 317 DEBUG(0, "smc91c92_attach()\n");
@@ -321,7 +321,7 @@ static int smc91c92_attach(struct pcmcia_device *p_dev)
321 if (!dev) 321 if (!dev)
322 return -ENOMEM; 322 return -ENOMEM;
323 smc = netdev_priv(dev); 323 smc = netdev_priv(dev);
324 link = &smc->link; 324 smc->p_dev = link;
325 link->priv = dev; 325 link->priv = dev;
326 326
327 spin_lock_init(&smc->lock); 327 spin_lock_init(&smc->lock);
@@ -333,7 +333,6 @@ static int smc91c92_attach(struct pcmcia_device *p_dev)
333 link->irq.Handler = &smc_interrupt; 333 link->irq.Handler = &smc_interrupt;
334 link->irq.Instance = dev; 334 link->irq.Instance = dev;
335 link->conf.Attributes = CONF_ENABLE_IRQ; 335 link->conf.Attributes = CONF_ENABLE_IRQ;
336 link->conf.Vcc = 50;
337 link->conf.IntType = INT_MEMORY_AND_IO; 336 link->conf.IntType = INT_MEMORY_AND_IO;
338 337
339 /* The SMC91c92-specific entries in the device structure. */ 338 /* The SMC91c92-specific entries in the device structure. */
@@ -357,13 +356,7 @@ static int smc91c92_attach(struct pcmcia_device *p_dev)
357 smc->mii_if.phy_id_mask = 0x1f; 356 smc->mii_if.phy_id_mask = 0x1f;
358 smc->mii_if.reg_num_mask = 0x1f; 357 smc->mii_if.reg_num_mask = 0x1f;
359 358
360 link->handle = p_dev; 359 return smc91c92_config(link);
361 p_dev->instance = link;
362
363 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
364 smc91c92_config(link);
365
366 return 0;
367} /* smc91c92_attach */ 360} /* smc91c92_attach */
368 361
369/*====================================================================== 362/*======================================================================
@@ -375,18 +368,16 @@ static int smc91c92_attach(struct pcmcia_device *p_dev)
375 368
376======================================================================*/ 369======================================================================*/
377 370
378static void smc91c92_detach(struct pcmcia_device *p_dev) 371static void smc91c92_detach(struct pcmcia_device *link)
379{ 372{
380 dev_link_t *link = dev_to_instance(p_dev);
381 struct net_device *dev = link->priv; 373 struct net_device *dev = link->priv;
382 374
383 DEBUG(0, "smc91c92_detach(0x%p)\n", link); 375 DEBUG(0, "smc91c92_detach(0x%p)\n", link);
384 376
385 if (link->dev) 377 if (link->dev_node)
386 unregister_netdev(dev); 378 unregister_netdev(dev);
387 379
388 if (link->state & DEV_CONFIG) 380 smc91c92_release(link);
389 smc91c92_release(link);
390 381
391 free_netdev(dev); 382 free_netdev(dev);
392} /* smc91c92_detach */ 383} /* smc91c92_detach */
@@ -414,7 +405,7 @@ static int cvt_ascii_address(struct net_device *dev, char *s)
414 405
415/*====================================================================*/ 406/*====================================================================*/
416 407
417static int first_tuple(client_handle_t handle, tuple_t *tuple, 408static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple,
418 cisparse_t *parse) 409 cisparse_t *parse)
419{ 410{
420 int i; 411 int i;
@@ -425,7 +416,7 @@ static int first_tuple(client_handle_t handle, tuple_t *tuple,
425 return pcmcia_parse_tuple(handle, tuple, parse); 416 return pcmcia_parse_tuple(handle, tuple, parse);
426} 417}
427 418
428static int next_tuple(client_handle_t handle, tuple_t *tuple, 419static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple,
429 cisparse_t *parse) 420 cisparse_t *parse)
430{ 421{
431 int i; 422 int i;
@@ -447,7 +438,7 @@ static int next_tuple(client_handle_t handle, tuple_t *tuple,
447 438
448======================================================================*/ 439======================================================================*/
449 440
450static int mhz_3288_power(dev_link_t *link) 441static int mhz_3288_power(struct pcmcia_device *link)
451{ 442{
452 struct net_device *dev = link->priv; 443 struct net_device *dev = link->priv;
453 struct smc_private *smc = netdev_priv(dev); 444 struct smc_private *smc = netdev_priv(dev);
@@ -469,7 +460,7 @@ static int mhz_3288_power(dev_link_t *link)
469 return 0; 460 return 0;
470} 461}
471 462
472static int mhz_mfc_config(dev_link_t *link) 463static int mhz_mfc_config(struct pcmcia_device *link)
473{ 464{
474 struct net_device *dev = link->priv; 465 struct net_device *dev = link->priv;
475 struct smc_private *smc = netdev_priv(dev); 466 struct smc_private *smc = netdev_priv(dev);
@@ -504,7 +495,7 @@ static int mhz_mfc_config(dev_link_t *link)
504 tuple->TupleDataMax = 255; 495 tuple->TupleDataMax = 255;
505 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; 496 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
506 497
507 i = first_tuple(link->handle, tuple, parse); 498 i = first_tuple(link, tuple, parse);
508 /* The Megahertz combo cards have modem-like CIS entries, so 499 /* The Megahertz combo cards have modem-like CIS entries, so
509 we have to explicitly try a bunch of port combinations. */ 500 we have to explicitly try a bunch of port combinations. */
510 while (i == CS_SUCCESS) { 501 while (i == CS_SUCCESS) {
@@ -513,11 +504,11 @@ static int mhz_mfc_config(dev_link_t *link)
513 for (k = 0; k < 0x400; k += 0x10) { 504 for (k = 0; k < 0x400; k += 0x10) {
514 if (k & 0x80) continue; 505 if (k & 0x80) continue;
515 link->io.BasePort1 = k ^ 0x300; 506 link->io.BasePort1 = k ^ 0x300;
516 i = pcmcia_request_io(link->handle, &link->io); 507 i = pcmcia_request_io(link, &link->io);
517 if (i == CS_SUCCESS) break; 508 if (i == CS_SUCCESS) break;
518 } 509 }
519 if (i == CS_SUCCESS) break; 510 if (i == CS_SUCCESS) break;
520 i = next_tuple(link->handle, tuple, parse); 511 i = next_tuple(link, tuple, parse);
521 } 512 }
522 if (i != CS_SUCCESS) 513 if (i != CS_SUCCESS)
523 goto free_cfg_mem; 514 goto free_cfg_mem;
@@ -527,7 +518,7 @@ static int mhz_mfc_config(dev_link_t *link)
527 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 518 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
528 req.Base = req.Size = 0; 519 req.Base = req.Size = 0;
529 req.AccessSpeed = 0; 520 req.AccessSpeed = 0;
530 i = pcmcia_request_window(&link->handle, &req, &link->win); 521 i = pcmcia_request_window(&link, &req, &link->win);
531 if (i != CS_SUCCESS) 522 if (i != CS_SUCCESS)
532 goto free_cfg_mem; 523 goto free_cfg_mem;
533 smc->base = ioremap(req.Base, req.Size); 524 smc->base = ioremap(req.Base, req.Size);
@@ -546,9 +537,8 @@ free_cfg_mem:
546 return i; 537 return i;
547} 538}
548 539
549static int mhz_setup(dev_link_t *link) 540static int mhz_setup(struct pcmcia_device *link)
550{ 541{
551 client_handle_t handle = link->handle;
552 struct net_device *dev = link->priv; 542 struct net_device *dev = link->priv;
553 struct smc_cfg_mem *cfg_mem; 543 struct smc_cfg_mem *cfg_mem;
554 tuple_t *tuple; 544 tuple_t *tuple;
@@ -571,13 +561,13 @@ static int mhz_setup(dev_link_t *link)
571 /* Read the station address from the CIS. It is stored as the last 561 /* Read the station address from the CIS. It is stored as the last
572 (fourth) string in the Version 1 Version/ID tuple. */ 562 (fourth) string in the Version 1 Version/ID tuple. */
573 tuple->DesiredTuple = CISTPL_VERS_1; 563 tuple->DesiredTuple = CISTPL_VERS_1;
574 if (first_tuple(handle, tuple, parse) != CS_SUCCESS) { 564 if (first_tuple(link, tuple, parse) != CS_SUCCESS) {
575 rc = -1; 565 rc = -1;
576 goto free_cfg_mem; 566 goto free_cfg_mem;
577 } 567 }
578 /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */ 568 /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */
579 if (next_tuple(handle, tuple, parse) != CS_SUCCESS) 569 if (next_tuple(link, tuple, parse) != CS_SUCCESS)
580 first_tuple(handle, tuple, parse); 570 first_tuple(link, tuple, parse);
581 if (parse->version_1.ns > 3) { 571 if (parse->version_1.ns > 3) {
582 station_addr = parse->version_1.str + parse->version_1.ofs[3]; 572 station_addr = parse->version_1.str + parse->version_1.ofs[3];
583 if (cvt_ascii_address(dev, station_addr) == 0) { 573 if (cvt_ascii_address(dev, station_addr) == 0) {
@@ -588,11 +578,11 @@ static int mhz_setup(dev_link_t *link)
588 578
589 /* Another possibility: for the EM3288, in a special tuple */ 579 /* Another possibility: for the EM3288, in a special tuple */
590 tuple->DesiredTuple = 0x81; 580 tuple->DesiredTuple = 0x81;
591 if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) { 581 if (pcmcia_get_first_tuple(link, tuple) != CS_SUCCESS) {
592 rc = -1; 582 rc = -1;
593 goto free_cfg_mem; 583 goto free_cfg_mem;
594 } 584 }
595 if (pcmcia_get_tuple_data(handle, tuple) != CS_SUCCESS) { 585 if (pcmcia_get_tuple_data(link, tuple) != CS_SUCCESS) {
596 rc = -1; 586 rc = -1;
597 goto free_cfg_mem; 587 goto free_cfg_mem;
598 } 588 }
@@ -616,7 +606,7 @@ free_cfg_mem:
616 606
617======================================================================*/ 607======================================================================*/
618 608
619static void mot_config(dev_link_t *link) 609static void mot_config(struct pcmcia_device *link)
620{ 610{
621 struct net_device *dev = link->priv; 611 struct net_device *dev = link->priv;
622 struct smc_private *smc = netdev_priv(dev); 612 struct smc_private *smc = netdev_priv(dev);
@@ -637,7 +627,7 @@ static void mot_config(dev_link_t *link)
637 mdelay(100); 627 mdelay(100);
638} 628}
639 629
640static int mot_setup(dev_link_t *link) 630static int mot_setup(struct pcmcia_device *link)
641{ 631{
642 struct net_device *dev = link->priv; 632 struct net_device *dev = link->priv;
643 kio_addr_t ioaddr = dev->base_addr; 633 kio_addr_t ioaddr = dev->base_addr;
@@ -671,7 +661,7 @@ static int mot_setup(dev_link_t *link)
671 661
672/*====================================================================*/ 662/*====================================================================*/
673 663
674static int smc_config(dev_link_t *link) 664static int smc_config(struct pcmcia_device *link)
675{ 665{
676 struct net_device *dev = link->priv; 666 struct net_device *dev = link->priv;
677 struct smc_cfg_mem *cfg_mem; 667 struct smc_cfg_mem *cfg_mem;
@@ -696,16 +686,16 @@ static int smc_config(dev_link_t *link)
696 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; 686 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
697 687
698 link->io.NumPorts1 = 16; 688 link->io.NumPorts1 = 16;
699 i = first_tuple(link->handle, tuple, parse); 689 i = first_tuple(link, tuple, parse);
700 while (i != CS_NO_MORE_ITEMS) { 690 while (i != CS_NO_MORE_ITEMS) {
701 if (i == CS_SUCCESS) { 691 if (i == CS_SUCCESS) {
702 link->conf.ConfigIndex = cf->index; 692 link->conf.ConfigIndex = cf->index;
703 link->io.BasePort1 = cf->io.win[0].base; 693 link->io.BasePort1 = cf->io.win[0].base;
704 link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; 694 link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK;
705 i = pcmcia_request_io(link->handle, &link->io); 695 i = pcmcia_request_io(link, &link->io);
706 if (i == CS_SUCCESS) break; 696 if (i == CS_SUCCESS) break;
707 } 697 }
708 i = next_tuple(link->handle, tuple, parse); 698 i = next_tuple(link, tuple, parse);
709 } 699 }
710 if (i == CS_SUCCESS) 700 if (i == CS_SUCCESS)
711 dev->base_addr = link->io.BasePort1; 701 dev->base_addr = link->io.BasePort1;
@@ -714,9 +704,8 @@ static int smc_config(dev_link_t *link)
714 return i; 704 return i;
715} 705}
716 706
717static int smc_setup(dev_link_t *link) 707static int smc_setup(struct pcmcia_device *link)
718{ 708{
719 client_handle_t handle = link->handle;
720 struct net_device *dev = link->priv; 709 struct net_device *dev = link->priv;
721 struct smc_cfg_mem *cfg_mem; 710 struct smc_cfg_mem *cfg_mem;
722 tuple_t *tuple; 711 tuple_t *tuple;
@@ -739,11 +728,11 @@ static int smc_setup(dev_link_t *link)
739 728
740 /* Check for a LAN function extension tuple */ 729 /* Check for a LAN function extension tuple */
741 tuple->DesiredTuple = CISTPL_FUNCE; 730 tuple->DesiredTuple = CISTPL_FUNCE;
742 i = first_tuple(handle, tuple, parse); 731 i = first_tuple(link, tuple, parse);
743 while (i == CS_SUCCESS) { 732 while (i == CS_SUCCESS) {
744 if (parse->funce.type == CISTPL_FUNCE_LAN_NODE_ID) 733 if (parse->funce.type == CISTPL_FUNCE_LAN_NODE_ID)
745 break; 734 break;
746 i = next_tuple(handle, tuple, parse); 735 i = next_tuple(link, tuple, parse);
747 } 736 }
748 if (i == CS_SUCCESS) { 737 if (i == CS_SUCCESS) {
749 node_id = (cistpl_lan_node_id_t *)parse->funce.data; 738 node_id = (cistpl_lan_node_id_t *)parse->funce.data;
@@ -756,7 +745,7 @@ static int smc_setup(dev_link_t *link)
756 } 745 }
757 /* Try the third string in the Version 1 Version/ID tuple. */ 746 /* Try the third string in the Version 1 Version/ID tuple. */
758 tuple->DesiredTuple = CISTPL_VERS_1; 747 tuple->DesiredTuple = CISTPL_VERS_1;
759 if (first_tuple(handle, tuple, parse) != CS_SUCCESS) { 748 if (first_tuple(link, tuple, parse) != CS_SUCCESS) {
760 rc = -1; 749 rc = -1;
761 goto free_cfg_mem; 750 goto free_cfg_mem;
762 } 751 }
@@ -774,7 +763,7 @@ free_cfg_mem:
774 763
775/*====================================================================*/ 764/*====================================================================*/
776 765
777static int osi_config(dev_link_t *link) 766static int osi_config(struct pcmcia_device *link)
778{ 767{
779 struct net_device *dev = link->priv; 768 struct net_device *dev = link->priv;
780 static const kio_addr_t com[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; 769 static const kio_addr_t com[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
@@ -794,22 +783,21 @@ static int osi_config(dev_link_t *link)
794 783
795 for (i = j = 0; j < 4; j++) { 784 for (i = j = 0; j < 4; j++) {
796 link->io.BasePort2 = com[j]; 785 link->io.BasePort2 = com[j];
797 i = pcmcia_request_io(link->handle, &link->io); 786 i = pcmcia_request_io(link, &link->io);
798 if (i == CS_SUCCESS) break; 787 if (i == CS_SUCCESS) break;
799 } 788 }
800 if (i != CS_SUCCESS) { 789 if (i != CS_SUCCESS) {
801 /* Fallback: turn off hard decode */ 790 /* Fallback: turn off hard decode */
802 link->conf.ConfigIndex = 0x03; 791 link->conf.ConfigIndex = 0x03;
803 link->io.NumPorts2 = 0; 792 link->io.NumPorts2 = 0;
804 i = pcmcia_request_io(link->handle, &link->io); 793 i = pcmcia_request_io(link, &link->io);
805 } 794 }
806 dev->base_addr = link->io.BasePort1 + 0x10; 795 dev->base_addr = link->io.BasePort1 + 0x10;
807 return i; 796 return i;
808} 797}
809 798
810static int osi_setup(dev_link_t *link, u_short manfid, u_short cardid) 799static int osi_setup(struct pcmcia_device *link, u_short manfid, u_short cardid)
811{ 800{
812 client_handle_t handle = link->handle;
813 struct net_device *dev = link->priv; 801 struct net_device *dev = link->priv;
814 struct smc_cfg_mem *cfg_mem; 802 struct smc_cfg_mem *cfg_mem;
815 tuple_t *tuple; 803 tuple_t *tuple;
@@ -830,12 +818,12 @@ static int osi_setup(dev_link_t *link, u_short manfid, u_short cardid)
830 818
831 /* Read the station address from tuple 0x90, subtuple 0x04 */ 819 /* Read the station address from tuple 0x90, subtuple 0x04 */
832 tuple->DesiredTuple = 0x90; 820 tuple->DesiredTuple = 0x90;
833 i = pcmcia_get_first_tuple(handle, tuple); 821 i = pcmcia_get_first_tuple(link, tuple);
834 while (i == CS_SUCCESS) { 822 while (i == CS_SUCCESS) {
835 i = pcmcia_get_tuple_data(handle, tuple); 823 i = pcmcia_get_tuple_data(link, tuple);
836 if ((i != CS_SUCCESS) || (buf[0] == 0x04)) 824 if ((i != CS_SUCCESS) || (buf[0] == 0x04))
837 break; 825 break;
838 i = pcmcia_get_next_tuple(handle, tuple); 826 i = pcmcia_get_next_tuple(link, tuple);
839 } 827 }
840 if (i != CS_SUCCESS) { 828 if (i != CS_SUCCESS) {
841 rc = -1; 829 rc = -1;
@@ -868,57 +856,47 @@ free_cfg_mem:
868 return rc; 856 return rc;
869} 857}
870 858
871static int smc91c92_suspend(struct pcmcia_device *p_dev) 859static int smc91c92_suspend(struct pcmcia_device *link)
872{ 860{
873 dev_link_t *link = dev_to_instance(p_dev);
874 struct net_device *dev = link->priv; 861 struct net_device *dev = link->priv;
875 862
876 link->state |= DEV_SUSPEND; 863 if (link->open)
877 if (link->state & DEV_CONFIG) { 864 netif_device_detach(dev);
878 if (link->open)
879 netif_device_detach(dev);
880 pcmcia_release_configuration(link->handle);
881 }
882 865
883 return 0; 866 return 0;
884} 867}
885 868
886static int smc91c92_resume(struct pcmcia_device *p_dev) 869static int smc91c92_resume(struct pcmcia_device *link)
887{ 870{
888 dev_link_t *link = dev_to_instance(p_dev);
889 struct net_device *dev = link->priv; 871 struct net_device *dev = link->priv;
890 struct smc_private *smc = netdev_priv(dev); 872 struct smc_private *smc = netdev_priv(dev);
891 int i; 873 int i;
892 874
893 link->state &= ~DEV_SUSPEND; 875 if ((smc->manfid == MANFID_MEGAHERTZ) &&
894 if (link->state & DEV_CONFIG) { 876 (smc->cardid == PRODID_MEGAHERTZ_EM3288))
895 if ((smc->manfid == MANFID_MEGAHERTZ) && 877 mhz_3288_power(link);
896 (smc->cardid == PRODID_MEGAHERTZ_EM3288)) 878 if (smc->manfid == MANFID_MOTOROLA)
897 mhz_3288_power(link); 879 mot_config(link);
898 pcmcia_request_configuration(link->handle, &link->conf); 880 if ((smc->manfid == MANFID_OSITECH) &&
899 if (smc->manfid == MANFID_MOTOROLA) 881 (smc->cardid != PRODID_OSITECH_SEVEN)) {
900 mot_config(link); 882 /* Power up the card and enable interrupts */
901 if ((smc->manfid == MANFID_OSITECH) && 883 set_bits(0x0300, dev->base_addr-0x10+OSITECH_AUI_PWR);
902 (smc->cardid != PRODID_OSITECH_SEVEN)) { 884 set_bits(0x0300, dev->base_addr-0x10+OSITECH_RESET_ISR);
903 /* Power up the card and enable interrupts */ 885 }
904 set_bits(0x0300, dev->base_addr-0x10+OSITECH_AUI_PWR); 886 if (((smc->manfid == MANFID_OSITECH) &&
905 set_bits(0x0300, dev->base_addr-0x10+OSITECH_RESET_ISR); 887 (smc->cardid == PRODID_OSITECH_SEVEN)) ||
906 } 888 ((smc->manfid == MANFID_PSION) &&
907 if (((smc->manfid == MANFID_OSITECH) && 889 (smc->cardid == PRODID_PSION_NET100))) {
908 (smc->cardid == PRODID_OSITECH_SEVEN)) || 890 /* Download the Seven of Diamonds firmware */
909 ((smc->manfid == MANFID_PSION) && 891 for (i = 0; i < sizeof(__Xilinx7OD); i++) {
910 (smc->cardid == PRODID_PSION_NET100))) { 892 outb(__Xilinx7OD[i], link->io.BasePort1+2);
911 /* Download the Seven of Diamonds firmware */ 893 udelay(50);
912 for (i = 0; i < sizeof(__Xilinx7OD); i++) {
913 outb(__Xilinx7OD[i], link->io.BasePort1+2);
914 udelay(50);
915 }
916 }
917 if (link->open) {
918 smc_reset(dev);
919 netif_device_attach(dev);
920 } 894 }
921 } 895 }
896 if (link->open) {
897 smc_reset(dev);
898 netif_device_attach(dev);
899 }
922 900
923 return 0; 901 return 0;
924} 902}
@@ -931,7 +909,7 @@ static int smc91c92_resume(struct pcmcia_device *p_dev)
931 909
932======================================================================*/ 910======================================================================*/
933 911
934static int check_sig(dev_link_t *link) 912static int check_sig(struct pcmcia_device *link)
935{ 913{
936 struct net_device *dev = link->priv; 914 struct net_device *dev = link->priv;
937 kio_addr_t ioaddr = dev->base_addr; 915 kio_addr_t ioaddr = dev->base_addr;
@@ -964,13 +942,15 @@ static int check_sig(dev_link_t *link)
964 } 942 }
965 943
966 if (width) { 944 if (width) {
967 printk(KERN_INFO "smc91c92_cs: using 8-bit IO window.\n"); 945 modconf_t mod = {
968 smc91c92_suspend(link->handle); 946 .Attributes = CONF_IO_CHANGE_WIDTH,
969 pcmcia_release_io(link->handle, &link->io); 947 };
970 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 948 printk(KERN_INFO "smc91c92_cs: using 8-bit IO window.\n");
971 pcmcia_request_io(link->handle, &link->io); 949
972 smc91c92_resume(link->handle); 950 smc91c92_suspend(link);
973 return check_sig(link); 951 pcmcia_modify_configuration(link, &mod);
952 smc91c92_resume(link);
953 return check_sig(link);
974 } 954 }
975 return -ENODEV; 955 return -ENODEV;
976} 956}
@@ -984,11 +964,10 @@ static int check_sig(dev_link_t *link)
984======================================================================*/ 964======================================================================*/
985 965
986#define CS_EXIT_TEST(ret, svc, label) \ 966#define CS_EXIT_TEST(ret, svc, label) \
987if (ret != CS_SUCCESS) { cs_error(link->handle, svc, ret); goto label; } 967if (ret != CS_SUCCESS) { cs_error(link, svc, ret); goto label; }
988 968
989static void smc91c92_config(dev_link_t *link) 969static int smc91c92_config(struct pcmcia_device *link)
990{ 970{
991 client_handle_t handle = link->handle;
992 struct net_device *dev = link->priv; 971 struct net_device *dev = link->priv;
993 struct smc_private *smc = netdev_priv(dev); 972 struct smc_private *smc = netdev_priv(dev);
994 struct smc_cfg_mem *cfg_mem; 973 struct smc_cfg_mem *cfg_mem;
@@ -1015,21 +994,18 @@ static void smc91c92_config(dev_link_t *link)
1015 tuple->TupleDataMax = 64; 994 tuple->TupleDataMax = 64;
1016 995
1017 tuple->DesiredTuple = CISTPL_CONFIG; 996 tuple->DesiredTuple = CISTPL_CONFIG;
1018 i = first_tuple(handle, tuple, parse); 997 i = first_tuple(link, tuple, parse);
1019 CS_EXIT_TEST(i, ParseTuple, config_failed); 998 CS_EXIT_TEST(i, ParseTuple, config_failed);
1020 link->conf.ConfigBase = parse->config.base; 999 link->conf.ConfigBase = parse->config.base;
1021 link->conf.Present = parse->config.rmask[0]; 1000 link->conf.Present = parse->config.rmask[0];
1022 1001
1023 tuple->DesiredTuple = CISTPL_MANFID; 1002 tuple->DesiredTuple = CISTPL_MANFID;
1024 tuple->Attributes = TUPLE_RETURN_COMMON; 1003 tuple->Attributes = TUPLE_RETURN_COMMON;
1025 if (first_tuple(handle, tuple, parse) == CS_SUCCESS) { 1004 if (first_tuple(link, tuple, parse) == CS_SUCCESS) {
1026 smc->manfid = parse->manfid.manf; 1005 smc->manfid = parse->manfid.manf;
1027 smc->cardid = parse->manfid.card; 1006 smc->cardid = parse->manfid.card;
1028 } 1007 }
1029 1008
1030 /* Configure card */
1031 link->state |= DEV_CONFIG;
1032
1033 if ((smc->manfid == MANFID_OSITECH) && 1009 if ((smc->manfid == MANFID_OSITECH) &&
1034 (smc->cardid != PRODID_OSITECH_SEVEN)) { 1010 (smc->cardid != PRODID_OSITECH_SEVEN)) {
1035 i = osi_config(link); 1011 i = osi_config(link);
@@ -1043,9 +1019,9 @@ static void smc91c92_config(dev_link_t *link)
1043 } 1019 }
1044 CS_EXIT_TEST(i, RequestIO, config_failed); 1020 CS_EXIT_TEST(i, RequestIO, config_failed);
1045 1021
1046 i = pcmcia_request_irq(link->handle, &link->irq); 1022 i = pcmcia_request_irq(link, &link->irq);
1047 CS_EXIT_TEST(i, RequestIRQ, config_failed); 1023 CS_EXIT_TEST(i, RequestIRQ, config_failed);
1048 i = pcmcia_request_configuration(link->handle, &link->conf); 1024 i = pcmcia_request_configuration(link, &link->conf);
1049 CS_EXIT_TEST(i, RequestConfiguration, config_failed); 1025 CS_EXIT_TEST(i, RequestConfiguration, config_failed);
1050 1026
1051 if (smc->manfid == MANFID_MOTOROLA) 1027 if (smc->manfid == MANFID_MOTOROLA)
@@ -1124,13 +1100,12 @@ static void smc91c92_config(dev_link_t *link)
1124 SMC_SELECT_BANK(0); 1100 SMC_SELECT_BANK(0);
1125 } 1101 }
1126 1102
1127 link->dev = &smc->node; 1103 link->dev_node = &smc->node;
1128 link->state &= ~DEV_CONFIG_PENDING; 1104 SET_NETDEV_DEV(dev, &handle_to_dev(link));
1129 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
1130 1105
1131 if (register_netdev(dev) != 0) { 1106 if (register_netdev(dev) != 0) {
1132 printk(KERN_ERR "smc91c92_cs: register_netdev() failed\n"); 1107 printk(KERN_ERR "smc91c92_cs: register_netdev() failed\n");
1133 link->dev = NULL; 1108 link->dev_node = NULL;
1134 goto config_undo; 1109 goto config_undo;
1135 } 1110 }
1136 1111
@@ -1160,15 +1135,14 @@ static void smc91c92_config(dev_link_t *link)
1160 } 1135 }
1161 } 1136 }
1162 kfree(cfg_mem); 1137 kfree(cfg_mem);
1163 return; 1138 return 0;
1164 1139
1165config_undo: 1140config_undo:
1166 unregister_netdev(dev); 1141 unregister_netdev(dev);
1167config_failed: /* CS_EXIT_TEST() calls jump to here... */ 1142config_failed: /* CS_EXIT_TEST() calls jump to here... */
1168 smc91c92_release(link); 1143 smc91c92_release(link);
1169 link->state &= ~DEV_CONFIG_PENDING;
1170 kfree(cfg_mem); 1144 kfree(cfg_mem);
1171 1145 return -ENODEV;
1172} /* smc91c92_config */ 1146} /* smc91c92_config */
1173 1147
1174/*====================================================================== 1148/*======================================================================
@@ -1179,22 +1153,15 @@ config_failed: /* CS_EXIT_TEST() calls jump to here... */
1179 1153
1180======================================================================*/ 1154======================================================================*/
1181 1155
1182static void smc91c92_release(dev_link_t *link) 1156static void smc91c92_release(struct pcmcia_device *link)
1183{ 1157{
1184 1158 DEBUG(0, "smc91c92_release(0x%p)\n", link);
1185 DEBUG(0, "smc91c92_release(0x%p)\n", link); 1159 if (link->win) {
1186 1160 struct net_device *dev = link->priv;
1187 pcmcia_release_configuration(link->handle); 1161 struct smc_private *smc = netdev_priv(dev);
1188 pcmcia_release_io(link->handle, &link->io); 1162 iounmap(smc->base);
1189 pcmcia_release_irq(link->handle, &link->irq); 1163 }
1190 if (link->win) { 1164 pcmcia_disable_device(link);
1191 struct net_device *dev = link->priv;
1192 struct smc_private *smc = netdev_priv(dev);
1193 iounmap(smc->base);
1194 pcmcia_release_window(link->win);
1195 }
1196
1197 link->state &= ~DEV_CONFIG;
1198} 1165}
1199 1166
1200/*====================================================================== 1167/*======================================================================
@@ -1283,7 +1250,7 @@ static void smc_dump(struct net_device *dev)
1283static int smc_open(struct net_device *dev) 1250static int smc_open(struct net_device *dev)
1284{ 1251{
1285 struct smc_private *smc = netdev_priv(dev); 1252 struct smc_private *smc = netdev_priv(dev);
1286 dev_link_t *link = &smc->link; 1253 struct pcmcia_device *link = smc->p_dev;
1287 1254
1288#ifdef PCMCIA_DEBUG 1255#ifdef PCMCIA_DEBUG
1289 DEBUG(0, "%s: smc_open(%p), ID/Window %4.4x.\n", 1256 DEBUG(0, "%s: smc_open(%p), ID/Window %4.4x.\n",
@@ -1292,7 +1259,7 @@ static int smc_open(struct net_device *dev)
1292#endif 1259#endif
1293 1260
1294 /* Check that the PCMCIA card is still here. */ 1261 /* Check that the PCMCIA card is still here. */
1295 if (!DEV_OK(link)) 1262 if (!pcmcia_dev_present(link))
1296 return -ENODEV; 1263 return -ENODEV;
1297 /* Physical device present signature. */ 1264 /* Physical device present signature. */
1298 if (check_sig(link) < 0) { 1265 if (check_sig(link) < 0) {
@@ -1320,7 +1287,7 @@ static int smc_open(struct net_device *dev)
1320static int smc_close(struct net_device *dev) 1287static int smc_close(struct net_device *dev)
1321{ 1288{
1322 struct smc_private *smc = netdev_priv(dev); 1289 struct smc_private *smc = netdev_priv(dev);
1323 dev_link_t *link = &smc->link; 1290 struct pcmcia_device *link = smc->p_dev;
1324 kio_addr_t ioaddr = dev->base_addr; 1291 kio_addr_t ioaddr = dev->base_addr;
1325 1292
1326 DEBUG(0, "%s: smc_close(), status %4.4x.\n", 1293 DEBUG(0, "%s: smc_close(), status %4.4x.\n",
@@ -2311,7 +2278,7 @@ static struct pcmcia_driver smc91c92_cs_driver = {
2311 .drv = { 2278 .drv = {
2312 .name = "smc91c92_cs", 2279 .name = "smc91c92_cs",
2313 }, 2280 },
2314 .probe = smc91c92_attach, 2281 .probe = smc91c92_probe,
2315 .remove = smc91c92_detach, 2282 .remove = smc91c92_detach,
2316 .id_table = smc91c92_ids, 2283 .id_table = smc91c92_ids,
2317 .suspend = smc91c92_suspend, 2284 .suspend = smc91c92_suspend,
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index e8f849e12976..71f45056a70c 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -289,9 +289,9 @@ static void mii_wr(kio_addr_t ioaddr, u_char phyaddr, u_char phyreg,
289 * and ejection events. They are invoked from the event handler. 289 * and ejection events. They are invoked from the event handler.
290 */ 290 */
291 291
292static int has_ce2_string(dev_link_t * link); 292static int has_ce2_string(struct pcmcia_device * link);
293static void xirc2ps_config(dev_link_t * link); 293static int xirc2ps_config(struct pcmcia_device * link);
294static void xirc2ps_release(dev_link_t * link); 294static void xirc2ps_release(struct pcmcia_device * link);
295 295
296/**************** 296/****************
297 * The attach() and detach() entry points are used to create and destroy 297 * The attach() and detach() entry points are used to create and destroy
@@ -313,10 +313,10 @@ static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id, struct pt_regs *regs
313/**************** 313/****************
314 * A linked list of "instances" of the device. Each actual 314 * A linked list of "instances" of the device. Each actual
315 * PCMCIA card corresponds to one device instance, and is described 315 * PCMCIA card corresponds to one device instance, and is described
316 * by one dev_link_t structure (defined in ds.h). 316 * by one struct pcmcia_device structure (defined in ds.h).
317 * 317 *
318 * You may not want to use a linked list for this -- for example, the 318 * You may not want to use a linked list for this -- for example, the
319 * memory card driver uses an array of dev_link_t pointers, where minor 319 * memory card driver uses an array of struct pcmcia_device pointers, where minor
320 * device numbers are used to derive the corresponding array index. 320 * device numbers are used to derive the corresponding array index.
321 */ 321 */
322 322
@@ -326,13 +326,13 @@ static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id, struct pt_regs *regs
326 * example, ethernet cards, modems). In other cases, there may be 326 * example, ethernet cards, modems). In other cases, there may be
327 * many actual or logical devices (SCSI adapters, memory cards with 327 * many actual or logical devices (SCSI adapters, memory cards with
328 * multiple partitions). The dev_node_t structures need to be kept 328 * multiple partitions). The dev_node_t structures need to be kept
329 * in a linked list starting at the 'dev' field of a dev_link_t 329 * in a linked list starting at the 'dev' field of a struct pcmcia_device
330 * structure. We allocate them in the card's private data structure, 330 * structure. We allocate them in the card's private data structure,
331 * because they generally can't be allocated dynamically. 331 * because they generally can't be allocated dynamically.
332 */ 332 */
333 333
334typedef struct local_info_t { 334typedef struct local_info_t {
335 dev_link_t link; 335 struct pcmcia_device *p_dev;
336 dev_node_t node; 336 dev_node_t node;
337 struct net_device_stats stats; 337 struct net_device_stats stats;
338 int card_type; 338 int card_type;
@@ -355,7 +355,7 @@ static void do_tx_timeout(struct net_device *dev);
355static struct net_device_stats *do_get_stats(struct net_device *dev); 355static struct net_device_stats *do_get_stats(struct net_device *dev);
356static void set_addresses(struct net_device *dev); 356static void set_addresses(struct net_device *dev);
357static void set_multicast_list(struct net_device *dev); 357static void set_multicast_list(struct net_device *dev);
358static int set_card_type(dev_link_t *link, const void *s); 358static int set_card_type(struct pcmcia_device *link, const void *s);
359static int do_config(struct net_device *dev, struct ifmap *map); 359static int do_config(struct net_device *dev, struct ifmap *map);
360static int do_open(struct net_device *dev); 360static int do_open(struct net_device *dev);
361static int do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 361static int do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
@@ -368,7 +368,7 @@ static int do_stop(struct net_device *dev);
368 368
369/*=============== Helper functions =========================*/ 369/*=============== Helper functions =========================*/
370static int 370static int
371first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) 371first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse)
372{ 372{
373 int err; 373 int err;
374 374
@@ -379,7 +379,7 @@ first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
379} 379}
380 380
381static int 381static int
382next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) 382next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse)
383{ 383{
384 int err; 384 int err;
385 385
@@ -553,9 +553,8 @@ mii_wr(kio_addr_t ioaddr, u_char phyaddr, u_char phyreg, unsigned data, int len)
553 */ 553 */
554 554
555static int 555static int
556xirc2ps_attach(struct pcmcia_device *p_dev) 556xirc2ps_probe(struct pcmcia_device *link)
557{ 557{
558 dev_link_t *link;
559 struct net_device *dev; 558 struct net_device *dev;
560 local_info_t *local; 559 local_info_t *local;
561 560
@@ -566,12 +565,11 @@ xirc2ps_attach(struct pcmcia_device *p_dev)
566 if (!dev) 565 if (!dev)
567 return -ENOMEM; 566 return -ENOMEM;
568 local = netdev_priv(dev); 567 local = netdev_priv(dev);
569 link = &local->link; 568 local->p_dev = link;
570 link->priv = dev; 569 link->priv = dev;
571 570
572 /* General socket configuration */ 571 /* General socket configuration */
573 link->conf.Attributes = CONF_ENABLE_IRQ; 572 link->conf.Attributes = CONF_ENABLE_IRQ;
574 link->conf.Vcc = 50;
575 link->conf.IntType = INT_MEMORY_AND_IO; 573 link->conf.IntType = INT_MEMORY_AND_IO;
576 link->conf.ConfigIndex = 1; 574 link->conf.ConfigIndex = 1;
577 link->conf.Present = PRESENT_OPTION; 575 link->conf.Present = PRESENT_OPTION;
@@ -593,13 +591,7 @@ xirc2ps_attach(struct pcmcia_device *p_dev)
593 dev->watchdog_timeo = TX_TIMEOUT; 591 dev->watchdog_timeo = TX_TIMEOUT;
594#endif 592#endif
595 593
596 link->handle = p_dev; 594 return xirc2ps_config(link);
597 p_dev->instance = link;
598
599 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
600 xirc2ps_config(link);
601
602 return 0;
603} /* xirc2ps_attach */ 595} /* xirc2ps_attach */
604 596
605/**************** 597/****************
@@ -610,18 +602,16 @@ xirc2ps_attach(struct pcmcia_device *p_dev)
610 */ 602 */
611 603
612static void 604static void
613xirc2ps_detach(struct pcmcia_device *p_dev) 605xirc2ps_detach(struct pcmcia_device *link)
614{ 606{
615 dev_link_t *link = dev_to_instance(p_dev);
616 struct net_device *dev = link->priv; 607 struct net_device *dev = link->priv;
617 608
618 DEBUG(0, "detach(0x%p)\n", link); 609 DEBUG(0, "detach(0x%p)\n", link);
619 610
620 if (link->dev) 611 if (link->dev_node)
621 unregister_netdev(dev); 612 unregister_netdev(dev);
622 613
623 if (link->state & DEV_CONFIG) 614 xirc2ps_release(link);
624 xirc2ps_release(link);
625 615
626 free_netdev(dev); 616 free_netdev(dev);
627} /* xirc2ps_detach */ 617} /* xirc2ps_detach */
@@ -645,7 +635,7 @@ xirc2ps_detach(struct pcmcia_device *p_dev)
645 * 635 *
646 */ 636 */
647static int 637static int
648set_card_type(dev_link_t *link, const void *s) 638set_card_type(struct pcmcia_device *link, const void *s)
649{ 639{
650 struct net_device *dev = link->priv; 640 struct net_device *dev = link->priv;
651 local_info_t *local = netdev_priv(dev); 641 local_info_t *local = netdev_priv(dev);
@@ -714,9 +704,8 @@ set_card_type(dev_link_t *link, const void *s)
714 * Returns: true if this is a CE2 704 * Returns: true if this is a CE2
715 */ 705 */
716static int 706static int
717has_ce2_string(dev_link_t * link) 707has_ce2_string(struct pcmcia_device * link)
718{ 708{
719 client_handle_t handle = link->handle;
720 tuple_t tuple; 709 tuple_t tuple;
721 cisparse_t parse; 710 cisparse_t parse;
722 u_char buf[256]; 711 u_char buf[256];
@@ -726,7 +715,7 @@ has_ce2_string(dev_link_t * link)
726 tuple.TupleDataMax = 254; 715 tuple.TupleDataMax = 254;
727 tuple.TupleOffset = 0; 716 tuple.TupleOffset = 0;
728 tuple.DesiredTuple = CISTPL_VERS_1; 717 tuple.DesiredTuple = CISTPL_VERS_1;
729 if (!first_tuple(handle, &tuple, &parse) && parse.version_1.ns > 2) { 718 if (!first_tuple(link, &tuple, &parse) && parse.version_1.ns > 2) {
730 if (strstr(parse.version_1.str + parse.version_1.ofs[2], "CE2")) 719 if (strstr(parse.version_1.str + parse.version_1.ofs[2], "CE2"))
731 return 1; 720 return 1;
732 } 721 }
@@ -738,10 +727,9 @@ has_ce2_string(dev_link_t * link)
738 * is received, to configure the PCMCIA socket, and to make the 727 * is received, to configure the PCMCIA socket, and to make the
739 * ethernet device available to the system. 728 * ethernet device available to the system.
740 */ 729 */
741static void 730static int
742xirc2ps_config(dev_link_t * link) 731xirc2ps_config(struct pcmcia_device * link)
743{ 732{
744 client_handle_t handle = link->handle;
745 struct net_device *dev = link->priv; 733 struct net_device *dev = link->priv;
746 local_info_t *local = netdev_priv(dev); 734 local_info_t *local = netdev_priv(dev);
747 tuple_t tuple; 735 tuple_t tuple;
@@ -767,7 +755,7 @@ xirc2ps_config(dev_link_t * link)
767 755
768 /* Is this a valid card */ 756 /* Is this a valid card */
769 tuple.DesiredTuple = CISTPL_MANFID; 757 tuple.DesiredTuple = CISTPL_MANFID;
770 if ((err=first_tuple(handle, &tuple, &parse))) { 758 if ((err=first_tuple(link, &tuple, &parse))) {
771 printk(KNOT_XIRC "manfid not found in CIS\n"); 759 printk(KNOT_XIRC "manfid not found in CIS\n");
772 goto failure; 760 goto failure;
773 } 761 }
@@ -803,15 +791,15 @@ xirc2ps_config(dev_link_t * link)
803 791
804 /* get configuration stuff */ 792 /* get configuration stuff */
805 tuple.DesiredTuple = CISTPL_CONFIG; 793 tuple.DesiredTuple = CISTPL_CONFIG;
806 if ((err=first_tuple(handle, &tuple, &parse))) 794 if ((err=first_tuple(link, &tuple, &parse)))
807 goto cis_error; 795 goto cis_error;
808 link->conf.ConfigBase = parse.config.base; 796 link->conf.ConfigBase = parse.config.base;
809 link->conf.Present = parse.config.rmask[0]; 797 link->conf.Present = parse.config.rmask[0];
810 798
811 /* get the ethernet address from the CIS */ 799 /* get the ethernet address from the CIS */
812 tuple.DesiredTuple = CISTPL_FUNCE; 800 tuple.DesiredTuple = CISTPL_FUNCE;
813 for (err = first_tuple(handle, &tuple, &parse); !err; 801 for (err = first_tuple(link, &tuple, &parse); !err;
814 err = next_tuple(handle, &tuple, &parse)) { 802 err = next_tuple(link, &tuple, &parse)) {
815 /* Once I saw two CISTPL_FUNCE_LAN_NODE_ID entries: 803 /* Once I saw two CISTPL_FUNCE_LAN_NODE_ID entries:
816 * the first one with a length of zero the second correct - 804 * the first one with a length of zero the second correct -
817 * so I skip all entries with length 0 */ 805 * so I skip all entries with length 0 */
@@ -821,8 +809,8 @@ xirc2ps_config(dev_link_t * link)
821 } 809 }
822 if (err) { /* not found: try to get the node-id from tuple 0x89 */ 810 if (err) { /* not found: try to get the node-id from tuple 0x89 */
823 tuple.DesiredTuple = 0x89; /* data layout looks like tuple 0x22 */ 811 tuple.DesiredTuple = 0x89; /* data layout looks like tuple 0x22 */
824 if ((err = pcmcia_get_first_tuple(handle, &tuple)) == 0 && 812 if ((err = pcmcia_get_first_tuple(link, &tuple)) == 0 &&
825 (err = pcmcia_get_tuple_data(handle, &tuple)) == 0) { 813 (err = pcmcia_get_tuple_data(link, &tuple)) == 0) {
826 if (tuple.TupleDataLen == 8 && *buf == CISTPL_FUNCE_LAN_NODE_ID) 814 if (tuple.TupleDataLen == 8 && *buf == CISTPL_FUNCE_LAN_NODE_ID)
827 memcpy(&parse, buf, 8); 815 memcpy(&parse, buf, 8);
828 else 816 else
@@ -831,8 +819,8 @@ xirc2ps_config(dev_link_t * link)
831 } 819 }
832 if (err) { /* another try (James Lehmer's CE2 version 4.1)*/ 820 if (err) { /* another try (James Lehmer's CE2 version 4.1)*/
833 tuple.DesiredTuple = CISTPL_FUNCE; 821 tuple.DesiredTuple = CISTPL_FUNCE;
834 for (err = first_tuple(handle, &tuple, &parse); !err; 822 for (err = first_tuple(link, &tuple, &parse); !err;
835 err = next_tuple(handle, &tuple, &parse)) { 823 err = next_tuple(link, &tuple, &parse)) {
836 if (parse.funce.type == 0x02 && parse.funce.data[0] == 1 824 if (parse.funce.type == 0x02 && parse.funce.data[0] == 1
837 && parse.funce.data[1] == 6 && tuple.TupleDataLen == 13) { 825 && parse.funce.data[1] == 6 && tuple.TupleDataLen == 13) {
838 buf[1] = 4; 826 buf[1] = 4;
@@ -853,9 +841,6 @@ xirc2ps_config(dev_link_t * link)
853 for (i=0; i < 6; i++) 841 for (i=0; i < 6; i++)
854 dev->dev_addr[i] = node_id->id[i]; 842 dev->dev_addr[i] = node_id->id[i];
855 843
856 /* Configure card */
857 link->state |= DEV_CONFIG;
858
859 link->io.IOAddrLines =10; 844 link->io.IOAddrLines =10;
860 link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 845 link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
861 link->irq.Attributes = IRQ_HANDLE_PRESENT; 846 link->irq.Attributes = IRQ_HANDLE_PRESENT;
@@ -875,14 +860,14 @@ xirc2ps_config(dev_link_t * link)
875 * Ethernet port */ 860 * Ethernet port */
876 link->io.NumPorts1 = 16; /* no Mako stuff anymore */ 861 link->io.NumPorts1 = 16; /* no Mako stuff anymore */
877 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 862 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
878 for (err = first_tuple(handle, &tuple, &parse); !err; 863 for (err = first_tuple(link, &tuple, &parse); !err;
879 err = next_tuple(handle, &tuple, &parse)) { 864 err = next_tuple(link, &tuple, &parse)) {
880 if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { 865 if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) {
881 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { 866 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) {
882 link->conf.ConfigIndex = cf->index ; 867 link->conf.ConfigIndex = cf->index ;
883 link->io.BasePort2 = cf->io.win[0].base; 868 link->io.BasePort2 = cf->io.win[0].base;
884 link->io.BasePort1 = ioaddr; 869 link->io.BasePort1 = ioaddr;
885 if (!(err=pcmcia_request_io(link->handle, &link->io))) 870 if (!(err=pcmcia_request_io(link, &link->io)))
886 goto port_found; 871 goto port_found;
887 } 872 }
888 } 873 }
@@ -896,15 +881,15 @@ xirc2ps_config(dev_link_t * link)
896 */ 881 */
897 for (pass=0; pass < 2; pass++) { 882 for (pass=0; pass < 2; pass++) {
898 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 883 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
899 for (err = first_tuple(handle, &tuple, &parse); !err; 884 for (err = first_tuple(link, &tuple, &parse); !err;
900 err = next_tuple(handle, &tuple, &parse)){ 885 err = next_tuple(link, &tuple, &parse)){
901 if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8){ 886 if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8){
902 link->conf.ConfigIndex = cf->index ; 887 link->conf.ConfigIndex = cf->index ;
903 link->io.BasePort2 = cf->io.win[0].base; 888 link->io.BasePort2 = cf->io.win[0].base;
904 link->io.BasePort1 = link->io.BasePort2 889 link->io.BasePort1 = link->io.BasePort2
905 + (pass ? (cf->index & 0x20 ? -24:8) 890 + (pass ? (cf->index & 0x20 ? -24:8)
906 : (cf->index & 0x20 ? 8:-24)); 891 : (cf->index & 0x20 ? 8:-24));
907 if (!(err=pcmcia_request_io(link->handle, &link->io))) 892 if (!(err=pcmcia_request_io(link, &link->io)))
908 goto port_found; 893 goto port_found;
909 } 894 }
910 } 895 }
@@ -919,12 +904,12 @@ xirc2ps_config(dev_link_t * link)
919 link->io.NumPorts1 = 16; 904 link->io.NumPorts1 = 16;
920 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { 905 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) {
921 link->io.BasePort1 = ioaddr; 906 link->io.BasePort1 = ioaddr;
922 if (!(err=pcmcia_request_io(link->handle, &link->io))) 907 if (!(err=pcmcia_request_io(link, &link->io)))
923 goto port_found; 908 goto port_found;
924 } 909 }
925 link->io.BasePort1 = 0; /* let CS decide */ 910 link->io.BasePort1 = 0; /* let CS decide */
926 if ((err=pcmcia_request_io(link->handle, &link->io))) { 911 if ((err=pcmcia_request_io(link, &link->io))) {
927 cs_error(link->handle, RequestIO, err); 912 cs_error(link, RequestIO, err);
928 goto config_error; 913 goto config_error;
929 } 914 }
930 } 915 }
@@ -936,8 +921,8 @@ xirc2ps_config(dev_link_t * link)
936 * Now allocate an interrupt line. Note that this does not 921 * Now allocate an interrupt line. Note that this does not
937 * actually assign a handler to the interrupt. 922 * actually assign a handler to the interrupt.
938 */ 923 */
939 if ((err=pcmcia_request_irq(link->handle, &link->irq))) { 924 if ((err=pcmcia_request_irq(link, &link->irq))) {
940 cs_error(link->handle, RequestIRQ, err); 925 cs_error(link, RequestIRQ, err);
941 goto config_error; 926 goto config_error;
942 } 927 }
943 928
@@ -945,8 +930,8 @@ xirc2ps_config(dev_link_t * link)
945 * This actually configures the PCMCIA socket -- setting up 930 * This actually configures the PCMCIA socket -- setting up
946 * the I/O windows and the interrupt mapping. 931 * the I/O windows and the interrupt mapping.
947 */ 932 */
948 if ((err=pcmcia_request_configuration(link->handle, &link->conf))) { 933 if ((err=pcmcia_request_configuration(link, &link->conf))) {
949 cs_error(link->handle, RequestConfiguration, err); 934 cs_error(link, RequestConfiguration, err);
950 goto config_error; 935 goto config_error;
951 } 936 }
952 937
@@ -963,15 +948,15 @@ xirc2ps_config(dev_link_t * link)
963 reg.Action = CS_WRITE; 948 reg.Action = CS_WRITE;
964 reg.Offset = CISREG_IOBASE_0; 949 reg.Offset = CISREG_IOBASE_0;
965 reg.Value = link->io.BasePort2 & 0xff; 950 reg.Value = link->io.BasePort2 & 0xff;
966 if ((err = pcmcia_access_configuration_register(link->handle, &reg))) { 951 if ((err = pcmcia_access_configuration_register(link, &reg))) {
967 cs_error(link->handle, AccessConfigurationRegister, err); 952 cs_error(link, AccessConfigurationRegister, err);
968 goto config_error; 953 goto config_error;
969 } 954 }
970 reg.Action = CS_WRITE; 955 reg.Action = CS_WRITE;
971 reg.Offset = CISREG_IOBASE_1; 956 reg.Offset = CISREG_IOBASE_1;
972 reg.Value = (link->io.BasePort2 >> 8) & 0xff; 957 reg.Value = (link->io.BasePort2 >> 8) & 0xff;
973 if ((err = pcmcia_access_configuration_register(link->handle, &reg))) { 958 if ((err = pcmcia_access_configuration_register(link, &reg))) {
974 cs_error(link->handle, AccessConfigurationRegister, err); 959 cs_error(link, AccessConfigurationRegister, err);
975 goto config_error; 960 goto config_error;
976 } 961 }
977 962
@@ -982,15 +967,15 @@ xirc2ps_config(dev_link_t * link)
982 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 967 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
983 req.Base = req.Size = 0; 968 req.Base = req.Size = 0;
984 req.AccessSpeed = 0; 969 req.AccessSpeed = 0;
985 if ((err = pcmcia_request_window(&link->handle, &req, &link->win))) { 970 if ((err = pcmcia_request_window(&link, &req, &link->win))) {
986 cs_error(link->handle, RequestWindow, err); 971 cs_error(link, RequestWindow, err);
987 goto config_error; 972 goto config_error;
988 } 973 }
989 local->dingo_ccr = ioremap(req.Base,0x1000) + 0x0800; 974 local->dingo_ccr = ioremap(req.Base,0x1000) + 0x0800;
990 mem.CardOffset = 0x0; 975 mem.CardOffset = 0x0;
991 mem.Page = 0; 976 mem.Page = 0;
992 if ((err = pcmcia_map_mem_page(link->win, &mem))) { 977 if ((err = pcmcia_map_mem_page(link->win, &mem))) {
993 cs_error(link->handle, MapMemPage, err); 978 cs_error(link, MapMemPage, err);
994 goto config_error; 979 goto config_error;
995 } 980 }
996 981
@@ -1050,13 +1035,12 @@ xirc2ps_config(dev_link_t * link)
1050 if (local->dingo) 1035 if (local->dingo)
1051 do_reset(dev, 1); /* a kludge to make the cem56 work */ 1036 do_reset(dev, 1); /* a kludge to make the cem56 work */
1052 1037
1053 link->dev = &local->node; 1038 link->dev_node = &local->node;
1054 link->state &= ~DEV_CONFIG_PENDING; 1039 SET_NETDEV_DEV(dev, &handle_to_dev(link));
1055 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
1056 1040
1057 if ((err=register_netdev(dev))) { 1041 if ((err=register_netdev(dev))) {
1058 printk(KNOT_XIRC "register_netdev() failed\n"); 1042 printk(KNOT_XIRC "register_netdev() failed\n");
1059 link->dev = NULL; 1043 link->dev_node = NULL;
1060 goto config_error; 1044 goto config_error;
1061 } 1045 }
1062 1046
@@ -1069,17 +1053,16 @@ xirc2ps_config(dev_link_t * link)
1069 printk("%c%02X", i?':':' ', dev->dev_addr[i]); 1053 printk("%c%02X", i?':':' ', dev->dev_addr[i]);
1070 printk("\n"); 1054 printk("\n");
1071 1055
1072 return; 1056 return 0;
1073 1057
1074 config_error: 1058 config_error:
1075 link->state &= ~DEV_CONFIG_PENDING;
1076 xirc2ps_release(link); 1059 xirc2ps_release(link);
1077 return; 1060 return -ENODEV;
1078 1061
1079 cis_error: 1062 cis_error:
1080 printk(KNOT_XIRC "unable to parse CIS\n"); 1063 printk(KNOT_XIRC "unable to parse CIS\n");
1081 failure: 1064 failure:
1082 link->state &= ~DEV_CONFIG_PENDING; 1065 return -ENODEV;
1083} /* xirc2ps_config */ 1066} /* xirc2ps_config */
1084 1067
1085/**************** 1068/****************
@@ -1088,57 +1071,41 @@ xirc2ps_config(dev_link_t * link)
1088 * still open, this will be postponed until it is closed. 1071 * still open, this will be postponed until it is closed.
1089 */ 1072 */
1090static void 1073static void
1091xirc2ps_release(dev_link_t *link) 1074xirc2ps_release(struct pcmcia_device *link)
1092{ 1075{
1076 DEBUG(0, "release(0x%p)\n", link);
1093 1077
1094 DEBUG(0, "release(0x%p)\n", link); 1078 if (link->win) {
1095 1079 struct net_device *dev = link->priv;
1096 if (link->win) { 1080 local_info_t *local = netdev_priv(dev);
1097 struct net_device *dev = link->priv; 1081 if (local->dingo)
1098 local_info_t *local = netdev_priv(dev); 1082 iounmap(local->dingo_ccr - 0x0800);
1099 if (local->dingo) 1083 }
1100 iounmap(local->dingo_ccr - 0x0800); 1084 pcmcia_disable_device(link);
1101 pcmcia_release_window(link->win);
1102 }
1103 pcmcia_release_configuration(link->handle);
1104 pcmcia_release_io(link->handle, &link->io);
1105 pcmcia_release_irq(link->handle, &link->irq);
1106 link->state &= ~DEV_CONFIG;
1107
1108} /* xirc2ps_release */ 1085} /* xirc2ps_release */
1109 1086
1110/*====================================================================*/ 1087/*====================================================================*/
1111 1088
1112 1089
1113static int xirc2ps_suspend(struct pcmcia_device *p_dev) 1090static int xirc2ps_suspend(struct pcmcia_device *link)
1114{ 1091{
1115 dev_link_t *link = dev_to_instance(p_dev);
1116 struct net_device *dev = link->priv; 1092 struct net_device *dev = link->priv;
1117 1093
1118 link->state |= DEV_SUSPEND; 1094 if (link->open) {
1119 if (link->state & DEV_CONFIG) { 1095 netif_device_detach(dev);
1120 if (link->open) { 1096 do_powerdown(dev);
1121 netif_device_detach(dev);
1122 do_powerdown(dev);
1123 }
1124 pcmcia_release_configuration(link->handle);
1125 } 1097 }
1126 1098
1127 return 0; 1099 return 0;
1128} 1100}
1129 1101
1130static int xirc2ps_resume(struct pcmcia_device *p_dev) 1102static int xirc2ps_resume(struct pcmcia_device *link)
1131{ 1103{
1132 dev_link_t *link = dev_to_instance(p_dev);
1133 struct net_device *dev = link->priv; 1104 struct net_device *dev = link->priv;
1134 1105
1135 link->state &= ~DEV_SUSPEND; 1106 if (link->open) {
1136 if (link->state & DEV_CONFIG) { 1107 do_reset(dev,1);
1137 pcmcia_request_configuration(link->handle, &link->conf); 1108 netif_device_attach(dev);
1138 if (link->open) {
1139 do_reset(dev,1);
1140 netif_device_attach(dev);
1141 }
1142 } 1109 }
1143 1110
1144 return 0; 1111 return 0;
@@ -1552,13 +1519,13 @@ static int
1552do_open(struct net_device *dev) 1519do_open(struct net_device *dev)
1553{ 1520{
1554 local_info_t *lp = netdev_priv(dev); 1521 local_info_t *lp = netdev_priv(dev);
1555 dev_link_t *link = &lp->link; 1522 struct pcmcia_device *link = lp->p_dev;
1556 1523
1557 DEBUG(0, "do_open(%p)\n", dev); 1524 DEBUG(0, "do_open(%p)\n", dev);
1558 1525
1559 /* Check that the PCMCIA card is still here. */ 1526 /* Check that the PCMCIA card is still here. */
1560 /* Physical device present signature. */ 1527 /* Physical device present signature. */
1561 if (!DEV_OK(link)) 1528 if (!pcmcia_dev_present(link))
1562 return -ENODEV; 1529 return -ENODEV;
1563 1530
1564 /* okay */ 1531 /* okay */
@@ -1882,7 +1849,7 @@ do_stop(struct net_device *dev)
1882{ 1849{
1883 kio_addr_t ioaddr = dev->base_addr; 1850 kio_addr_t ioaddr = dev->base_addr;
1884 local_info_t *lp = netdev_priv(dev); 1851 local_info_t *lp = netdev_priv(dev);
1885 dev_link_t *link = &lp->link; 1852 struct pcmcia_device *link = lp->p_dev;
1886 1853
1887 DEBUG(0, "do_stop(%p)\n", dev); 1854 DEBUG(0, "do_stop(%p)\n", dev);
1888 1855
@@ -1935,7 +1902,7 @@ static struct pcmcia_driver xirc2ps_cs_driver = {
1935 .drv = { 1902 .drv = {
1936 .name = "xirc2ps_cs", 1903 .name = "xirc2ps_cs",
1937 }, 1904 },
1938 .probe = xirc2ps_attach, 1905 .probe = xirc2ps_probe,
1939 .remove = xirc2ps_detach, 1906 .remove = xirc2ps_detach,
1940 .id_table = xirc2ps_ids, 1907 .id_table = xirc2ps_ids,
1941 .suspend = xirc2ps_suspend, 1908 .suspend = xirc2ps_suspend,
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index a496460ce224..af0cbb6c5c0c 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -80,8 +80,8 @@ MODULE_SUPPORTED_DEVICE("Aironet 4500, 4800 and Cisco 340 PCMCIA cards");
80 event handler. 80 event handler.
81*/ 81*/
82 82
83static void airo_config(dev_link_t *link); 83static int airo_config(struct pcmcia_device *link);
84static void airo_release(dev_link_t *link); 84static void airo_release(struct pcmcia_device *link);
85 85
86/* 86/*
87 The attach() and detach() entry points are used to create and destroy 87 The attach() and detach() entry points are used to create and destroy
@@ -101,10 +101,10 @@ static void airo_detach(struct pcmcia_device *p_dev);
101/* 101/*
102 A linked list of "instances" of the aironet device. Each actual 102 A linked list of "instances" of the aironet device. Each actual
103 PCMCIA card corresponds to one device instance, and is described 103 PCMCIA card corresponds to one device instance, and is described
104 by one dev_link_t structure (defined in ds.h). 104 by one struct pcmcia_device structure (defined in ds.h).
105 105
106 You may not want to use a linked list for this -- for example, the 106 You may not want to use a linked list for this -- for example, the
107 memory card driver uses an array of dev_link_t pointers, where minor 107 memory card driver uses an array of struct pcmcia_device pointers, where minor
108 device numbers are used to derive the corresponding array index. 108 device numbers are used to derive the corresponding array index.
109*/ 109*/
110 110
@@ -114,7 +114,7 @@ static void airo_detach(struct pcmcia_device *p_dev);
114 example, ethernet cards, modems). In other cases, there may be 114 example, ethernet cards, modems). In other cases, there may be
115 many actual or logical devices (SCSI adapters, memory cards with 115 many actual or logical devices (SCSI adapters, memory cards with
116 multiple partitions). The dev_node_t structures need to be kept 116 multiple partitions). The dev_node_t structures need to be kept
117 in a linked list starting at the 'dev' field of a dev_link_t 117 in a linked list starting at the 'dev' field of a struct pcmcia_device
118 structure. We allocate them in the card's private data structure, 118 structure. We allocate them in the card's private data structure,
119 because they generally shouldn't be allocated dynamically. 119 because they generally shouldn't be allocated dynamically.
120 120
@@ -141,24 +141,16 @@ typedef struct local_info_t {
141 141
142 ======================================================================*/ 142 ======================================================================*/
143 143
144static int airo_attach(struct pcmcia_device *p_dev) 144static int airo_probe(struct pcmcia_device *p_dev)
145{ 145{
146 dev_link_t *link;
147 local_info_t *local; 146 local_info_t *local;
148 147
149 DEBUG(0, "airo_attach()\n"); 148 DEBUG(0, "airo_attach()\n");
150 149
151 /* Initialize the dev_link_t structure */
152 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL);
153 if (!link) {
154 printk(KERN_ERR "airo_cs: no memory for new device\n");
155 return -ENOMEM;
156 }
157
158 /* Interrupt setup */ 150 /* Interrupt setup */
159 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 151 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
160 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 152 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
161 link->irq.Handler = NULL; 153 p_dev->irq.Handler = NULL;
162 154
163 /* 155 /*
164 General socket configuration defaults can go here. In this 156 General socket configuration defaults can go here. In this
@@ -167,26 +159,18 @@ static int airo_attach(struct pcmcia_device *p_dev)
167 and attributes of IO windows) are fixed by the nature of the 159 and attributes of IO windows) are fixed by the nature of the
168 device, and can be hard-wired here. 160 device, and can be hard-wired here.
169 */ 161 */
170 link->conf.Attributes = 0; 162 p_dev->conf.Attributes = 0;
171 link->conf.Vcc = 50; 163 p_dev->conf.IntType = INT_MEMORY_AND_IO;
172 link->conf.IntType = INT_MEMORY_AND_IO;
173 164
174 /* Allocate space for private device-specific data */ 165 /* Allocate space for private device-specific data */
175 local = kzalloc(sizeof(local_info_t), GFP_KERNEL); 166 local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
176 if (!local) { 167 if (!local) {
177 printk(KERN_ERR "airo_cs: no memory for new device\n"); 168 printk(KERN_ERR "airo_cs: no memory for new device\n");
178 kfree (link);
179 return -ENOMEM; 169 return -ENOMEM;
180 } 170 }
181 link->priv = local; 171 p_dev->priv = local;
182 172
183 link->handle = p_dev; 173 return airo_config(p_dev);
184 p_dev->instance = link;
185
186 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
187 airo_config(link);
188
189 return 0;
190} /* airo_attach */ 174} /* airo_attach */
191 175
192/*====================================================================== 176/*======================================================================
@@ -198,14 +182,11 @@ static int airo_attach(struct pcmcia_device *p_dev)
198 182
199 ======================================================================*/ 183 ======================================================================*/
200 184
201static void airo_detach(struct pcmcia_device *p_dev) 185static void airo_detach(struct pcmcia_device *link)
202{ 186{
203 dev_link_t *link = dev_to_instance(p_dev);
204
205 DEBUG(0, "airo_detach(0x%p)\n", link); 187 DEBUG(0, "airo_detach(0x%p)\n", link);
206 188
207 if (link->state & DEV_CONFIG) 189 airo_release(link);
208 airo_release(link);
209 190
210 if ( ((local_info_t*)link->priv)->eth_dev ) { 191 if ( ((local_info_t*)link->priv)->eth_dev ) {
211 stop_airo_card( ((local_info_t*)link->priv)->eth_dev, 0 ); 192 stop_airo_card( ((local_info_t*)link->priv)->eth_dev, 0 );
@@ -213,7 +194,6 @@ static void airo_detach(struct pcmcia_device *p_dev)
213 ((local_info_t*)link->priv)->eth_dev = NULL; 194 ((local_info_t*)link->priv)->eth_dev = NULL;
214 195
215 kfree(link->priv); 196 kfree(link->priv);
216 kfree(link);
217} /* airo_detach */ 197} /* airo_detach */
218 198
219/*====================================================================== 199/*======================================================================
@@ -227,9 +207,8 @@ static void airo_detach(struct pcmcia_device *p_dev)
227#define CS_CHECK(fn, ret) \ 207#define CS_CHECK(fn, ret) \
228do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 208do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
229 209
230static void airo_config(dev_link_t *link) 210static int airo_config(struct pcmcia_device *link)
231{ 211{
232 client_handle_t handle;
233 tuple_t tuple; 212 tuple_t tuple;
234 cisparse_t parse; 213 cisparse_t parse;
235 local_info_t *dev; 214 local_info_t *dev;
@@ -237,8 +216,7 @@ static void airo_config(dev_link_t *link)
237 u_char buf[64]; 216 u_char buf[64];
238 win_req_t req; 217 win_req_t req;
239 memreq_t map; 218 memreq_t map;
240 219
241 handle = link->handle;
242 dev = link->priv; 220 dev = link->priv;
243 221
244 DEBUG(0, "airo_config(0x%p)\n", link); 222 DEBUG(0, "airo_config(0x%p)\n", link);
@@ -252,15 +230,12 @@ static void airo_config(dev_link_t *link)
252 tuple.TupleData = buf; 230 tuple.TupleData = buf;
253 tuple.TupleDataMax = sizeof(buf); 231 tuple.TupleDataMax = sizeof(buf);
254 tuple.TupleOffset = 0; 232 tuple.TupleOffset = 0;
255 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 233 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
256 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 234 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
257 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 235 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
258 link->conf.ConfigBase = parse.config.base; 236 link->conf.ConfigBase = parse.config.base;
259 link->conf.Present = parse.config.rmask[0]; 237 link->conf.Present = parse.config.rmask[0];
260 238
261 /* Configure card */
262 link->state |= DEV_CONFIG;
263
264 /* 239 /*
265 In this loop, we scan the CIS for configuration table entries, 240 In this loop, we scan the CIS for configuration table entries,
266 each of which describes a valid card configuration, including 241 each of which describes a valid card configuration, including
@@ -274,12 +249,12 @@ static void airo_config(dev_link_t *link)
274 will only use the CIS to fill in implementation-defined details. 249 will only use the CIS to fill in implementation-defined details.
275 */ 250 */
276 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 251 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
277 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 252 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
278 while (1) { 253 while (1) {
279 cistpl_cftable_entry_t dflt = { 0 }; 254 cistpl_cftable_entry_t dflt = { 0 };
280 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 255 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
281 if (pcmcia_get_tuple_data(handle, &tuple) != 0 || 256 if (pcmcia_get_tuple_data(link, &tuple) != 0 ||
282 pcmcia_parse_tuple(handle, &tuple, &parse) != 0) 257 pcmcia_parse_tuple(link, &tuple, &parse) != 0)
283 goto next_entry; 258 goto next_entry;
284 259
285 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; 260 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg;
@@ -294,16 +269,11 @@ static void airo_config(dev_link_t *link)
294 269
295 /* Use power settings for Vcc and Vpp if present */ 270 /* Use power settings for Vcc and Vpp if present */
296 /* Note that the CIS values need to be rescaled */ 271 /* Note that the CIS values need to be rescaled */
297 if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM))
298 link->conf.Vcc = cfg->vcc.param[CISTPL_POWER_VNOM]/10000;
299 else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM))
300 link->conf.Vcc = dflt.vcc.param[CISTPL_POWER_VNOM]/10000;
301
302 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) 272 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
303 link->conf.Vpp1 = link->conf.Vpp2 = 273 link->conf.Vpp =
304 cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; 274 cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
305 else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) 275 else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM))
306 link->conf.Vpp1 = link->conf.Vpp2 = 276 link->conf.Vpp =
307 dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; 277 dflt.vpp1.param[CISTPL_POWER_VNOM]/10000;
308 278
309 /* Do we need to allocate an interrupt? */ 279 /* Do we need to allocate an interrupt? */
@@ -329,12 +299,12 @@ static void airo_config(dev_link_t *link)
329 } 299 }
330 300
331 /* This reserves IO space but doesn't actually enable it */ 301 /* This reserves IO space but doesn't actually enable it */
332 if (pcmcia_request_io(link->handle, &link->io) != 0) 302 if (pcmcia_request_io(link, &link->io) != 0)
333 goto next_entry; 303 goto next_entry;
334 304
335 /* 305 /*
336 Now set up a common memory window, if needed. There is room 306 Now set up a common memory window, if needed. There is room
337 in the dev_link_t structure for one memory window handle, 307 in the struct pcmcia_device structure for one memory window handle,
338 but if the base addresses need to be saved, or if multiple 308 but if the base addresses need to be saved, or if multiple
339 windows are needed, the info should go in the private data 309 windows are needed, the info should go in the private data
340 structure for this device. 310 structure for this device.
@@ -350,7 +320,7 @@ static void airo_config(dev_link_t *link)
350 req.Base = mem->win[0].host_addr; 320 req.Base = mem->win[0].host_addr;
351 req.Size = mem->win[0].len; 321 req.Size = mem->win[0].len;
352 req.AccessSpeed = 0; 322 req.AccessSpeed = 0;
353 if (pcmcia_request_window(&link->handle, &req, &link->win) != 0) 323 if (pcmcia_request_window(&link, &req, &link->win) != 0)
354 goto next_entry; 324 goto next_entry;
355 map.Page = 0; map.CardOffset = mem->win[0].card_addr; 325 map.Page = 0; map.CardOffset = mem->win[0].card_addr;
356 if (pcmcia_map_mem_page(link->win, &map) != 0) 326 if (pcmcia_map_mem_page(link->win, &map) != 0)
@@ -360,7 +330,7 @@ static void airo_config(dev_link_t *link)
360 break; 330 break;
361 331
362 next_entry: 332 next_entry:
363 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); 333 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple));
364 } 334 }
365 335
366 /* 336 /*
@@ -369,33 +339,32 @@ static void airo_config(dev_link_t *link)
369 irq structure is initialized. 339 irq structure is initialized.
370 */ 340 */
371 if (link->conf.Attributes & CONF_ENABLE_IRQ) 341 if (link->conf.Attributes & CONF_ENABLE_IRQ)
372 CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 342 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
373 343
374 /* 344 /*
375 This actually configures the PCMCIA socket -- setting up 345 This actually configures the PCMCIA socket -- setting up
376 the I/O windows and the interrupt mapping, and putting the 346 the I/O windows and the interrupt mapping, and putting the
377 card and host interface into "Memory and IO" mode. 347 card and host interface into "Memory and IO" mode.
378 */ 348 */
379 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 349 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
380 ((local_info_t*)link->priv)->eth_dev = 350 ((local_info_t*)link->priv)->eth_dev =
381 init_airo_card( link->irq.AssignedIRQ, 351 init_airo_card( link->irq.AssignedIRQ,
382 link->io.BasePort1, 1, &handle_to_dev(handle) ); 352 link->io.BasePort1, 1, &handle_to_dev(link) );
383 if (!((local_info_t*)link->priv)->eth_dev) goto cs_failed; 353 if (!((local_info_t*)link->priv)->eth_dev) goto cs_failed;
384 354
385 /* 355 /*
386 At this point, the dev_node_t structure(s) need to be 356 At this point, the dev_node_t structure(s) need to be
387 initialized and arranged in a linked list at link->dev. 357 initialized and arranged in a linked list at link->dev_node.
388 */ 358 */
389 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name ); 359 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name );
390 dev->node.major = dev->node.minor = 0; 360 dev->node.major = dev->node.minor = 0;
391 link->dev = &dev->node; 361 link->dev_node = &dev->node;
392 362
393 /* Finally, report what we've done */ 363 /* Finally, report what we've done */
394 printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d", 364 printk(KERN_INFO "%s: index 0x%02x: ",
395 dev->node.dev_name, link->conf.ConfigIndex, 365 dev->node.dev_name, link->conf.ConfigIndex);
396 link->conf.Vcc/10, link->conf.Vcc%10); 366 if (link->conf.Vpp)
397 if (link->conf.Vpp1) 367 printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10);
398 printk(", Vpp %d.%d", link->conf.Vpp1/10, link->conf.Vpp1%10);
399 if (link->conf.Attributes & CONF_ENABLE_IRQ) 368 if (link->conf.Attributes & CONF_ENABLE_IRQ)
400 printk(", irq %d", link->irq.AssignedIRQ); 369 printk(", irq %d", link->irq.AssignedIRQ);
401 if (link->io.NumPorts1) 370 if (link->io.NumPorts1)
@@ -408,14 +377,12 @@ static void airo_config(dev_link_t *link)
408 printk(", mem 0x%06lx-0x%06lx", req.Base, 377 printk(", mem 0x%06lx-0x%06lx", req.Base,
409 req.Base+req.Size-1); 378 req.Base+req.Size-1);
410 printk("\n"); 379 printk("\n");
411 380 return 0;
412 link->state &= ~DEV_CONFIG_PENDING; 381
413 return;
414
415 cs_failed: 382 cs_failed:
416 cs_error(link->handle, last_fn, last_ret); 383 cs_error(link, last_fn, last_ret);
417 airo_release(link); 384 airo_release(link);
418 385 return -ENODEV;
419} /* airo_config */ 386} /* airo_config */
420 387
421/*====================================================================== 388/*======================================================================
@@ -426,51 +393,26 @@ static void airo_config(dev_link_t *link)
426 393
427 ======================================================================*/ 394 ======================================================================*/
428 395
429static void airo_release(dev_link_t *link) 396static void airo_release(struct pcmcia_device *link)
430{ 397{
431 DEBUG(0, "airo_release(0x%p)\n", link); 398 DEBUG(0, "airo_release(0x%p)\n", link);
432 399 pcmcia_disable_device(link);
433 /* Unlink the device chain */
434 link->dev = NULL;
435
436 /*
437 In a normal driver, additional code may be needed to release
438 other kernel data structures associated with this device.
439 */
440
441 /* Don't bother checking to see if these succeed or not */
442 if (link->win)
443 pcmcia_release_window(link->win);
444 pcmcia_release_configuration(link->handle);
445 if (link->io.NumPorts1)
446 pcmcia_release_io(link->handle, &link->io);
447 if (link->irq.AssignedIRQ)
448 pcmcia_release_irq(link->handle, &link->irq);
449 link->state &= ~DEV_CONFIG;
450} 400}
451 401
452static int airo_suspend(struct pcmcia_device *p_dev) 402static int airo_suspend(struct pcmcia_device *link)
453{ 403{
454 dev_link_t *link = dev_to_instance(p_dev);
455 local_info_t *local = link->priv; 404 local_info_t *local = link->priv;
456 405
457 link->state |= DEV_SUSPEND; 406 netif_device_detach(local->eth_dev);
458 if (link->state & DEV_CONFIG) {
459 netif_device_detach(local->eth_dev);
460 pcmcia_release_configuration(link->handle);
461 }
462 407
463 return 0; 408 return 0;
464} 409}
465 410
466static int airo_resume(struct pcmcia_device *p_dev) 411static int airo_resume(struct pcmcia_device *link)
467{ 412{
468 dev_link_t *link = dev_to_instance(p_dev);
469 local_info_t *local = link->priv; 413 local_info_t *local = link->priv;
470 414
471 link->state &= ~DEV_SUSPEND; 415 if (link->open) {
472 if (link->state & DEV_CONFIG) {
473 pcmcia_request_configuration(link->handle, &link->conf);
474 reset_airo_card(local->eth_dev); 416 reset_airo_card(local->eth_dev);
475 netif_device_attach(local->eth_dev); 417 netif_device_attach(local->eth_dev);
476 } 418 }
@@ -492,7 +434,7 @@ static struct pcmcia_driver airo_driver = {
492 .drv = { 434 .drv = {
493 .name = "airo_cs", 435 .name = "airo_cs",
494 }, 436 },
495 .probe = airo_attach, 437 .probe = airo_probe,
496 .remove = airo_detach, 438 .remove = airo_detach,
497 .id_table = airo_ids, 439 .id_table = airo_ids,
498 .suspend = airo_suspend, 440 .suspend = airo_suspend,
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index d6f4a5a3e55a..26bf1127524d 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -91,8 +91,8 @@ MODULE_SUPPORTED_DEVICE("Atmel at76c50x PCMCIA cards");
91 event handler. 91 event handler.
92*/ 92*/
93 93
94static void atmel_config(dev_link_t *link); 94static int atmel_config(struct pcmcia_device *link);
95static void atmel_release(dev_link_t *link); 95static void atmel_release(struct pcmcia_device *link);
96 96
97/* 97/*
98 The attach() and detach() entry points are used to create and destroy 98 The attach() and detach() entry points are used to create and destroy
@@ -112,10 +112,10 @@ static void atmel_detach(struct pcmcia_device *p_dev);
112/* 112/*
113 A linked list of "instances" of the atmelnet device. Each actual 113 A linked list of "instances" of the atmelnet device. Each actual
114 PCMCIA card corresponds to one device instance, and is described 114 PCMCIA card corresponds to one device instance, and is described
115 by one dev_link_t structure (defined in ds.h). 115 by one struct pcmcia_device structure (defined in ds.h).
116 116
117 You may not want to use a linked list for this -- for example, the 117 You may not want to use a linked list for this -- for example, the
118 memory card driver uses an array of dev_link_t pointers, where minor 118 memory card driver uses an array of struct pcmcia_device pointers, where minor
119 device numbers are used to derive the corresponding array index. 119 device numbers are used to derive the corresponding array index.
120*/ 120*/
121 121
@@ -125,7 +125,7 @@ static void atmel_detach(struct pcmcia_device *p_dev);
125 example, ethernet cards, modems). In other cases, there may be 125 example, ethernet cards, modems). In other cases, there may be
126 many actual or logical devices (SCSI adapters, memory cards with 126 many actual or logical devices (SCSI adapters, memory cards with
127 multiple partitions). The dev_node_t structures need to be kept 127 multiple partitions). The dev_node_t structures need to be kept
128 in a linked list starting at the 'dev' field of a dev_link_t 128 in a linked list starting at the 'dev' field of a struct pcmcia_device
129 structure. We allocate them in the card's private data structure, 129 structure. We allocate them in the card's private data structure,
130 because they generally shouldn't be allocated dynamically. 130 because they generally shouldn't be allocated dynamically.
131 131
@@ -152,24 +152,16 @@ typedef struct local_info_t {
152 152
153 ======================================================================*/ 153 ======================================================================*/
154 154
155static int atmel_attach(struct pcmcia_device *p_dev) 155static int atmel_probe(struct pcmcia_device *p_dev)
156{ 156{
157 dev_link_t *link;
158 local_info_t *local; 157 local_info_t *local;
159 158
160 DEBUG(0, "atmel_attach()\n"); 159 DEBUG(0, "atmel_attach()\n");
161 160
162 /* Initialize the dev_link_t structure */
163 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL);
164 if (!link) {
165 printk(KERN_ERR "atmel_cs: no memory for new device\n");
166 return -ENOMEM;
167 }
168
169 /* Interrupt setup */ 161 /* Interrupt setup */
170 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 162 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
171 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 163 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
172 link->irq.Handler = NULL; 164 p_dev->irq.Handler = NULL;
173 165
174 /* 166 /*
175 General socket configuration defaults can go here. In this 167 General socket configuration defaults can go here. In this
@@ -178,26 +170,18 @@ static int atmel_attach(struct pcmcia_device *p_dev)
178 and attributes of IO windows) are fixed by the nature of the 170 and attributes of IO windows) are fixed by the nature of the
179 device, and can be hard-wired here. 171 device, and can be hard-wired here.
180 */ 172 */
181 link->conf.Attributes = 0; 173 p_dev->conf.Attributes = 0;
182 link->conf.Vcc = 50; 174 p_dev->conf.IntType = INT_MEMORY_AND_IO;
183 link->conf.IntType = INT_MEMORY_AND_IO;
184 175
185 /* Allocate space for private device-specific data */ 176 /* Allocate space for private device-specific data */
186 local = kzalloc(sizeof(local_info_t), GFP_KERNEL); 177 local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
187 if (!local) { 178 if (!local) {
188 printk(KERN_ERR "atmel_cs: no memory for new device\n"); 179 printk(KERN_ERR "atmel_cs: no memory for new device\n");
189 kfree (link);
190 return -ENOMEM; 180 return -ENOMEM;
191 } 181 }
192 link->priv = local; 182 p_dev->priv = local;
193 183
194 link->handle = p_dev; 184 return atmel_config(p_dev);
195 p_dev->instance = link;
196
197 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
198 atmel_config(link);
199
200 return 0;
201} /* atmel_attach */ 185} /* atmel_attach */
202 186
203/*====================================================================== 187/*======================================================================
@@ -209,17 +193,13 @@ static int atmel_attach(struct pcmcia_device *p_dev)
209 193
210 ======================================================================*/ 194 ======================================================================*/
211 195
212static void atmel_detach(struct pcmcia_device *p_dev) 196static void atmel_detach(struct pcmcia_device *link)
213{ 197{
214 dev_link_t *link = dev_to_instance(p_dev);
215
216 DEBUG(0, "atmel_detach(0x%p)\n", link); 198 DEBUG(0, "atmel_detach(0x%p)\n", link);
217 199
218 if (link->state & DEV_CONFIG) 200 atmel_release(link);
219 atmel_release(link);
220 201
221 kfree(link->priv); 202 kfree(link->priv);
222 kfree(link);
223} 203}
224 204
225/*====================================================================== 205/*======================================================================
@@ -236,19 +216,17 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
236/* Call-back function to interrogate PCMCIA-specific information 216/* Call-back function to interrogate PCMCIA-specific information
237 about the current existance of the card */ 217 about the current existance of the card */
238static int card_present(void *arg) 218static int card_present(void *arg)
239{ 219{
240 dev_link_t *link = (dev_link_t *)arg; 220 struct pcmcia_device *link = (struct pcmcia_device *)arg;
241 if (link->state & DEV_SUSPEND) 221
242 return 0; 222 if (pcmcia_dev_present(link))
243 else if (link->state & DEV_PRESENT)
244 return 1; 223 return 1;
245 224
246 return 0; 225 return 0;
247} 226}
248 227
249static void atmel_config(dev_link_t *link) 228static int atmel_config(struct pcmcia_device *link)
250{ 229{
251 client_handle_t handle;
252 tuple_t tuple; 230 tuple_t tuple;
253 cisparse_t parse; 231 cisparse_t parse;
254 local_info_t *dev; 232 local_info_t *dev;
@@ -256,9 +234,8 @@ static void atmel_config(dev_link_t *link)
256 u_char buf[64]; 234 u_char buf[64];
257 struct pcmcia_device_id *did; 235 struct pcmcia_device_id *did;
258 236
259 handle = link->handle;
260 dev = link->priv; 237 dev = link->priv;
261 did = handle_to_dev(handle).driver_data; 238 did = handle_to_dev(link).driver_data;
262 239
263 DEBUG(0, "atmel_config(0x%p)\n", link); 240 DEBUG(0, "atmel_config(0x%p)\n", link);
264 241
@@ -272,15 +249,12 @@ static void atmel_config(dev_link_t *link)
272 registers. 249 registers.
273 */ 250 */
274 tuple.DesiredTuple = CISTPL_CONFIG; 251 tuple.DesiredTuple = CISTPL_CONFIG;
275 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 252 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
276 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 253 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
277 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 254 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
278 link->conf.ConfigBase = parse.config.base; 255 link->conf.ConfigBase = parse.config.base;
279 link->conf.Present = parse.config.rmask[0]; 256 link->conf.Present = parse.config.rmask[0];
280 257
281 /* Configure card */
282 link->state |= DEV_CONFIG;
283
284 /* 258 /*
285 In this loop, we scan the CIS for configuration table entries, 259 In this loop, we scan the CIS for configuration table entries,
286 each of which describes a valid card configuration, including 260 each of which describes a valid card configuration, including
@@ -294,12 +268,12 @@ static void atmel_config(dev_link_t *link)
294 will only use the CIS to fill in implementation-defined details. 268 will only use the CIS to fill in implementation-defined details.
295 */ 269 */
296 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 270 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
297 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 271 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
298 while (1) { 272 while (1) {
299 cistpl_cftable_entry_t dflt = { 0 }; 273 cistpl_cftable_entry_t dflt = { 0 };
300 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 274 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
301 if (pcmcia_get_tuple_data(handle, &tuple) != 0 || 275 if (pcmcia_get_tuple_data(link, &tuple) != 0 ||
302 pcmcia_parse_tuple(handle, &tuple, &parse) != 0) 276 pcmcia_parse_tuple(link, &tuple, &parse) != 0)
303 goto next_entry; 277 goto next_entry;
304 278
305 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; 279 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg;
@@ -314,16 +288,11 @@ static void atmel_config(dev_link_t *link)
314 288
315 /* Use power settings for Vcc and Vpp if present */ 289 /* Use power settings for Vcc and Vpp if present */
316 /* Note that the CIS values need to be rescaled */ 290 /* Note that the CIS values need to be rescaled */
317 if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM))
318 link->conf.Vcc = cfg->vcc.param[CISTPL_POWER_VNOM]/10000;
319 else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM))
320 link->conf.Vcc = dflt.vcc.param[CISTPL_POWER_VNOM]/10000;
321
322 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) 291 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
323 link->conf.Vpp1 = link->conf.Vpp2 = 292 link->conf.Vpp =
324 cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; 293 cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
325 else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) 294 else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM))
326 link->conf.Vpp1 = link->conf.Vpp2 = 295 link->conf.Vpp =
327 dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; 296 dflt.vpp1.param[CISTPL_POWER_VNOM]/10000;
328 297
329 /* Do we need to allocate an interrupt? */ 298 /* Do we need to allocate an interrupt? */
@@ -349,14 +318,14 @@ static void atmel_config(dev_link_t *link)
349 } 318 }
350 319
351 /* This reserves IO space but doesn't actually enable it */ 320 /* This reserves IO space but doesn't actually enable it */
352 if (pcmcia_request_io(link->handle, &link->io) != 0) 321 if (pcmcia_request_io(link, &link->io) != 0)
353 goto next_entry; 322 goto next_entry;
354 323
355 /* If we got this far, we're cool! */ 324 /* If we got this far, we're cool! */
356 break; 325 break;
357 326
358 next_entry: 327 next_entry:
359 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); 328 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple));
360 } 329 }
361 330
362 /* 331 /*
@@ -365,14 +334,14 @@ static void atmel_config(dev_link_t *link)
365 irq structure is initialized. 334 irq structure is initialized.
366 */ 335 */
367 if (link->conf.Attributes & CONF_ENABLE_IRQ) 336 if (link->conf.Attributes & CONF_ENABLE_IRQ)
368 CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 337 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
369 338
370 /* 339 /*
371 This actually configures the PCMCIA socket -- setting up 340 This actually configures the PCMCIA socket -- setting up
372 the I/O windows and the interrupt mapping, and putting the 341 the I/O windows and the interrupt mapping, and putting the
373 card and host interface into "Memory and IO" mode. 342 card and host interface into "Memory and IO" mode.
374 */ 343 */
375 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 344 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
376 345
377 if (link->irq.AssignedIRQ == 0) { 346 if (link->irq.AssignedIRQ == 0) {
378 printk(KERN_ALERT 347 printk(KERN_ALERT
@@ -384,7 +353,7 @@ static void atmel_config(dev_link_t *link)
384 init_atmel_card(link->irq.AssignedIRQ, 353 init_atmel_card(link->irq.AssignedIRQ,
385 link->io.BasePort1, 354 link->io.BasePort1,
386 did ? did->driver_info : ATMEL_FW_TYPE_NONE, 355 did ? did->driver_info : ATMEL_FW_TYPE_NONE,
387 &handle_to_dev(handle), 356 &handle_to_dev(link),
388 card_present, 357 card_present,
389 link); 358 link);
390 if (!((local_info_t*)link->priv)->eth_dev) 359 if (!((local_info_t*)link->priv)->eth_dev)
@@ -393,18 +362,18 @@ static void atmel_config(dev_link_t *link)
393 362
394 /* 363 /*
395 At this point, the dev_node_t structure(s) need to be 364 At this point, the dev_node_t structure(s) need to be
396 initialized and arranged in a linked list at link->dev. 365 initialized and arranged in a linked list at link->dev_node.
397 */ 366 */
398 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name ); 367 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name );
399 dev->node.major = dev->node.minor = 0; 368 dev->node.major = dev->node.minor = 0;
400 link->dev = &dev->node; 369 link->dev_node = &dev->node;
401 370
402 link->state &= ~DEV_CONFIG_PENDING; 371 return 0;
403 return; 372
404
405 cs_failed: 373 cs_failed:
406 cs_error(link->handle, last_fn, last_ret); 374 cs_error(link, last_fn, last_ret);
407 atmel_release(link); 375 atmel_release(link);
376 return -ENODEV;
408} 377}
409 378
410/*====================================================================== 379/*======================================================================
@@ -415,53 +384,34 @@ static void atmel_config(dev_link_t *link)
415 384
416 ======================================================================*/ 385 ======================================================================*/
417 386
418static void atmel_release(dev_link_t *link) 387static void atmel_release(struct pcmcia_device *link)
419{ 388{
420 struct net_device *dev = ((local_info_t*)link->priv)->eth_dev; 389 struct net_device *dev = ((local_info_t*)link->priv)->eth_dev;
421 390
422 DEBUG(0, "atmel_release(0x%p)\n", link); 391 DEBUG(0, "atmel_release(0x%p)\n", link);
423 392
424 /* Unlink the device chain */ 393 if (dev)
425 link->dev = NULL;
426
427 if (dev)
428 stop_atmel_card(dev); 394 stop_atmel_card(dev);
429 ((local_info_t*)link->priv)->eth_dev = NULL; 395 ((local_info_t*)link->priv)->eth_dev = NULL;
430 396
431 /* Don't bother checking to see if these succeed or not */ 397 pcmcia_disable_device(link);
432 pcmcia_release_configuration(link->handle);
433 if (link->io.NumPorts1)
434 pcmcia_release_io(link->handle, &link->io);
435 if (link->irq.AssignedIRQ)
436 pcmcia_release_irq(link->handle, &link->irq);
437 link->state &= ~DEV_CONFIG;
438} 398}
439 399
440static int atmel_suspend(struct pcmcia_device *dev) 400static int atmel_suspend(struct pcmcia_device *link)
441{ 401{
442 dev_link_t *link = dev_to_instance(dev);
443 local_info_t *local = link->priv; 402 local_info_t *local = link->priv;
444 403
445 link->state |= DEV_SUSPEND; 404 netif_device_detach(local->eth_dev);
446 if (link->state & DEV_CONFIG) {
447 netif_device_detach(local->eth_dev);
448 pcmcia_release_configuration(link->handle);
449 }
450 405
451 return 0; 406 return 0;
452} 407}
453 408
454static int atmel_resume(struct pcmcia_device *dev) 409static int atmel_resume(struct pcmcia_device *link)
455{ 410{
456 dev_link_t *link = dev_to_instance(dev);
457 local_info_t *local = link->priv; 411 local_info_t *local = link->priv;
458 412
459 link->state &= ~DEV_SUSPEND; 413 atmel_open(local->eth_dev);
460 if (link->state & DEV_CONFIG) { 414 netif_device_attach(local->eth_dev);
461 pcmcia_request_configuration(link->handle, &link->conf);
462 atmel_open(local->eth_dev);
463 netif_device_attach(local->eth_dev);
464 }
465 415
466 return 0; 416 return 0;
467} 417}
@@ -515,7 +465,7 @@ static struct pcmcia_driver atmel_driver = {
515 .drv = { 465 .drv = {
516 .name = "atmel_cs", 466 .name = "atmel_cs",
517 }, 467 },
518 .probe = atmel_attach, 468 .probe = atmel_probe,
519 .remove = atmel_detach, 469 .remove = atmel_detach,
520 .id_table = atmel_ids, 470 .id_table = atmel_ids,
521 .suspend = atmel_suspend, 471 .suspend = atmel_suspend,
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index d335b250923a..55bed923fbe9 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -42,7 +42,7 @@ MODULE_PARM_DESC(ignore_cis_vcc, "Ignore broken CIS VCC entry");
42/* struct local_info::hw_priv */ 42/* struct local_info::hw_priv */
43struct hostap_cs_priv { 43struct hostap_cs_priv {
44 dev_node_t node; 44 dev_node_t node;
45 dev_link_t *link; 45 struct pcmcia_device *link;
46 int sandisk_connectplus; 46 int sandisk_connectplus;
47}; 47};
48 48
@@ -204,15 +204,13 @@ static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
204 204
205static void prism2_detach(struct pcmcia_device *p_dev); 205static void prism2_detach(struct pcmcia_device *p_dev);
206static void prism2_release(u_long arg); 206static void prism2_release(u_long arg);
207static int prism2_config(dev_link_t *link); 207static int prism2_config(struct pcmcia_device *link);
208 208
209 209
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 && pcmcia_dev_present(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}
@@ -237,7 +235,7 @@ static void sandisk_set_iobase(local_info_t *local)
237 reg.Action = CS_WRITE; 235 reg.Action = CS_WRITE;
238 reg.Offset = 0x10; /* 0x3f0 IO base 1 */ 236 reg.Offset = 0x10; /* 0x3f0 IO base 1 */
239 reg.Value = hw_priv->link->io.BasePort1 & 0x00ff; 237 reg.Value = hw_priv->link->io.BasePort1 & 0x00ff;
240 res = pcmcia_access_configuration_register(hw_priv->link->handle, 238 res = pcmcia_access_configuration_register(hw_priv->link,
241 &reg); 239 &reg);
242 if (res != CS_SUCCESS) { 240 if (res != CS_SUCCESS) {
243 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -" 241 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -"
@@ -249,7 +247,7 @@ static void sandisk_set_iobase(local_info_t *local)
249 reg.Action = CS_WRITE; 247 reg.Action = CS_WRITE;
250 reg.Offset = 0x12; /* 0x3f2 IO base 2 */ 248 reg.Offset = 0x12; /* 0x3f2 IO base 2 */
251 reg.Value = (hw_priv->link->io.BasePort1 & 0xff00) >> 8; 249 reg.Value = (hw_priv->link->io.BasePort1 & 0xff00) >> 8;
252 res = pcmcia_access_configuration_register(hw_priv->link->handle, 250 res = pcmcia_access_configuration_register(hw_priv->link,
253 &reg); 251 &reg);
254 if (res != CS_SUCCESS) { 252 if (res != CS_SUCCESS) {
255 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -" 253 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -"
@@ -301,9 +299,9 @@ static int sandisk_enable_wireless(struct net_device *dev)
301 tuple.TupleData = buf; 299 tuple.TupleData = buf;
302 tuple.TupleDataMax = sizeof(buf); 300 tuple.TupleDataMax = sizeof(buf);
303 tuple.TupleOffset = 0; 301 tuple.TupleOffset = 0;
304 if (pcmcia_get_first_tuple(hw_priv->link->handle, &tuple) || 302 if (pcmcia_get_first_tuple(hw_priv->link, &tuple) ||
305 pcmcia_get_tuple_data(hw_priv->link->handle, &tuple) || 303 pcmcia_get_tuple_data(hw_priv->link, &tuple) ||
306 pcmcia_parse_tuple(hw_priv->link->handle, &tuple, parse) || 304 pcmcia_parse_tuple(hw_priv->link, &tuple, parse) ||
307 parse->manfid.manf != 0xd601 || parse->manfid.card != 0x0101) { 305 parse->manfid.manf != 0xd601 || parse->manfid.card != 0x0101) {
308 /* No SanDisk manfid found */ 306 /* No SanDisk manfid found */
309 ret = -ENODEV; 307 ret = -ENODEV;
@@ -311,9 +309,9 @@ static int sandisk_enable_wireless(struct net_device *dev)
311 } 309 }
312 310
313 tuple.DesiredTuple = CISTPL_LONGLINK_MFC; 311 tuple.DesiredTuple = CISTPL_LONGLINK_MFC;
314 if (pcmcia_get_first_tuple(hw_priv->link->handle, &tuple) || 312 if (pcmcia_get_first_tuple(hw_priv->link, &tuple) ||
315 pcmcia_get_tuple_data(hw_priv->link->handle, &tuple) || 313 pcmcia_get_tuple_data(hw_priv->link, &tuple) ||
316 pcmcia_parse_tuple(hw_priv->link->handle, &tuple, parse) || 314 pcmcia_parse_tuple(hw_priv->link, &tuple, parse) ||
317 parse->longlink_mfc.nfn < 2) { 315 parse->longlink_mfc.nfn < 2) {
318 /* No multi-function links found */ 316 /* No multi-function links found */
319 ret = -ENODEV; 317 ret = -ENODEV;
@@ -328,7 +326,7 @@ static int sandisk_enable_wireless(struct net_device *dev)
328 reg.Action = CS_WRITE; 326 reg.Action = CS_WRITE;
329 reg.Offset = CISREG_COR; 327 reg.Offset = CISREG_COR;
330 reg.Value = COR_SOFT_RESET; 328 reg.Value = COR_SOFT_RESET;
331 res = pcmcia_access_configuration_register(hw_priv->link->handle, 329 res = pcmcia_access_configuration_register(hw_priv->link,
332 &reg); 330 &reg);
333 if (res != CS_SUCCESS) { 331 if (res != CS_SUCCESS) {
334 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", 332 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
@@ -345,7 +343,7 @@ static int sandisk_enable_wireless(struct net_device *dev)
345 * will be enabled during the first cor_sreset call. 343 * will be enabled during the first cor_sreset call.
346 */ 344 */
347 reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA; 345 reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA;
348 res = pcmcia_access_configuration_register(hw_priv->link->handle, 346 res = pcmcia_access_configuration_register(hw_priv->link,
349 &reg); 347 &reg);
350 if (res != CS_SUCCESS) { 348 if (res != CS_SUCCESS) {
351 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", 349 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
@@ -380,7 +378,7 @@ static void prism2_pccard_cor_sreset(local_info_t *local)
380 reg.Action = CS_READ; 378 reg.Action = CS_READ;
381 reg.Offset = CISREG_COR; 379 reg.Offset = CISREG_COR;
382 reg.Value = 0; 380 reg.Value = 0;
383 res = pcmcia_access_configuration_register(hw_priv->link->handle, 381 res = pcmcia_access_configuration_register(hw_priv->link,
384 &reg); 382 &reg);
385 if (res != CS_SUCCESS) { 383 if (res != CS_SUCCESS) {
386 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n", 384 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n",
@@ -392,7 +390,7 @@ static void prism2_pccard_cor_sreset(local_info_t *local)
392 390
393 reg.Action = CS_WRITE; 391 reg.Action = CS_WRITE;
394 reg.Value |= COR_SOFT_RESET; 392 reg.Value |= COR_SOFT_RESET;
395 res = pcmcia_access_configuration_register(hw_priv->link->handle, 393 res = pcmcia_access_configuration_register(hw_priv->link,
396 &reg); 394 &reg);
397 if (res != CS_SUCCESS) { 395 if (res != CS_SUCCESS) {
398 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n", 396 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n",
@@ -405,7 +403,7 @@ static void prism2_pccard_cor_sreset(local_info_t *local)
405 reg.Value &= ~COR_SOFT_RESET; 403 reg.Value &= ~COR_SOFT_RESET;
406 if (hw_priv->sandisk_connectplus) 404 if (hw_priv->sandisk_connectplus)
407 reg.Value |= COR_IREQ_ENA; 405 reg.Value |= COR_IREQ_ENA;
408 res = pcmcia_access_configuration_register(hw_priv->link->handle, 406 res = pcmcia_access_configuration_register(hw_priv->link,
409 &reg); 407 &reg);
410 if (res != CS_SUCCESS) { 408 if (res != CS_SUCCESS) {
411 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n", 409 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n",
@@ -439,7 +437,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
439 reg.Action = CS_READ; 437 reg.Action = CS_READ;
440 reg.Offset = CISREG_COR; 438 reg.Offset = CISREG_COR;
441 reg.Value = 0; 439 reg.Value = 0;
442 res = pcmcia_access_configuration_register(hw_priv->link->handle, 440 res = pcmcia_access_configuration_register(hw_priv->link,
443 &reg); 441 &reg);
444 if (res != CS_SUCCESS) { 442 if (res != CS_SUCCESS) {
445 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 " 443 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 "
@@ -452,7 +450,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
452 450
453 reg.Action = CS_WRITE; 451 reg.Action = CS_WRITE;
454 reg.Value |= COR_SOFT_RESET; 452 reg.Value |= COR_SOFT_RESET;
455 res = pcmcia_access_configuration_register(hw_priv->link->handle, 453 res = pcmcia_access_configuration_register(hw_priv->link,
456 &reg); 454 &reg);
457 if (res != CS_SUCCESS) { 455 if (res != CS_SUCCESS) {
458 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 " 456 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 "
@@ -466,7 +464,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
466 reg.Action = CS_WRITE; 464 reg.Action = CS_WRITE;
467 reg.Value = hcr; 465 reg.Value = hcr;
468 reg.Offset = CISREG_CCSR; 466 reg.Offset = CISREG_CCSR;
469 res = pcmcia_access_configuration_register(hw_priv->link->handle, 467 res = pcmcia_access_configuration_register(hw_priv->link,
470 &reg); 468 &reg);
471 if (res != CS_SUCCESS) { 469 if (res != CS_SUCCESS) {
472 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 " 470 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 "
@@ -478,7 +476,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
478 reg.Action = CS_WRITE; 476 reg.Action = CS_WRITE;
479 reg.Offset = CISREG_COR; 477 reg.Offset = CISREG_COR;
480 reg.Value = old_cor & ~COR_SOFT_RESET; 478 reg.Value = old_cor & ~COR_SOFT_RESET;
481 res = pcmcia_access_configuration_register(hw_priv->link->handle, 479 res = pcmcia_access_configuration_register(hw_priv->link,
482 &reg); 480 &reg);
483 if (res != CS_SUCCESS) { 481 if (res != CS_SUCCESS) {
484 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 " 482 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 "
@@ -501,40 +499,27 @@ static struct prism2_helper_functions prism2_pccard_funcs =
501 499
502/* allocate local data and register with CardServices 500/* allocate local data and register with CardServices
503 * initialize dev_link structure, but do not configure the card yet */ 501 * initialize dev_link structure, but do not configure the card yet */
504static int prism2_attach(struct pcmcia_device *p_dev) 502static int hostap_cs_probe(struct pcmcia_device *p_dev)
505{ 503{
506 dev_link_t *link; 504 int ret;
507
508 link = kmalloc(sizeof(dev_link_t), GFP_KERNEL);
509 if (link == NULL)
510 return -ENOMEM;
511
512 memset(link, 0, sizeof(dev_link_t));
513 505
514 PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info); 506 PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info);
515 link->conf.Vcc = 33; 507 p_dev->conf.IntType = INT_MEMORY_AND_IO;
516 link->conf.IntType = INT_MEMORY_AND_IO;
517
518 link->handle = p_dev;
519 p_dev->instance = link;
520 508
521 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 509 ret = prism2_config(p_dev);
522 if (prism2_config(link)) 510 if (ret) {
523 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n"); 511 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");
512 }
524 513
525 return 0; 514 return ret;
526} 515}
527 516
528 517
529static void prism2_detach(struct pcmcia_device *p_dev) 518static void prism2_detach(struct pcmcia_device *link)
530{ 519{
531 dev_link_t *link = dev_to_instance(p_dev);
532
533 PDEBUG(DEBUG_FLOW, "prism2_detach\n"); 520 PDEBUG(DEBUG_FLOW, "prism2_detach\n");
534 521
535 if (link->state & DEV_CONFIG) { 522 prism2_release((u_long)link);
536 prism2_release((u_long)link);
537 }
538 523
539 /* release net devices */ 524 /* release net devices */
540 if (link->priv) { 525 if (link->priv) {
@@ -547,7 +532,6 @@ static void prism2_detach(struct pcmcia_device *p_dev)
547 prism2_free_local_data(dev); 532 prism2_free_local_data(dev);
548 kfree(hw_priv); 533 kfree(hw_priv);
549 } 534 }
550 kfree(link);
551} 535}
552 536
553 537
@@ -558,7 +542,7 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
558do { int ret = (retf); \ 542do { int ret = (retf); \
559if (ret != 0) { \ 543if (ret != 0) { \
560 PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", ret); \ 544 PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", ret); \
561 cs_error(link->handle, fn, ret); \ 545 cs_error(link, fn, ret); \
562 goto next_entry; \ 546 goto next_entry; \
563} \ 547} \
564} while (0) 548} while (0)
@@ -566,7 +550,7 @@ if (ret != 0) { \
566 550
567/* run after a CARD_INSERTION event is received to configure the PCMCIA 551/* run after a CARD_INSERTION event is received to configure the PCMCIA
568 * socket and make the device available to the system */ 552 * socket and make the device available to the system */
569static int prism2_config(dev_link_t *link) 553static int prism2_config(struct pcmcia_device *link)
570{ 554{
571 struct net_device *dev; 555 struct net_device *dev;
572 struct hostap_interface *iface; 556 struct hostap_interface *iface;
@@ -595,27 +579,24 @@ static int prism2_config(dev_link_t *link)
595 tuple.TupleData = buf; 579 tuple.TupleData = buf;
596 tuple.TupleDataMax = sizeof(buf); 580 tuple.TupleDataMax = sizeof(buf);
597 tuple.TupleOffset = 0; 581 tuple.TupleOffset = 0;
598 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple)); 582 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
599 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link->handle, &tuple)); 583 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
600 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link->handle, &tuple, parse)); 584 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, parse));
601 link->conf.ConfigBase = parse->config.base; 585 link->conf.ConfigBase = parse->config.base;
602 link->conf.Present = parse->config.rmask[0]; 586 link->conf.Present = parse->config.rmask[0];
603 587
604 CS_CHECK(GetConfigurationInfo, 588 CS_CHECK(GetConfigurationInfo,
605 pcmcia_get_configuration_info(link->handle, &conf)); 589 pcmcia_get_configuration_info(link, &conf));
606 PDEBUG(DEBUG_HW, "%s: %s Vcc=%d (from config)\n", dev_info,
607 ignore_cis_vcc ? "ignoring" : "setting", conf.Vcc);
608 link->conf.Vcc = conf.Vcc;
609 590
610 /* Look for an appropriate configuration table entry in the CIS */ 591 /* Look for an appropriate configuration table entry in the CIS */
611 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 592 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
612 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple)); 593 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
613 for (;;) { 594 for (;;) {
614 cistpl_cftable_entry_t *cfg = &(parse->cftable_entry); 595 cistpl_cftable_entry_t *cfg = &(parse->cftable_entry);
615 CFG_CHECK2(GetTupleData, 596 CFG_CHECK2(GetTupleData,
616 pcmcia_get_tuple_data(link->handle, &tuple)); 597 pcmcia_get_tuple_data(link, &tuple));
617 CFG_CHECK2(ParseTuple, 598 CFG_CHECK2(ParseTuple,
618 pcmcia_parse_tuple(link->handle, &tuple, parse)); 599 pcmcia_parse_tuple(link, &tuple, parse));
619 600
620 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) 601 if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
621 dflt = *cfg; 602 dflt = *cfg;
@@ -650,10 +631,10 @@ static int prism2_config(dev_link_t *link)
650 } 631 }
651 632
652 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 633 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
653 link->conf.Vpp1 = link->conf.Vpp2 = 634 link->conf.Vpp =
654 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 635 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
655 else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) 636 else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))
656 link->conf.Vpp1 = link->conf.Vpp2 = 637 link->conf.Vpp =
657 dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; 638 dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;
658 639
659 /* Do we need to allocate an interrupt? */ 640 /* Do we need to allocate an interrupt? */
@@ -695,19 +676,19 @@ static int prism2_config(dev_link_t *link)
695 676
696 /* This reserves IO space but doesn't actually enable it */ 677 /* This reserves IO space but doesn't actually enable it */
697 CFG_CHECK2(RequestIO, 678 CFG_CHECK2(RequestIO,
698 pcmcia_request_io(link->handle, &link->io)); 679 pcmcia_request_io(link, &link->io));
699 680
700 /* This configuration table entry is OK */ 681 /* This configuration table entry is OK */
701 break; 682 break;
702 683
703 next_entry: 684 next_entry:
704 CS_CHECK(GetNextTuple, 685 CS_CHECK(GetNextTuple,
705 pcmcia_get_next_tuple(link->handle, &tuple)); 686 pcmcia_get_next_tuple(link, &tuple));
706 } 687 }
707 688
708 /* Need to allocate net_device before requesting IRQ handler */ 689 /* Need to allocate net_device before requesting IRQ handler */
709 dev = prism2_init_local_data(&prism2_pccard_funcs, 0, 690 dev = prism2_init_local_data(&prism2_pccard_funcs, 0,
710 &handle_to_dev(link->handle)); 691 &handle_to_dev(link));
711 if (dev == NULL) 692 if (dev == NULL)
712 goto failed; 693 goto failed;
713 link->priv = dev; 694 link->priv = dev;
@@ -717,7 +698,7 @@ static int prism2_config(dev_link_t *link)
717 local->hw_priv = hw_priv; 698 local->hw_priv = hw_priv;
718 hw_priv->link = link; 699 hw_priv->link = link;
719 strcpy(hw_priv->node.dev_name, dev->name); 700 strcpy(hw_priv->node.dev_name, dev->name);
720 link->dev = &hw_priv->node; 701 link->dev_node = &hw_priv->node;
721 702
722 /* 703 /*
723 * Allocate an interrupt line. Note that this does not assign a 704 * Allocate an interrupt line. Note that this does not assign a
@@ -730,7 +711,7 @@ static int prism2_config(dev_link_t *link)
730 link->irq.Handler = prism2_interrupt; 711 link->irq.Handler = prism2_interrupt;
731 link->irq.Instance = dev; 712 link->irq.Instance = dev;
732 CS_CHECK(RequestIRQ, 713 CS_CHECK(RequestIRQ,
733 pcmcia_request_irq(link->handle, &link->irq)); 714 pcmcia_request_irq(link, &link->irq));
734 } 715 }
735 716
736 /* 717 /*
@@ -739,18 +720,17 @@ static int prism2_config(dev_link_t *link)
739 * card and host interface into "Memory and IO" mode. 720 * card and host interface into "Memory and IO" mode.
740 */ 721 */
741 CS_CHECK(RequestConfiguration, 722 CS_CHECK(RequestConfiguration,
742 pcmcia_request_configuration(link->handle, &link->conf)); 723 pcmcia_request_configuration(link, &link->conf));
743 724
744 dev->irq = link->irq.AssignedIRQ; 725 dev->irq = link->irq.AssignedIRQ;
745 dev->base_addr = link->io.BasePort1; 726 dev->base_addr = link->io.BasePort1;
746 727
747 /* Finally, report what we've done */ 728 /* Finally, report what we've done */
748 printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d", 729 printk(KERN_INFO "%s: index 0x%02x: ",
749 dev_info, link->conf.ConfigIndex, 730 dev_info, link->conf.ConfigIndex);
750 link->conf.Vcc / 10, link->conf.Vcc % 10); 731 if (link->conf.Vpp)
751 if (link->conf.Vpp1) 732 printk(", Vpp %d.%d", link->conf.Vpp / 10,
752 printk(", Vpp %d.%d", link->conf.Vpp1 / 10, 733 link->conf.Vpp % 10);
753 link->conf.Vpp1 % 10);
754 if (link->conf.Attributes & CONF_ENABLE_IRQ) 734 if (link->conf.Attributes & CONF_ENABLE_IRQ)
755 printk(", irq %d", link->irq.AssignedIRQ); 735 printk(", irq %d", link->irq.AssignedIRQ);
756 if (link->io.NumPorts1) 736 if (link->io.NumPorts1)
@@ -761,9 +741,6 @@ static int prism2_config(dev_link_t *link)
761 link->io.BasePort2+link->io.NumPorts2-1); 741 link->io.BasePort2+link->io.NumPorts2-1);
762 printk("\n"); 742 printk("\n");
763 743
764 link->state |= DEV_CONFIG;
765 link->state &= ~DEV_CONFIG_PENDING;
766
767 local->shutdown = 0; 744 local->shutdown = 0;
768 745
769 sandisk_enable_wireless(dev); 746 sandisk_enable_wireless(dev);
@@ -778,7 +755,7 @@ static int prism2_config(dev_link_t *link)
778 return ret; 755 return ret;
779 756
780 cs_failed: 757 cs_failed:
781 cs_error(link->handle, last_fn, last_ret); 758 cs_error(link, last_fn, last_ret);
782 759
783 failed: 760 failed:
784 kfree(parse); 761 kfree(parse);
@@ -790,7 +767,7 @@ static int prism2_config(dev_link_t *link)
790 767
791static void prism2_release(u_long arg) 768static void prism2_release(u_long arg)
792{ 769{
793 dev_link_t *link = (dev_link_t *)arg; 770 struct pcmcia_device *link = (struct pcmcia_device *)arg;
794 771
795 PDEBUG(DEBUG_FLOW, "prism2_release\n"); 772 PDEBUG(DEBUG_FLOW, "prism2_release\n");
796 773
@@ -799,71 +776,54 @@ static void prism2_release(u_long arg)
799 struct hostap_interface *iface; 776 struct hostap_interface *iface;
800 777
801 iface = netdev_priv(dev); 778 iface = netdev_priv(dev);
802 if (link->state & DEV_CONFIG) 779 prism2_hw_shutdown(dev, 0);
803 prism2_hw_shutdown(dev, 0);
804 iface->local->shutdown = 1; 780 iface->local->shutdown = 1;
805 } 781 }
806 782
807 if (link->win) 783 pcmcia_disable_device(link);
808 pcmcia_release_window(link->win);
809 pcmcia_release_configuration(link->handle);
810 if (link->io.NumPorts1)
811 pcmcia_release_io(link->handle, &link->io);
812 if (link->irq.AssignedIRQ)
813 pcmcia_release_irq(link->handle, &link->irq);
814
815 link->state &= ~DEV_CONFIG;
816
817 PDEBUG(DEBUG_FLOW, "release - done\n"); 784 PDEBUG(DEBUG_FLOW, "release - done\n");
818} 785}
819 786
820static int hostap_cs_suspend(struct pcmcia_device *p_dev) 787static int hostap_cs_suspend(struct pcmcia_device *link)
821{ 788{
822 dev_link_t *link = dev_to_instance(p_dev);
823 struct net_device *dev = (struct net_device *) link->priv; 789 struct net_device *dev = (struct net_device *) link->priv;
824 int dev_open = 0; 790 int dev_open = 0;
791 struct hostap_interface *iface = NULL;
825 792
826 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info); 793 if (dev)
827 794 iface = netdev_priv(dev);
828 link->state |= DEV_SUSPEND;
829 795
830 if (link->state & DEV_CONFIG) { 796 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info);
831 struct hostap_interface *iface = netdev_priv(dev); 797 if (iface && iface->local)
832 if (iface && iface->local) 798 dev_open = iface->local->num_dev_open > 0;
833 dev_open = iface->local->num_dev_open > 0; 799 if (dev_open) {
834 if (dev_open) { 800 netif_stop_queue(dev);
835 netif_stop_queue(dev); 801 netif_device_detach(dev);
836 netif_device_detach(dev);
837 }
838 prism2_suspend(dev);
839 pcmcia_release_configuration(link->handle);
840 } 802 }
803 prism2_suspend(dev);
841 804
842 return 0; 805 return 0;
843} 806}
844 807
845static int hostap_cs_resume(struct pcmcia_device *p_dev) 808static int hostap_cs_resume(struct pcmcia_device *link)
846{ 809{
847 dev_link_t *link = dev_to_instance(p_dev);
848 struct net_device *dev = (struct net_device *) link->priv; 810 struct net_device *dev = (struct net_device *) link->priv;
849 int dev_open = 0; 811 int dev_open = 0;
812 struct hostap_interface *iface = NULL;
850 813
851 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info); 814 if (dev)
815 iface = netdev_priv(dev);
852 816
853 link->state &= ~DEV_SUSPEND; 817 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info);
854 if (link->state & DEV_CONFIG) {
855 struct hostap_interface *iface = netdev_priv(dev);
856 if (iface && iface->local)
857 dev_open = iface->local->num_dev_open > 0;
858 818
859 pcmcia_request_configuration(link->handle, &link->conf); 819 if (iface && iface->local)
820 dev_open = iface->local->num_dev_open > 0;
860 821
861 prism2_hw_shutdown(dev, 1); 822 prism2_hw_shutdown(dev, 1);
862 prism2_hw_config(dev, dev_open ? 0 : 1); 823 prism2_hw_config(dev, dev_open ? 0 : 1);
863 if (dev_open) { 824 if (dev_open) {
864 netif_device_attach(dev); 825 netif_device_attach(dev);
865 netif_start_queue(dev); 826 netif_start_queue(dev);
866 }
867 } 827 }
868 828
869 return 0; 829 return 0;
@@ -930,7 +890,7 @@ static struct pcmcia_driver hostap_driver = {
930 .drv = { 890 .drv = {
931 .name = "hostap_cs", 891 .name = "hostap_cs",
932 }, 892 },
933 .probe = prism2_attach, 893 .probe = hostap_cs_probe,
934 .remove = prism2_detach, 894 .remove = prism2_detach,
935 .owner = THIS_MODULE, 895 .owner = THIS_MODULE,
936 .id_table = hostap_cs_ids, 896 .id_table = hostap_cs_ids,
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index 75ce6ddb0cf5..9343d970537b 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -190,8 +190,8 @@ module_param(mem_speed, int, 0);
190/*====================================================================*/ 190/*====================================================================*/
191 191
192/* PCMCIA (Card Services) related functions */ 192/* PCMCIA (Card Services) related functions */
193static void netwave_release(dev_link_t *link); /* Card removal */ 193static void netwave_release(struct pcmcia_device *link); /* Card removal */
194static void netwave_pcmcia_config(dev_link_t *arg); /* Runs after card 194static int netwave_pcmcia_config(struct pcmcia_device *arg); /* Runs after card
195 insertion */ 195 insertion */
196static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */ 196static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */
197 197
@@ -221,10 +221,10 @@ static struct iw_statistics* netwave_get_wireless_stats(struct net_device *dev);
221static void set_multicast_list(struct net_device *dev); 221static void set_multicast_list(struct net_device *dev);
222 222
223/* 223/*
224 A dev_link_t structure has fields for most things that are needed 224 A struct pcmcia_device structure has fields for most things that are needed
225 to keep track of a socket, but there will usually be some device 225 to keep track of a socket, but there will usually be some device
226 specific information that also needs to be kept track of. The 226 specific information that also needs to be kept track of. The
227 'priv' pointer in a dev_link_t structure can be used to point to 227 'priv' pointer in a struct pcmcia_device structure can be used to point to
228 a device-specific private data structure, like this. 228 a device-specific private data structure, like this.
229 229
230 A driver needs to provide a dev_node_t structure for each device 230 A driver needs to provide a dev_node_t structure for each device
@@ -232,7 +232,7 @@ static void set_multicast_list(struct net_device *dev);
232 example, ethernet cards, modems). In other cases, there may be 232 example, ethernet cards, modems). In other cases, there may be
233 many actual or logical devices (SCSI adapters, memory cards with 233 many actual or logical devices (SCSI adapters, memory cards with
234 multiple partitions). The dev_node_t structures need to be kept 234 multiple partitions). The dev_node_t structures need to be kept
235 in a linked list starting at the 'dev' field of a dev_link_t 235 in a linked list starting at the 'dev' field of a struct pcmcia_device
236 structure. We allocate them in the card's private data structure, 236 structure. We allocate them in the card's private data structure,
237 because they generally can't be allocated dynamically. 237 because they generally can't be allocated dynamically.
238*/ 238*/
@@ -268,7 +268,7 @@ struct site_survey {
268}; 268};
269 269
270typedef struct netwave_private { 270typedef struct netwave_private {
271 dev_link_t link; 271 struct pcmcia_device *p_dev;
272 spinlock_t spinlock; /* Serialize access to the hardware (SMP) */ 272 spinlock_t spinlock; /* Serialize access to the hardware (SMP) */
273 dev_node_t node; 273 dev_node_t node;
274 u_char __iomem *ramBase; 274 u_char __iomem *ramBase;
@@ -376,20 +376,19 @@ static struct iw_statistics *netwave_get_wireless_stats(struct net_device *dev)
376 * configure the card at this point -- we wait until we receive a 376 * configure the card at this point -- we wait until we receive a
377 * card insertion event. 377 * card insertion event.
378 */ 378 */
379static int netwave_attach(struct pcmcia_device *p_dev) 379static int netwave_probe(struct pcmcia_device *link)
380{ 380{
381 dev_link_t *link;
382 struct net_device *dev; 381 struct net_device *dev;
383 netwave_private *priv; 382 netwave_private *priv;
384 383
385 DEBUG(0, "netwave_attach()\n"); 384 DEBUG(0, "netwave_attach()\n");
386 385
387 /* Initialize the dev_link_t structure */ 386 /* Initialize the struct pcmcia_device structure */
388 dev = alloc_etherdev(sizeof(netwave_private)); 387 dev = alloc_etherdev(sizeof(netwave_private));
389 if (!dev) 388 if (!dev)
390 return -ENOMEM; 389 return -ENOMEM;
391 priv = netdev_priv(dev); 390 priv = netdev_priv(dev);
392 link = &priv->link; 391 priv->p_dev = link;
393 link->priv = dev; 392 link->priv = dev;
394 393
395 /* The io structure describes IO port mapping */ 394 /* The io structure describes IO port mapping */
@@ -406,7 +405,6 @@ static int netwave_attach(struct pcmcia_device *p_dev)
406 405
407 /* General socket configuration */ 406 /* General socket configuration */
408 link->conf.Attributes = CONF_ENABLE_IRQ; 407 link->conf.Attributes = CONF_ENABLE_IRQ;
409 link->conf.Vcc = 50;
410 link->conf.IntType = INT_MEMORY_AND_IO; 408 link->conf.IntType = INT_MEMORY_AND_IO;
411 link->conf.ConfigIndex = 1; 409 link->conf.ConfigIndex = 1;
412 link->conf.Present = PRESENT_OPTION; 410 link->conf.Present = PRESENT_OPTION;
@@ -430,13 +428,7 @@ static int netwave_attach(struct pcmcia_device *p_dev)
430 dev->stop = &netwave_close; 428 dev->stop = &netwave_close;
431 link->irq.Instance = dev; 429 link->irq.Instance = dev;
432 430
433 link->handle = p_dev; 431 return netwave_pcmcia_config( link);
434 p_dev->instance = link;
435
436 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
437 netwave_pcmcia_config( link);
438
439 return 0;
440} /* netwave_attach */ 432} /* netwave_attach */
441 433
442/* 434/*
@@ -447,17 +439,15 @@ static int netwave_attach(struct pcmcia_device *p_dev)
447 * structures are freed. Otherwise, the structures will be freed 439 * structures are freed. Otherwise, the structures will be freed
448 * when the device is released. 440 * when the device is released.
449 */ 441 */
450static void netwave_detach(struct pcmcia_device *p_dev) 442static void netwave_detach(struct pcmcia_device *link)
451{ 443{
452 dev_link_t *link = dev_to_instance(p_dev);
453 struct net_device *dev = link->priv; 444 struct net_device *dev = link->priv;
454 445
455 DEBUG(0, "netwave_detach(0x%p)\n", link); 446 DEBUG(0, "netwave_detach(0x%p)\n", link);
456 447
457 if (link->state & DEV_CONFIG) 448 netwave_release(link);
458 netwave_release(link);
459 449
460 if (link->dev) 450 if (link->dev_node)
461 unregister_netdev(dev); 451 unregister_netdev(dev);
462 452
463 free_netdev(dev); 453 free_netdev(dev);
@@ -743,8 +733,7 @@ static const struct iw_handler_def netwave_handler_def =
743#define CS_CHECK(fn, ret) \ 733#define CS_CHECK(fn, ret) \
744do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 734do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
745 735
746static void netwave_pcmcia_config(dev_link_t *link) { 736static int netwave_pcmcia_config(struct pcmcia_device *link) {
747 client_handle_t handle = link->handle;
748 struct net_device *dev = link->priv; 737 struct net_device *dev = link->priv;
749 netwave_private *priv = netdev_priv(dev); 738 netwave_private *priv = netdev_priv(dev);
750 tuple_t tuple; 739 tuple_t tuple;
@@ -766,15 +755,12 @@ static void netwave_pcmcia_config(dev_link_t *link) {
766 tuple.TupleDataMax = 64; 755 tuple.TupleDataMax = 64;
767 tuple.TupleOffset = 0; 756 tuple.TupleOffset = 0;
768 tuple.DesiredTuple = CISTPL_CONFIG; 757 tuple.DesiredTuple = CISTPL_CONFIG;
769 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 758 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
770 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 759 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
771 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 760 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
772 link->conf.ConfigBase = parse.config.base; 761 link->conf.ConfigBase = parse.config.base;
773 link->conf.Present = parse.config.rmask[0]; 762 link->conf.Present = parse.config.rmask[0];
774 763
775 /* Configure card */
776 link->state |= DEV_CONFIG;
777
778 /* 764 /*
779 * Try allocating IO ports. This tries a few fixed addresses. 765 * Try allocating IO ports. This tries a few fixed addresses.
780 * 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
@@ -782,11 +768,11 @@ static void netwave_pcmcia_config(dev_link_t *link) {
782 */ 768 */
783 for (i = j = 0x0; j < 0x400; j += 0x20) { 769 for (i = j = 0x0; j < 0x400; j += 0x20) {
784 link->io.BasePort1 = j ^ 0x300; 770 link->io.BasePort1 = j ^ 0x300;
785 i = pcmcia_request_io(link->handle, &link->io); 771 i = pcmcia_request_io(link, &link->io);
786 if (i == CS_SUCCESS) break; 772 if (i == CS_SUCCESS) break;
787 } 773 }
788 if (i != CS_SUCCESS) { 774 if (i != CS_SUCCESS) {
789 cs_error(link->handle, RequestIO, i); 775 cs_error(link, RequestIO, i);
790 goto failed; 776 goto failed;
791 } 777 }
792 778
@@ -794,16 +780,16 @@ static void netwave_pcmcia_config(dev_link_t *link) {
794 * Now allocate an interrupt line. Note that this does not 780 * Now allocate an interrupt line. Note that this does not
795 * actually assign a handler to the interrupt. 781 * actually assign a handler to the interrupt.
796 */ 782 */
797 CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); 783 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
798 784
799 /* 785 /*
800 * This actually configures the PCMCIA socket -- setting up 786 * This actually configures the PCMCIA socket -- setting up
801 * the I/O windows and the interrupt mapping. 787 * the I/O windows and the interrupt mapping.
802 */ 788 */
803 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); 789 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
804 790
805 /* 791 /*
806 * Allocate a 32K memory window. Note that the dev_link_t 792 * Allocate a 32K memory window. Note that the struct pcmcia_device
807 * structure provides space for one window handle -- if your 793 * structure provides space for one window handle -- if your
808 * device needs several windows, you'll need to keep track of 794 * device needs several windows, you'll need to keep track of
809 * the handles in your private data structure, dev->priv. 795 * the handles in your private data structure, dev->priv.
@@ -813,7 +799,7 @@ static void netwave_pcmcia_config(dev_link_t *link) {
813 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_CM|WIN_ENABLE; 799 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_CM|WIN_ENABLE;
814 req.Base = 0; req.Size = 0x8000; 800 req.Base = 0; req.Size = 0x8000;
815 req.AccessSpeed = mem_speed; 801 req.AccessSpeed = mem_speed;
816 CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &link->win)); 802 CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win));
817 mem.CardOffset = 0x20000; mem.Page = 0; 803 mem.CardOffset = 0x20000; mem.Page = 0;
818 CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem)); 804 CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem));
819 805
@@ -823,7 +809,7 @@ static void netwave_pcmcia_config(dev_link_t *link) {
823 809
824 dev->irq = link->irq.AssignedIRQ; 810 dev->irq = link->irq.AssignedIRQ;
825 dev->base_addr = link->io.BasePort1; 811 dev->base_addr = link->io.BasePort1;
826 SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 812 SET_NETDEV_DEV(dev, &handle_to_dev(link));
827 813
828 if (register_netdev(dev) != 0) { 814 if (register_netdev(dev) != 0) {
829 printk(KERN_DEBUG "netwave_cs: register_netdev() failed\n"); 815 printk(KERN_DEBUG "netwave_cs: register_netdev() failed\n");
@@ -831,8 +817,7 @@ static void netwave_pcmcia_config(dev_link_t *link) {
831 } 817 }
832 818
833 strcpy(priv->node.dev_name, dev->name); 819 strcpy(priv->node.dev_name, dev->name);
834 link->dev = &priv->node; 820 link->dev_node = &priv->node;
835 link->state &= ~DEV_CONFIG_PENDING;
836 821
837 /* Reset card before reading physical address */ 822 /* Reset card before reading physical address */
838 netwave_doreset(dev->base_addr, ramBase); 823 netwave_doreset(dev->base_addr, ramBase);
@@ -852,12 +837,13 @@ static void netwave_pcmcia_config(dev_link_t *link) {
852 printk(KERN_DEBUG "Netwave_reset: revision %04x %04x\n", 837 printk(KERN_DEBUG "Netwave_reset: revision %04x %04x\n",
853 get_uint16(ramBase + NETWAVE_EREG_ARW), 838 get_uint16(ramBase + NETWAVE_EREG_ARW),
854 get_uint16(ramBase + NETWAVE_EREG_ARW+2)); 839 get_uint16(ramBase + NETWAVE_EREG_ARW+2));
855 return; 840 return 0;
856 841
857cs_failed: 842cs_failed:
858 cs_error(link->handle, last_fn, last_ret); 843 cs_error(link, last_fn, last_ret);
859failed: 844failed:
860 netwave_release(link); 845 netwave_release(link);
846 return -ENODEV;
861} /* netwave_pcmcia_config */ 847} /* netwave_pcmcia_config */
862 848
863/* 849/*
@@ -867,52 +853,35 @@ failed:
867 * device, and release the PCMCIA configuration. If the device is 853 * device, and release the PCMCIA configuration. If the device is
868 * still open, this will be postponed until it is closed. 854 * still open, this will be postponed until it is closed.
869 */ 855 */
870static void netwave_release(dev_link_t *link) 856static void netwave_release(struct pcmcia_device *link)
871{ 857{
872 struct net_device *dev = link->priv; 858 struct net_device *dev = link->priv;
873 netwave_private *priv = netdev_priv(dev); 859 netwave_private *priv = netdev_priv(dev);
874
875 DEBUG(0, "netwave_release(0x%p)\n", link);
876 860
877 /* Don't bother checking to see if these succeed or not */ 861 DEBUG(0, "netwave_release(0x%p)\n", link);
878 if (link->win) {
879 iounmap(priv->ramBase);
880 pcmcia_release_window(link->win);
881 }
882 pcmcia_release_configuration(link->handle);
883 pcmcia_release_io(link->handle, &link->io);
884 pcmcia_release_irq(link->handle, &link->irq);
885 862
886 link->state &= ~DEV_CONFIG; 863 pcmcia_disable_device(link);
864 if (link->win)
865 iounmap(priv->ramBase);
887} 866}
888 867
889static int netwave_suspend(struct pcmcia_device *p_dev) 868static int netwave_suspend(struct pcmcia_device *link)
890{ 869{
891 dev_link_t *link = dev_to_instance(p_dev);
892 struct net_device *dev = link->priv; 870 struct net_device *dev = link->priv;
893 871
894 link->state |= DEV_SUSPEND; 872 if (link->open)
895 if (link->state & DEV_CONFIG) { 873 netif_device_detach(dev);
896 if (link->open)
897 netif_device_detach(dev);
898 pcmcia_release_configuration(link->handle);
899 }
900 874
901 return 0; 875 return 0;
902} 876}
903 877
904static int netwave_resume(struct pcmcia_device *p_dev) 878static int netwave_resume(struct pcmcia_device *link)
905{ 879{
906 dev_link_t *link = dev_to_instance(p_dev);
907 struct net_device *dev = link->priv; 880 struct net_device *dev = link->priv;
908 881
909 link->state &= ~DEV_SUSPEND; 882 if (link->open) {
910 if (link->state & DEV_CONFIG) { 883 netwave_reset(dev);
911 pcmcia_request_configuration(link->handle, &link->conf); 884 netif_device_attach(dev);
912 if (link->open) {
913 netwave_reset(dev);
914 netif_device_attach(dev);
915 }
916 } 885 }
917 886
918 return 0; 887 return 0;
@@ -1119,7 +1088,7 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id, struct pt_regs *regs
1119 u_char __iomem *ramBase; 1088 u_char __iomem *ramBase;
1120 struct net_device *dev = (struct net_device *)dev_id; 1089 struct net_device *dev = (struct net_device *)dev_id;
1121 struct netwave_private *priv = netdev_priv(dev); 1090 struct netwave_private *priv = netdev_priv(dev);
1122 dev_link_t *link = &priv->link; 1091 struct pcmcia_device *link = priv->p_dev;
1123 int i; 1092 int i;
1124 1093
1125 if (!netif_device_present(dev)) 1094 if (!netif_device_present(dev))
@@ -1138,7 +1107,7 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id, struct pt_regs *regs
1138 1107
1139 status = inb(iobase + NETWAVE_REG_ASR); 1108 status = inb(iobase + NETWAVE_REG_ASR);
1140 1109
1141 if (!DEV_OK(link)) { 1110 if (!pcmcia_dev_present(link)) {
1142 DEBUG(1, "netwave_interrupt: Interrupt with status 0x%x " 1111 DEBUG(1, "netwave_interrupt: Interrupt with status 0x%x "
1143 "from removed or suspended card!\n", status); 1112 "from removed or suspended card!\n", status);
1144 break; 1113 break;
@@ -1373,11 +1342,11 @@ static int netwave_rx(struct net_device *dev)
1373 1342
1374static int netwave_open(struct net_device *dev) { 1343static int netwave_open(struct net_device *dev) {
1375 netwave_private *priv = netdev_priv(dev); 1344 netwave_private *priv = netdev_priv(dev);
1376 dev_link_t *link = &priv->link; 1345 struct pcmcia_device *link = priv->p_dev;
1377 1346
1378 DEBUG(1, "netwave_open: starting.\n"); 1347 DEBUG(1, "netwave_open: starting.\n");
1379 1348
1380 if (!DEV_OK(link)) 1349 if (!pcmcia_dev_present(link))
1381 return -ENODEV; 1350 return -ENODEV;
1382 1351
1383 link->open++; 1352 link->open++;
@@ -1390,7 +1359,7 @@ static int netwave_open(struct net_device *dev) {
1390 1359
1391static int netwave_close(struct net_device *dev) { 1360static int netwave_close(struct net_device *dev) {
1392 netwave_private *priv = netdev_priv(dev); 1361 netwave_private *priv = netdev_priv(dev);
1393 dev_link_t *link = &priv->link; 1362 struct pcmcia_device *link = priv->p_dev;
1394 1363
1395 DEBUG(1, "netwave_close: finishing.\n"); 1364 DEBUG(1, "netwave_close: finishing.\n");
1396 1365
@@ -1411,7 +1380,7 @@ static struct pcmcia_driver netwave_driver = {
1411 .drv = { 1380 .drv = {
1412 .name = "netwave_cs", 1381 .name = "netwave_cs",
1413 }, 1382 },
1414 .probe = netwave_attach, 1383 .probe = netwave_probe,
1415 .remove = netwave_detach, 1384 .remove = netwave_detach,
1416 .id_table = netwave_ids, 1385 .id_table = netwave_ids,
1417 .suspend = netwave_suspend, 1386 .suspend = netwave_suspend,
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index ec6f2a48895b..434f7d7ad841 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -49,7 +49,7 @@ MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket
49/* PCMCIA specific device information (goes in the card field of 49/* PCMCIA specific device information (goes in the card field of
50 * struct orinoco_private */ 50 * struct orinoco_private */
51struct orinoco_pccard { 51struct orinoco_pccard {
52 dev_link_t link; 52 struct pcmcia_device *p_dev;
53 dev_node_t node; 53 dev_node_t node;
54 54
55 /* Used to handle hard reset */ 55 /* Used to handle hard reset */
@@ -63,8 +63,8 @@ struct orinoco_pccard {
63/* Function prototypes */ 63/* Function prototypes */
64/********************************************************************/ 64/********************************************************************/
65 65
66static void orinoco_cs_config(dev_link_t *link); 66static int orinoco_cs_config(struct pcmcia_device *link);
67static void orinoco_cs_release(dev_link_t *link); 67static void orinoco_cs_release(struct pcmcia_device *link);
68static void orinoco_cs_detach(struct pcmcia_device *p_dev); 68static void orinoco_cs_detach(struct pcmcia_device *p_dev);
69 69
70/********************************************************************/ 70/********************************************************************/
@@ -75,13 +75,13 @@ static int
75orinoco_cs_hard_reset(struct orinoco_private *priv) 75orinoco_cs_hard_reset(struct orinoco_private *priv)
76{ 76{
77 struct orinoco_pccard *card = priv->card; 77 struct orinoco_pccard *card = priv->card;
78 dev_link_t *link = &card->link; 78 struct pcmcia_device *link = card->p_dev;
79 int err; 79 int err;
80 80
81 /* We need atomic ops here, because we're not holding the lock */ 81 /* We need atomic ops here, because we're not holding the lock */
82 set_bit(0, &card->hard_reset_in_progress); 82 set_bit(0, &card->hard_reset_in_progress);
83 83
84 err = pcmcia_reset_card(link->handle, NULL); 84 err = pcmcia_reset_card(link, NULL);
85 if (err) 85 if (err)
86 return err; 86 return err;
87 87
@@ -104,12 +104,11 @@ orinoco_cs_hard_reset(struct orinoco_private *priv)
104 * configure the card at this point -- we wait until we receive a card 104 * configure the card at this point -- we wait until we receive a card
105 * insertion event. */ 105 * insertion event. */
106static int 106static int
107orinoco_cs_attach(struct pcmcia_device *p_dev) 107orinoco_cs_probe(struct pcmcia_device *link)
108{ 108{
109 struct net_device *dev; 109 struct net_device *dev;
110 struct orinoco_private *priv; 110 struct orinoco_private *priv;
111 struct orinoco_pccard *card; 111 struct orinoco_pccard *card;
112 dev_link_t *link;
113 112
114 dev = alloc_orinocodev(sizeof(*card), orinoco_cs_hard_reset); 113 dev = alloc_orinocodev(sizeof(*card), orinoco_cs_hard_reset);
115 if (! dev) 114 if (! dev)
@@ -118,7 +117,7 @@ orinoco_cs_attach(struct pcmcia_device *p_dev)
118 card = priv->card; 117 card = priv->card;
119 118
120 /* Link both structures together */ 119 /* Link both structures together */
121 link = &card->link; 120 card->p_dev = link;
122 link->priv = dev; 121 link->priv = dev;
123 122
124 /* Interrupt setup */ 123 /* Interrupt setup */
@@ -135,16 +134,7 @@ orinoco_cs_attach(struct pcmcia_device *p_dev)
135 link->conf.Attributes = 0; 134 link->conf.Attributes = 0;
136 link->conf.IntType = INT_MEMORY_AND_IO; 135 link->conf.IntType = INT_MEMORY_AND_IO;
137 136
138 /* Register with Card Services */ 137 return orinoco_cs_config(link);
139 link->next = NULL;
140
141 link->handle = p_dev;
142 p_dev->instance = link;
143
144 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
145 orinoco_cs_config(link);
146
147 return 0;
148} /* orinoco_cs_attach */ 138} /* orinoco_cs_attach */
149 139
150/* 140/*
@@ -153,16 +143,14 @@ orinoco_cs_attach(struct pcmcia_device *p_dev)
153 * are freed. Otherwise, the structures will be freed when the device 143 * are freed. Otherwise, the structures will be freed when the device
154 * is released. 144 * is released.
155 */ 145 */
156static void orinoco_cs_detach(struct pcmcia_device *p_dev) 146static void orinoco_cs_detach(struct pcmcia_device *link)
157{ 147{
158 dev_link_t *link = dev_to_instance(p_dev);
159 struct net_device *dev = link->priv; 148 struct net_device *dev = link->priv;
160 149
161 if (link->state & DEV_CONFIG) 150 orinoco_cs_release(link);
162 orinoco_cs_release(link);
163 151
164 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); 152 DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node);
165 if (link->dev) { 153 if (link->dev_node) {
166 DEBUG(0, PFX "About to unregister net device %p\n", 154 DEBUG(0, PFX "About to unregister net device %p\n",
167 dev); 155 dev);
168 unregister_netdev(dev); 156 unregister_netdev(dev);
@@ -180,11 +168,10 @@ static void orinoco_cs_detach(struct pcmcia_device *p_dev)
180 last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; \ 168 last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; \
181 } while (0) 169 } while (0)
182 170
183static void 171static int
184orinoco_cs_config(dev_link_t *link) 172orinoco_cs_config(struct pcmcia_device *link)
185{ 173{
186 struct net_device *dev = link->priv; 174 struct net_device *dev = link->priv;
187 client_handle_t handle = link->handle;
188 struct orinoco_private *priv = netdev_priv(dev); 175 struct orinoco_private *priv = netdev_priv(dev);
189 struct orinoco_pccard *card = priv->card; 176 struct orinoco_pccard *card = priv->card;
190 hermes_t *hw = &priv->hw; 177 hermes_t *hw = &priv->hw;
@@ -196,7 +183,7 @@ orinoco_cs_config(dev_link_t *link)
196 cisparse_t parse; 183 cisparse_t parse;
197 void __iomem *mem; 184 void __iomem *mem;
198 185
199 CS_CHECK(ValidateCIS, pcmcia_validate_cis(handle, &info)); 186 CS_CHECK(ValidateCIS, pcmcia_validate_cis(link, &info));
200 187
201 /* 188 /*
202 * This reads the card's CONFIG tuple to find its 189 * This reads the card's CONFIG tuple to find its
@@ -207,19 +194,15 @@ orinoco_cs_config(dev_link_t *link)
207 tuple.TupleData = buf; 194 tuple.TupleData = buf;
208 tuple.TupleDataMax = sizeof(buf); 195 tuple.TupleDataMax = sizeof(buf);
209 tuple.TupleOffset = 0; 196 tuple.TupleOffset = 0;
210 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 197 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
211 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 198 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
212 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 199 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
213 link->conf.ConfigBase = parse.config.base; 200 link->conf.ConfigBase = parse.config.base;
214 link->conf.Present = parse.config.rmask[0]; 201 link->conf.Present = parse.config.rmask[0];
215 202
216 /* Configure card */
217 link->state |= DEV_CONFIG;
218
219 /* Look up the current Vcc */ 203 /* Look up the current Vcc */
220 CS_CHECK(GetConfigurationInfo, 204 CS_CHECK(GetConfigurationInfo,
221 pcmcia_get_configuration_info(handle, &conf)); 205 pcmcia_get_configuration_info(link, &conf));
222 link->conf.Vcc = conf.Vcc;
223 206
224 /* 207 /*
225 * In this loop, we scan the CIS for configuration table 208 * In this loop, we scan the CIS for configuration table
@@ -236,13 +219,13 @@ orinoco_cs_config(dev_link_t *link)
236 * implementation-defined details. 219 * implementation-defined details.
237 */ 220 */
238 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 221 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
239 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 222 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
240 while (1) { 223 while (1) {
241 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 224 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
242 cistpl_cftable_entry_t dflt = { .index = 0 }; 225 cistpl_cftable_entry_t dflt = { .index = 0 };
243 226
244 if ( (pcmcia_get_tuple_data(handle, &tuple) != 0) 227 if ( (pcmcia_get_tuple_data(link, &tuple) != 0)
245 || (pcmcia_parse_tuple(handle, &tuple, &parse) != 0)) 228 || (pcmcia_parse_tuple(link, &tuple, &parse) != 0))
246 goto next_entry; 229 goto next_entry;
247 230
248 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) 231 if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
@@ -274,10 +257,10 @@ orinoco_cs_config(dev_link_t *link)
274 } 257 }
275 258
276 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 259 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
277 link->conf.Vpp1 = link->conf.Vpp2 = 260 link->conf.Vpp =
278 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 261 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
279 else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) 262 else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))
280 link->conf.Vpp1 = link->conf.Vpp2 = 263 link->conf.Vpp =
281 dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; 264 dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;
282 265
283 /* Do we need to allocate an interrupt? */ 266 /* Do we need to allocate an interrupt? */
@@ -307,7 +290,7 @@ orinoco_cs_config(dev_link_t *link)
307 } 290 }
308 291
309 /* This reserves IO space but doesn't actually enable it */ 292 /* This reserves IO space but doesn't actually enable it */
310 if (pcmcia_request_io(link->handle, &link->io) != 0) 293 if (pcmcia_request_io(link, &link->io) != 0)
311 goto next_entry; 294 goto next_entry;
312 } 295 }
313 296
@@ -317,9 +300,8 @@ orinoco_cs_config(dev_link_t *link)
317 break; 300 break;
318 301
319 next_entry: 302 next_entry:
320 if (link->io.NumPorts1) 303 pcmcia_disable_device(link);
321 pcmcia_release_io(link->handle, &link->io); 304 last_ret = pcmcia_get_next_tuple(link, &tuple);
322 last_ret = pcmcia_get_next_tuple(handle, &tuple);
323 if (last_ret == CS_NO_MORE_ITEMS) { 305 if (last_ret == CS_NO_MORE_ITEMS) {
324 printk(KERN_ERR PFX "GetNextTuple(): No matching " 306 printk(KERN_ERR PFX "GetNextTuple(): No matching "
325 "CIS configuration. Maybe you need the " 307 "CIS configuration. Maybe you need the "
@@ -333,7 +315,7 @@ orinoco_cs_config(dev_link_t *link)
333 * a handler to the interrupt, unless the 'Handler' member of 315 * a handler to the interrupt, unless the 'Handler' member of
334 * the irq structure is initialized. 316 * the irq structure is initialized.
335 */ 317 */
336 CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 318 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
337 319
338 /* We initialize the hermes structure before completing PCMCIA 320 /* We initialize the hermes structure before completing PCMCIA
339 * configuration just in case the interrupt handler gets 321 * configuration just in case the interrupt handler gets
@@ -350,7 +332,7 @@ orinoco_cs_config(dev_link_t *link)
350 * card and host interface into "Memory and IO" mode. 332 * card and host interface into "Memory and IO" mode.
351 */ 333 */
352 CS_CHECK(RequestConfiguration, 334 CS_CHECK(RequestConfiguration,
353 pcmcia_request_configuration(link->handle, &link->conf)); 335 pcmcia_request_configuration(link, &link->conf));
354 336
355 /* Ok, we have the configuration, prepare to register the netdev */ 337 /* Ok, we have the configuration, prepare to register the netdev */
356 dev->base_addr = link->io.BasePort1; 338 dev->base_addr = link->io.BasePort1;
@@ -358,7 +340,7 @@ orinoco_cs_config(dev_link_t *link)
358 SET_MODULE_OWNER(dev); 340 SET_MODULE_OWNER(dev);
359 card->node.major = card->node.minor = 0; 341 card->node.major = card->node.minor = 0;
360 342
361 SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 343 SET_NETDEV_DEV(dev, &handle_to_dev(link));
362 /* Tell the stack we exist */ 344 /* Tell the stack we exist */
363 if (register_netdev(dev) != 0) { 345 if (register_netdev(dev) != 0) {
364 printk(KERN_ERR PFX "register_netdev() failed\n"); 346 printk(KERN_ERR PFX "register_netdev() failed\n");
@@ -366,20 +348,18 @@ orinoco_cs_config(dev_link_t *link)
366 } 348 }
367 349
368 /* At this point, the dev_node_t structure(s) needs to be 350 /* At this point, the dev_node_t structure(s) needs to be
369 * initialized and arranged in a linked list at link->dev. */ 351 * initialized and arranged in a linked list at link->dev_node. */
370 strcpy(card->node.dev_name, dev->name); 352 strcpy(card->node.dev_name, dev->name);
371 link->dev = &card->node; /* link->dev being non-NULL is also 353 link->dev_node = &card->node; /* link->dev_node being non-NULL is also
372 used to indicate that the 354 used to indicate that the
373 net_device has been registered */ 355 net_device has been registered */
374 link->state &= ~DEV_CONFIG_PENDING;
375 356
376 /* Finally, report what we've done */ 357 /* Finally, report what we've done */
377 printk(KERN_DEBUG "%s: index 0x%02x: Vcc %d.%d", 358 printk(KERN_DEBUG "%s: index 0x%02x: ",
378 dev->name, link->conf.ConfigIndex, 359 dev->name, link->conf.ConfigIndex);
379 link->conf.Vcc / 10, link->conf.Vcc % 10); 360 if (link->conf.Vpp)
380 if (link->conf.Vpp1) 361 printk(", Vpp %d.%d", link->conf.Vpp / 10,
381 printk(", Vpp %d.%d", link->conf.Vpp1 / 10, 362 link->conf.Vpp % 10);
382 link->conf.Vpp1 % 10);
383 printk(", irq %d", link->irq.AssignedIRQ); 363 printk(", irq %d", link->irq.AssignedIRQ);
384 if (link->io.NumPorts1) 364 if (link->io.NumPorts1)
385 printk(", io 0x%04x-0x%04x", link->io.BasePort1, 365 printk(", io 0x%04x-0x%04x", link->io.BasePort1,
@@ -389,13 +369,14 @@ orinoco_cs_config(dev_link_t *link)
389 link->io.BasePort2 + link->io.NumPorts2 - 1); 369 link->io.BasePort2 + link->io.NumPorts2 - 1);
390 printk("\n"); 370 printk("\n");
391 371
392 return; 372 return 0;
393 373
394 cs_failed: 374 cs_failed:
395 cs_error(link->handle, last_fn, last_ret); 375 cs_error(link, last_fn, last_ret);
396 376
397 failed: 377 failed:
398 orinoco_cs_release(link); 378 orinoco_cs_release(link);
379 return -ENODEV;
399} /* orinoco_cs_config */ 380} /* orinoco_cs_config */
400 381
401/* 382/*
@@ -404,7 +385,7 @@ orinoco_cs_config(dev_link_t *link)
404 * still open, this will be postponed until it is closed. 385 * still open, this will be postponed until it is closed.
405 */ 386 */
406static void 387static void
407orinoco_cs_release(dev_link_t *link) 388orinoco_cs_release(struct pcmcia_device *link)
408{ 389{
409 struct net_device *dev = link->priv; 390 struct net_device *dev = link->priv;
410 struct orinoco_private *priv = netdev_priv(dev); 391 struct orinoco_private *priv = netdev_priv(dev);
@@ -416,88 +397,68 @@ orinoco_cs_release(dev_link_t *link)
416 priv->hw_unavailable++; 397 priv->hw_unavailable++;
417 spin_unlock_irqrestore(&priv->lock, flags); 398 spin_unlock_irqrestore(&priv->lock, flags);
418 399
419 /* Don't bother checking to see if these succeed or not */ 400 pcmcia_disable_device(link);
420 pcmcia_release_configuration(link->handle);
421 if (link->io.NumPorts1)
422 pcmcia_release_io(link->handle, &link->io);
423 if (link->irq.AssignedIRQ)
424 pcmcia_release_irq(link->handle, &link->irq);
425 link->state &= ~DEV_CONFIG;
426 if (priv->hw.iobase) 401 if (priv->hw.iobase)
427 ioport_unmap(priv->hw.iobase); 402 ioport_unmap(priv->hw.iobase);
428} /* orinoco_cs_release */ 403} /* orinoco_cs_release */
429 404
430static int orinoco_cs_suspend(struct pcmcia_device *p_dev) 405static int orinoco_cs_suspend(struct pcmcia_device *link)
431{ 406{
432 dev_link_t *link = dev_to_instance(p_dev);
433 struct net_device *dev = link->priv; 407 struct net_device *dev = link->priv;
434 struct orinoco_private *priv = netdev_priv(dev); 408 struct orinoco_private *priv = netdev_priv(dev);
435 struct orinoco_pccard *card = priv->card; 409 struct orinoco_pccard *card = priv->card;
436 int err = 0; 410 int err = 0;
437 unsigned long flags; 411 unsigned long flags;
438 412
439 link->state |= DEV_SUSPEND; 413 /* This is probably racy, but I can't think of
440 if (link->state & DEV_CONFIG) { 414 a better way, short of rewriting the PCMCIA
441 /* This is probably racy, but I can't think of 415 layer to not suck :-( */
442 a better way, short of rewriting the PCMCIA 416 if (! test_bit(0, &card->hard_reset_in_progress)) {
443 layer to not suck :-( */ 417 spin_lock_irqsave(&priv->lock, flags);
444 if (! test_bit(0, &card->hard_reset_in_progress)) {
445 spin_lock_irqsave(&priv->lock, flags);
446 418
447 err = __orinoco_down(dev); 419 err = __orinoco_down(dev);
448 if (err) 420 if (err)
449 printk(KERN_WARNING "%s: Error %d downing interface\n", 421 printk(KERN_WARNING "%s: Error %d downing interface\n",
450 dev->name, err); 422 dev->name, err);
451 423
452 netif_device_detach(dev); 424 netif_device_detach(dev);
453 priv->hw_unavailable++; 425 priv->hw_unavailable++;
454 426
455 spin_unlock_irqrestore(&priv->lock, flags); 427 spin_unlock_irqrestore(&priv->lock, flags);
456 }
457
458 pcmcia_release_configuration(link->handle);
459 } 428 }
460 429
461 return 0; 430 return 0;
462} 431}
463 432
464static int orinoco_cs_resume(struct pcmcia_device *p_dev) 433static int orinoco_cs_resume(struct pcmcia_device *link)
465{ 434{
466 dev_link_t *link = dev_to_instance(p_dev);
467 struct net_device *dev = link->priv; 435 struct net_device *dev = link->priv;
468 struct orinoco_private *priv = netdev_priv(dev); 436 struct orinoco_private *priv = netdev_priv(dev);
469 struct orinoco_pccard *card = priv->card; 437 struct orinoco_pccard *card = priv->card;
470 int err = 0; 438 int err = 0;
471 unsigned long flags; 439 unsigned long flags;
472 440
473 link->state &= ~DEV_SUSPEND; 441 if (! test_bit(0, &card->hard_reset_in_progress)) {
474 if (link->state & DEV_CONFIG) { 442 err = orinoco_reinit_firmware(dev);
475 /* FIXME: should we double check that this is 443 if (err) {
476 * the same card as we had before */ 444 printk(KERN_ERR "%s: Error %d re-initializing firmware\n",
477 pcmcia_request_configuration(link->handle, &link->conf); 445 dev->name, err);
478 446 return -EIO;
479 if (! test_bit(0, &card->hard_reset_in_progress)) { 447 }
480 err = orinoco_reinit_firmware(dev);
481 if (err) {
482 printk(KERN_ERR "%s: Error %d re-initializing firmware\n",
483 dev->name, err);
484 return -EIO;
485 }
486
487 spin_lock_irqsave(&priv->lock, flags);
488 448
489 netif_device_attach(dev); 449 spin_lock_irqsave(&priv->lock, flags);
490 priv->hw_unavailable--;
491 450
492 if (priv->open && ! priv->hw_unavailable) { 451 netif_device_attach(dev);
493 err = __orinoco_up(dev); 452 priv->hw_unavailable--;
494 if (err)
495 printk(KERN_ERR "%s: Error %d restarting card\n",
496 dev->name, err);
497 }
498 453
499 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);
500 } 459 }
460
461 spin_unlock_irqrestore(&priv->lock, flags);
501 } 462 }
502 463
503 return 0; 464 return 0;
@@ -604,7 +565,7 @@ static struct pcmcia_driver orinoco_driver = {
604 .drv = { 565 .drv = {
605 .name = DRIVER_NAME, 566 .name = DRIVER_NAME,
606 }, 567 },
607 .probe = orinoco_cs_attach, 568 .probe = orinoco_cs_probe,
608 .remove = orinoco_cs_detach, 569 .remove = orinoco_cs_detach,
609 .id_table = orinoco_cs_ids, 570 .id_table = orinoco_cs_ids,
610 .suspend = orinoco_cs_suspend, 571 .suspend = orinoco_cs_suspend,
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 7880d8c31aad..879eb427607c 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -90,8 +90,8 @@ module_param(pc_debug, int, 0);
90#define DEBUG(n, args...) 90#define DEBUG(n, args...)
91#endif 91#endif
92/** Prototypes based on PCMCIA skeleton driver *******************************/ 92/** Prototypes based on PCMCIA skeleton driver *******************************/
93static void ray_config(dev_link_t *link); 93static int ray_config(struct pcmcia_device *link);
94static void ray_release(dev_link_t *link); 94static void ray_release(struct pcmcia_device *link);
95static void ray_detach(struct pcmcia_device *p_dev); 95static void ray_detach(struct pcmcia_device *p_dev);
96 96
97/***** Prototypes indicated by device structure ******************************/ 97/***** Prototypes indicated by device structure ******************************/
@@ -190,20 +190,17 @@ static int bc;
190static char *phy_addr = NULL; 190static char *phy_addr = NULL;
191 191
192 192
193/* A linked list of "instances" of the ray device. Each actual 193/* A struct pcmcia_device structure has fields for most things that are needed
194 PCMCIA card corresponds to one device instance, and is described
195 by one dev_link_t structure (defined in ds.h).
196*/
197static dev_link_t *dev_list = NULL;
198
199/* A dev_link_t structure has fields for most things that are needed
200 to keep track of a socket, but there will usually be some device 194 to keep track of a socket, but there will usually be some device
201 specific information that also needs to be kept track of. The 195 specific information that also needs to be kept track of. The
202 'priv' pointer in a dev_link_t structure can be used to point to 196 'priv' pointer in a struct pcmcia_device structure can be used to point to
203 a device-specific private data structure, like this. 197 a device-specific private data structure, like this.
204*/ 198*/
205static unsigned int ray_mem_speed = 500; 199static unsigned int ray_mem_speed = 500;
206 200
201/* WARNING: THIS DRIVER IS NOT CAPABLE OF HANDLING MULTIPLE DEVICES! */
202static struct pcmcia_device *this_device = NULL;
203
207MODULE_AUTHOR("Corey Thomas <corey@world.std.com>"); 204MODULE_AUTHOR("Corey Thomas <corey@world.std.com>");
208MODULE_DESCRIPTION("Raylink/WebGear wireless LAN driver"); 205MODULE_DESCRIPTION("Raylink/WebGear wireless LAN driver");
209MODULE_LICENSE("GPL"); 206MODULE_LICENSE("GPL");
@@ -306,56 +303,46 @@ static char rcsid[] = "Raylink/WebGear wireless LAN - Corey <Thomas corey@world.
306 configure the card at this point -- we wait until we receive a 303 configure the card at this point -- we wait until we receive a
307 card insertion event. 304 card insertion event.
308=============================================================================*/ 305=============================================================================*/
309static int ray_attach(struct pcmcia_device *p_dev) 306static int ray_probe(struct pcmcia_device *p_dev)
310{ 307{
311 dev_link_t *link;
312 ray_dev_t *local; 308 ray_dev_t *local;
313 struct net_device *dev; 309 struct net_device *dev;
314
315 DEBUG(1, "ray_attach()\n");
316 310
317 /* Initialize the dev_link_t structure */ 311 DEBUG(1, "ray_attach()\n");
318 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
319
320 if (!link)
321 return -ENOMEM;
322 312
323 /* Allocate space for private device-specific data */ 313 /* Allocate space for private device-specific data */
324 dev = alloc_etherdev(sizeof(ray_dev_t)); 314 dev = alloc_etherdev(sizeof(ray_dev_t));
325
326 if (!dev) 315 if (!dev)
327 goto fail_alloc_dev; 316 goto fail_alloc_dev;
328 317
329 local = dev->priv; 318 local = dev->priv;
330 319 local->finder = p_dev;
331 memset(link, 0, sizeof(struct dev_link_t));
332 320
333 /* The io structure describes IO port mapping. None used here */ 321 /* The io structure describes IO port mapping. None used here */
334 link->io.NumPorts1 = 0; 322 p_dev->io.NumPorts1 = 0;
335 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 323 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
336 link->io.IOAddrLines = 5; 324 p_dev->io.IOAddrLines = 5;
337 325
338 /* Interrupt setup. For PCMCIA, driver takes what's given */ 326 /* Interrupt setup. For PCMCIA, driver takes what's given */
339 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 327 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
340 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 328 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
341 link->irq.Handler = &ray_interrupt; 329 p_dev->irq.Handler = &ray_interrupt;
342 330
343 /* General socket configuration */ 331 /* General socket configuration */
344 link->conf.Attributes = CONF_ENABLE_IRQ; 332 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
345 link->conf.Vcc = 50; 333 p_dev->conf.IntType = INT_MEMORY_AND_IO;
346 link->conf.IntType = INT_MEMORY_AND_IO; 334 p_dev->conf.ConfigIndex = 1;
347 link->conf.ConfigIndex = 1; 335 p_dev->conf.Present = PRESENT_OPTION;
348 link->conf.Present = PRESENT_OPTION; 336
349 337 p_dev->priv = dev;
350 link->priv = dev; 338 p_dev->irq.Instance = dev;
351 link->irq.Instance = dev;
352 339
353 local->finder = link; 340 local->finder = p_dev;
354 local->card_status = CARD_INSERTED; 341 local->card_status = CARD_INSERTED;
355 local->authentication_state = UNAUTHENTICATED; 342 local->authentication_state = UNAUTHENTICATED;
356 local->num_multi = 0; 343 local->num_multi = 0;
357 DEBUG(2,"ray_attach link = %p, dev = %p, local = %p, intr = %p\n", 344 DEBUG(2,"ray_attach p_dev = %p, dev = %p, local = %p, intr = %p\n",
358 link,dev,local,&ray_interrupt); 345 p_dev,dev,local,&ray_interrupt);
359 346
360 /* Raylink entries in the device structure */ 347 /* Raylink entries in the device structure */
361 dev->hard_start_xmit = &ray_dev_start_xmit; 348 dev->hard_start_xmit = &ray_dev_start_xmit;
@@ -379,16 +366,10 @@ static int ray_attach(struct pcmcia_device *p_dev)
379 366
380 init_timer(&local->timer); 367 init_timer(&local->timer);
381 368
382 link->handle = p_dev; 369 this_device = p_dev;
383 p_dev->instance = link; 370 return ray_config(p_dev);
384
385 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
386 ray_config(link);
387
388 return 0;
389 371
390fail_alloc_dev: 372fail_alloc_dev:
391 kfree(link);
392 return -ENOMEM; 373 return -ENOMEM;
393} /* ray_attach */ 374} /* ray_attach */
394/*============================================================================= 375/*=============================================================================
@@ -397,37 +378,25 @@ fail_alloc_dev:
397 structures are freed. Otherwise, the structures will be freed 378 structures are freed. Otherwise, the structures will be freed
398 when the device is released. 379 when the device is released.
399=============================================================================*/ 380=============================================================================*/
400static void ray_detach(struct pcmcia_device *p_dev) 381static void ray_detach(struct pcmcia_device *link)
401{ 382{
402 dev_link_t *link = dev_to_instance(p_dev);
403 dev_link_t **linkp;
404 struct net_device *dev; 383 struct net_device *dev;
405 ray_dev_t *local; 384 ray_dev_t *local;
406 385
407 DEBUG(1, "ray_detach(0x%p)\n", link); 386 DEBUG(1, "ray_detach(0x%p)\n", link);
408
409 /* Locate device structure */
410 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
411 if (*linkp == link) break;
412 if (*linkp == NULL)
413 return;
414 387
388 this_device = NULL;
415 dev = link->priv; 389 dev = link->priv;
416 390
417 if (link->state & DEV_CONFIG) { 391 ray_release(link);
418 ray_release(link);
419 392
420 local = (ray_dev_t *)dev->priv; 393 local = (ray_dev_t *)dev->priv;
421 del_timer(&local->timer); 394 del_timer(&local->timer);
422 }
423 395
424 /* Unlink device structure, free pieces */
425 *linkp = link->next;
426 if (link->priv) { 396 if (link->priv) {
427 if (link->dev) unregister_netdev(dev); 397 if (link->dev_node) unregister_netdev(dev);
428 free_netdev(dev); 398 free_netdev(dev);
429 } 399 }
430 kfree(link);
431 DEBUG(2,"ray_cs ray_detach ending\n"); 400 DEBUG(2,"ray_cs ray_detach ending\n");
432} /* ray_detach */ 401} /* ray_detach */
433/*============================================================================= 402/*=============================================================================
@@ -438,9 +407,8 @@ static void ray_detach(struct pcmcia_device *p_dev)
438#define CS_CHECK(fn, ret) \ 407#define CS_CHECK(fn, ret) \
439do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 408do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
440#define MAX_TUPLE_SIZE 128 409#define MAX_TUPLE_SIZE 128
441static void ray_config(dev_link_t *link) 410static int ray_config(struct pcmcia_device *link)
442{ 411{
443 client_handle_t handle = link->handle;
444 tuple_t tuple; 412 tuple_t tuple;
445 cisparse_t parse; 413 cisparse_t parse;
446 int last_fn = 0, last_ret = 0; 414 int last_fn = 0, last_ret = 0;
@@ -455,48 +423,45 @@ static void ray_config(dev_link_t *link)
455 423
456 /* This reads the card's CONFIG tuple to find its configuration regs */ 424 /* This reads the card's CONFIG tuple to find its configuration regs */
457 tuple.DesiredTuple = CISTPL_CONFIG; 425 tuple.DesiredTuple = CISTPL_CONFIG;
458 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 426 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
459 tuple.TupleData = buf; 427 tuple.TupleData = buf;
460 tuple.TupleDataMax = MAX_TUPLE_SIZE; 428 tuple.TupleDataMax = MAX_TUPLE_SIZE;
461 tuple.TupleOffset = 0; 429 tuple.TupleOffset = 0;
462 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 430 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
463 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 431 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
464 link->conf.ConfigBase = parse.config.base; 432 link->conf.ConfigBase = parse.config.base;
465 link->conf.Present = parse.config.rmask[0]; 433 link->conf.Present = parse.config.rmask[0];
466 434
467 /* Determine card type and firmware version */ 435 /* Determine card type and firmware version */
468 buf[0] = buf[MAX_TUPLE_SIZE - 1] = 0; 436 buf[0] = buf[MAX_TUPLE_SIZE - 1] = 0;
469 tuple.DesiredTuple = CISTPL_VERS_1; 437 tuple.DesiredTuple = CISTPL_VERS_1;
470 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 438 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
471 tuple.TupleData = buf; 439 tuple.TupleData = buf;
472 tuple.TupleDataMax = MAX_TUPLE_SIZE; 440 tuple.TupleDataMax = MAX_TUPLE_SIZE;
473 tuple.TupleOffset = 2; 441 tuple.TupleOffset = 2;
474 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 442 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
475 443
476 for (i=0; i<tuple.TupleDataLen - 4; i++) 444 for (i=0; i<tuple.TupleDataLen - 4; i++)
477 if (buf[i] == 0) buf[i] = ' '; 445 if (buf[i] == 0) buf[i] = ' ';
478 printk(KERN_INFO "ray_cs Detected: %s\n",buf); 446 printk(KERN_INFO "ray_cs Detected: %s\n",buf);
479 447
480 /* Configure card */
481 link->state |= DEV_CONFIG;
482
483 /* Now allocate an interrupt line. Note that this does not 448 /* Now allocate an interrupt line. Note that this does not
484 actually assign a handler to the interrupt. 449 actually assign a handler to the interrupt.
485 */ 450 */
486 CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 451 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
487 dev->irq = link->irq.AssignedIRQ; 452 dev->irq = link->irq.AssignedIRQ;
488 453
489 /* This actually configures the PCMCIA socket -- setting up 454 /* This actually configures the PCMCIA socket -- setting up
490 the I/O windows and the interrupt mapping. 455 the I/O windows and the interrupt mapping.
491 */ 456 */
492 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 457 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
493 458
494/*** Set up 32k window for shared memory (transmit and control) ************/ 459/*** Set up 32k window for shared memory (transmit and control) ************/
495 req.Attributes = WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT; 460 req.Attributes = WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
496 req.Base = 0; 461 req.Base = 0;
497 req.Size = 0x8000; 462 req.Size = 0x8000;
498 req.AccessSpeed = ray_mem_speed; 463 req.AccessSpeed = ray_mem_speed;
499 CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &link->win)); 464 CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win));
500 mem.CardOffset = 0x0000; mem.Page = 0; 465 mem.CardOffset = 0x0000; mem.Page = 0;
501 CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem)); 466 CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem));
502 local->sram = ioremap(req.Base,req.Size); 467 local->sram = ioremap(req.Base,req.Size);
@@ -506,7 +471,7 @@ static void ray_config(dev_link_t *link)
506 req.Base = 0; 471 req.Base = 0;
507 req.Size = 0x4000; 472 req.Size = 0x4000;
508 req.AccessSpeed = ray_mem_speed; 473 req.AccessSpeed = ray_mem_speed;
509 CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &local->rmem_handle)); 474 CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &local->rmem_handle));
510 mem.CardOffset = 0x8000; mem.Page = 0; 475 mem.CardOffset = 0x8000; mem.Page = 0;
511 CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->rmem_handle, &mem)); 476 CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->rmem_handle, &mem));
512 local->rmem = ioremap(req.Base,req.Size); 477 local->rmem = ioremap(req.Base,req.Size);
@@ -516,7 +481,7 @@ static void ray_config(dev_link_t *link)
516 req.Base = 0; 481 req.Base = 0;
517 req.Size = 0x1000; 482 req.Size = 0x1000;
518 req.AccessSpeed = ray_mem_speed; 483 req.AccessSpeed = ray_mem_speed;
519 CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &local->amem_handle)); 484 CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &local->amem_handle));
520 mem.CardOffset = 0x0000; mem.Page = 0; 485 mem.CardOffset = 0x0000; mem.Page = 0;
521 CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->amem_handle, &mem)); 486 CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->amem_handle, &mem));
522 local->amem = ioremap(req.Base,req.Size); 487 local->amem = ioremap(req.Base,req.Size);
@@ -526,32 +491,32 @@ static void ray_config(dev_link_t *link)
526 DEBUG(3,"ray_config amem=%p\n",local->amem); 491 DEBUG(3,"ray_config amem=%p\n",local->amem);
527 if (ray_init(dev) < 0) { 492 if (ray_init(dev) < 0) {
528 ray_release(link); 493 ray_release(link);
529 return; 494 return -ENODEV;
530 } 495 }
531 496
532 SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 497 SET_NETDEV_DEV(dev, &handle_to_dev(link));
533 i = register_netdev(dev); 498 i = register_netdev(dev);
534 if (i != 0) { 499 if (i != 0) {
535 printk("ray_config register_netdev() failed\n"); 500 printk("ray_config register_netdev() failed\n");
536 ray_release(link); 501 ray_release(link);
537 return; 502 return i;
538 } 503 }
539 504
540 strcpy(local->node.dev_name, dev->name); 505 strcpy(local->node.dev_name, dev->name);
541 link->dev = &local->node; 506 link->dev_node = &local->node;
542 507
543 link->state &= ~DEV_CONFIG_PENDING;
544 printk(KERN_INFO "%s: RayLink, irq %d, hw_addr ", 508 printk(KERN_INFO "%s: RayLink, irq %d, hw_addr ",
545 dev->name, dev->irq); 509 dev->name, dev->irq);
546 for (i = 0; i < 6; i++) 510 for (i = 0; i < 6; i++)
547 printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n")); 511 printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n"));
548 512
549 return; 513 return 0;
550 514
551cs_failed: 515cs_failed:
552 cs_error(link->handle, last_fn, last_ret); 516 cs_error(link, last_fn, last_ret);
553 517
554 ray_release(link); 518 ray_release(link);
519 return -ENODEV;
555} /* ray_config */ 520} /* ray_config */
556 521
557static inline struct ccs __iomem *ccs_base(ray_dev_t *dev) 522static inline struct ccs __iomem *ccs_base(ray_dev_t *dev)
@@ -578,9 +543,9 @@ static int ray_init(struct net_device *dev)
578 UCHAR *p; 543 UCHAR *p;
579 struct ccs __iomem *pccs; 544 struct ccs __iomem *pccs;
580 ray_dev_t *local = (ray_dev_t *)dev->priv; 545 ray_dev_t *local = (ray_dev_t *)dev->priv;
581 dev_link_t *link = local->finder; 546 struct pcmcia_device *link = local->finder;
582 DEBUG(1, "ray_init(0x%p)\n", dev); 547 DEBUG(1, "ray_init(0x%p)\n", dev);
583 if (!(link->state & DEV_PRESENT)) { 548 if (!(pcmcia_dev_present(link))) {
584 DEBUG(0,"ray_init - device not present\n"); 549 DEBUG(0,"ray_init - device not present\n");
585 return -1; 550 return -1;
586 } 551 }
@@ -640,10 +605,10 @@ static int dl_startup_params(struct net_device *dev)
640 int ccsindex; 605 int ccsindex;
641 ray_dev_t *local = (ray_dev_t *)dev->priv; 606 ray_dev_t *local = (ray_dev_t *)dev->priv;
642 struct ccs __iomem *pccs; 607 struct ccs __iomem *pccs;
643 dev_link_t *link = local->finder; 608 struct pcmcia_device *link = local->finder;
644 609
645 DEBUG(1,"dl_startup_params entered\n"); 610 DEBUG(1,"dl_startup_params entered\n");
646 if (!(link->state & DEV_PRESENT)) { 611 if (!(pcmcia_dev_present(link))) {
647 DEBUG(2,"ray_cs dl_startup_params - device not present\n"); 612 DEBUG(2,"ray_cs dl_startup_params - device not present\n");
648 return -1; 613 return -1;
649 } 614 }
@@ -747,9 +712,9 @@ static void verify_dl_startup(u_long data)
747 ray_dev_t *local = (ray_dev_t *)data; 712 ray_dev_t *local = (ray_dev_t *)data;
748 struct ccs __iomem *pccs = ccs_base(local) + local->dl_param_ccs; 713 struct ccs __iomem *pccs = ccs_base(local) + local->dl_param_ccs;
749 UCHAR status; 714 UCHAR status;
750 dev_link_t *link = local->finder; 715 struct pcmcia_device *link = local->finder;
751 716
752 if (!(link->state & DEV_PRESENT)) { 717 if (!(pcmcia_dev_present(link))) {
753 DEBUG(2,"ray_cs verify_dl_startup - device not present\n"); 718 DEBUG(2,"ray_cs verify_dl_startup - device not present\n");
754 return; 719 return;
755 } 720 }
@@ -787,8 +752,8 @@ static void start_net(u_long data)
787 ray_dev_t *local = (ray_dev_t *)data; 752 ray_dev_t *local = (ray_dev_t *)data;
788 struct ccs __iomem *pccs; 753 struct ccs __iomem *pccs;
789 int ccsindex; 754 int ccsindex;
790 dev_link_t *link = local->finder; 755 struct pcmcia_device *link = local->finder;
791 if (!(link->state & DEV_PRESENT)) { 756 if (!(pcmcia_dev_present(link))) {
792 DEBUG(2,"ray_cs start_net - device not present\n"); 757 DEBUG(2,"ray_cs start_net - device not present\n");
793 return; 758 return;
794 } 759 }
@@ -814,9 +779,9 @@ static void join_net(u_long data)
814 779
815 struct ccs __iomem *pccs; 780 struct ccs __iomem *pccs;
816 int ccsindex; 781 int ccsindex;
817 dev_link_t *link = local->finder; 782 struct pcmcia_device *link = local->finder;
818 783
819 if (!(link->state & DEV_PRESENT)) { 784 if (!(pcmcia_dev_present(link))) {
820 DEBUG(2,"ray_cs join_net - device not present\n"); 785 DEBUG(2,"ray_cs join_net - device not present\n");
821 return; 786 return;
822 } 787 }
@@ -840,7 +805,7 @@ static void join_net(u_long data)
840 device, and release the PCMCIA configuration. If the device is 805 device, and release the PCMCIA configuration. If the device is
841 still open, this will be postponed until it is closed. 806 still open, this will be postponed until it is closed.
842=============================================================================*/ 807=============================================================================*/
843static void ray_release(dev_link_t *link) 808static void ray_release(struct pcmcia_device *link)
844{ 809{
845 struct net_device *dev = link->priv; 810 struct net_device *dev = link->priv;
846 ray_dev_t *local = dev->priv; 811 ray_dev_t *local = dev->priv;
@@ -849,56 +814,38 @@ static void ray_release(dev_link_t *link)
849 DEBUG(1, "ray_release(0x%p)\n", link); 814 DEBUG(1, "ray_release(0x%p)\n", link);
850 815
851 del_timer(&local->timer); 816 del_timer(&local->timer);
852 link->state &= ~DEV_CONFIG;
853 817
854 iounmap(local->sram); 818 iounmap(local->sram);
855 iounmap(local->rmem); 819 iounmap(local->rmem);
856 iounmap(local->amem); 820 iounmap(local->amem);
857 /* Do bother checking to see if these succeed or not */ 821 /* Do bother checking to see if these succeed or not */
858 i = pcmcia_release_window(link->win);
859 if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(link->win) ret = %x\n",i);
860 i = pcmcia_release_window(local->amem_handle); 822 i = pcmcia_release_window(local->amem_handle);
861 if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(local->amem) ret = %x\n",i); 823 if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(local->amem) ret = %x\n",i);
862 i = pcmcia_release_window(local->rmem_handle); 824 i = pcmcia_release_window(local->rmem_handle);
863 if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(local->rmem) ret = %x\n",i); 825 if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(local->rmem) ret = %x\n",i);
864 i = pcmcia_release_configuration(link->handle); 826 pcmcia_disable_device(link);
865 if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseConfiguration ret = %x\n",i);
866 i = pcmcia_release_irq(link->handle, &link->irq);
867 if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseIRQ ret = %x\n",i);
868 827
869 DEBUG(2,"ray_release ending\n"); 828 DEBUG(2,"ray_release ending\n");
870} 829}
871 830
872static int ray_suspend(struct pcmcia_device *p_dev) 831static int ray_suspend(struct pcmcia_device *link)
873{ 832{
874 dev_link_t *link = dev_to_instance(p_dev);
875 struct net_device *dev = link->priv; 833 struct net_device *dev = link->priv;
876 834
877 link->state |= DEV_SUSPEND; 835 if (link->open)
878 if (link->state & DEV_CONFIG) { 836 netif_device_detach(dev);
879 if (link->open)
880 netif_device_detach(dev);
881
882 pcmcia_release_configuration(link->handle);
883 }
884
885 837
886 return 0; 838 return 0;
887} 839}
888 840
889static int ray_resume(struct pcmcia_device *p_dev) 841static int ray_resume(struct pcmcia_device *link)
890{ 842{
891 dev_link_t *link = dev_to_instance(p_dev);
892 struct net_device *dev = link->priv; 843 struct net_device *dev = link->priv;
893 844
894 link->state &= ~DEV_SUSPEND; 845 if (link->open) {
895 if (link->state & DEV_CONFIG) { 846 ray_reset(dev);
896 pcmcia_request_configuration(link->handle, &link->conf); 847 netif_device_attach(dev);
897 if (link->open) { 848 }
898 ray_reset(dev);
899 netif_device_attach(dev);
900 }
901 }
902 849
903 return 0; 850 return 0;
904} 851}
@@ -910,10 +857,10 @@ int ray_dev_init(struct net_device *dev)
910 int i; 857 int i;
911#endif /* RAY_IMMEDIATE_INIT */ 858#endif /* RAY_IMMEDIATE_INIT */
912 ray_dev_t *local = dev->priv; 859 ray_dev_t *local = dev->priv;
913 dev_link_t *link = local->finder; 860 struct pcmcia_device *link = local->finder;
914 861
915 DEBUG(1,"ray_dev_init(dev=%p)\n",dev); 862 DEBUG(1,"ray_dev_init(dev=%p)\n",dev);
916 if (!(link->state & DEV_PRESENT)) { 863 if (!(pcmcia_dev_present(link))) {
917 DEBUG(2,"ray_dev_init - device not present\n"); 864 DEBUG(2,"ray_dev_init - device not present\n");
918 return -1; 865 return -1;
919 } 866 }
@@ -944,10 +891,10 @@ int ray_dev_init(struct net_device *dev)
944static int ray_dev_config(struct net_device *dev, struct ifmap *map) 891static int ray_dev_config(struct net_device *dev, struct ifmap *map)
945{ 892{
946 ray_dev_t *local = dev->priv; 893 ray_dev_t *local = dev->priv;
947 dev_link_t *link = local->finder; 894 struct pcmcia_device *link = local->finder;
948 /* Dummy routine to satisfy device structure */ 895 /* Dummy routine to satisfy device structure */
949 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);
950 if (!(link->state & DEV_PRESENT)) { 897 if (!(pcmcia_dev_present(link))) {
951 DEBUG(2,"ray_dev_config - device not present\n"); 898 DEBUG(2,"ray_dev_config - device not present\n");
952 return -1; 899 return -1;
953 } 900 }
@@ -958,10 +905,10 @@ static int ray_dev_config(struct net_device *dev, struct ifmap *map)
958static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev) 905static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev)
959{ 906{
960 ray_dev_t *local = dev->priv; 907 ray_dev_t *local = dev->priv;
961 dev_link_t *link = local->finder; 908 struct pcmcia_device *link = local->finder;
962 short length = skb->len; 909 short length = skb->len;
963 910
964 if (!(link->state & DEV_PRESENT)) { 911 if (!(pcmcia_dev_present(link))) {
965 DEBUG(2,"ray_dev_start_xmit - device not present\n"); 912 DEBUG(2,"ray_dev_start_xmit - device not present\n");
966 return -1; 913 return -1;
967 } 914 }
@@ -1570,7 +1517,7 @@ static int ray_commit(struct net_device *dev,
1570static iw_stats * ray_get_wireless_stats(struct net_device * dev) 1517static iw_stats * ray_get_wireless_stats(struct net_device * dev)
1571{ 1518{
1572 ray_dev_t * local = (ray_dev_t *) dev->priv; 1519 ray_dev_t * local = (ray_dev_t *) dev->priv;
1573 dev_link_t *link = local->finder; 1520 struct pcmcia_device *link = local->finder;
1574 struct status __iomem *p = local->sram + STATUS_BASE; 1521 struct status __iomem *p = local->sram + STATUS_BASE;
1575 1522
1576 if(local == (ray_dev_t *) NULL) 1523 if(local == (ray_dev_t *) NULL)
@@ -1588,7 +1535,7 @@ static iw_stats * ray_get_wireless_stats(struct net_device * dev)
1588 } 1535 }
1589#endif /* WIRELESS_SPY */ 1536#endif /* WIRELESS_SPY */
1590 1537
1591 if((link->state & DEV_PRESENT)) { 1538 if(pcmcia_dev_present(link)) {
1592 local->wstats.qual.noise = readb(&p->rxnoise); 1539 local->wstats.qual.noise = readb(&p->rxnoise);
1593 local->wstats.qual.updated |= 4; 1540 local->wstats.qual.updated |= 4;
1594 } 1541 }
@@ -1657,18 +1604,14 @@ static const struct iw_handler_def ray_handler_def =
1657/*===========================================================================*/ 1604/*===========================================================================*/
1658static int ray_open(struct net_device *dev) 1605static int ray_open(struct net_device *dev)
1659{ 1606{
1660 dev_link_t *link;
1661 ray_dev_t *local = (ray_dev_t *)dev->priv; 1607 ray_dev_t *local = (ray_dev_t *)dev->priv;
1608 struct pcmcia_device *link;
1609 link = local->finder;
1662 1610
1663 DEBUG(1, "ray_open('%s')\n", dev->name); 1611 DEBUG(1, "ray_open('%s')\n", dev->name);
1664 1612
1665 for (link = dev_list; link; link = link->next) 1613 if (link->open == 0)
1666 if (link->priv == dev) break; 1614 local->num_multi = 0;
1667 if (!DEV_OK(link)) {
1668 return -ENODEV;
1669 }
1670
1671 if (link->open == 0) local->num_multi = 0;
1672 link->open++; 1615 link->open++;
1673 1616
1674 /* If the card is not started, time to start it ! - Jean II */ 1617 /* If the card is not started, time to start it ! - Jean II */
@@ -1695,15 +1638,12 @@ static int ray_open(struct net_device *dev)
1695/*===========================================================================*/ 1638/*===========================================================================*/
1696static int ray_dev_close(struct net_device *dev) 1639static int ray_dev_close(struct net_device *dev)
1697{ 1640{
1698 dev_link_t *link; 1641 ray_dev_t *local = (ray_dev_t *)dev->priv;
1642 struct pcmcia_device *link;
1643 link = local->finder;
1699 1644
1700 DEBUG(1, "ray_dev_close('%s')\n", dev->name); 1645 DEBUG(1, "ray_dev_close('%s')\n", dev->name);
1701 1646
1702 for (link = dev_list; link; link = link->next)
1703 if (link->priv == dev) break;
1704 if (link == NULL)
1705 return -ENODEV;
1706
1707 link->open--; 1647 link->open--;
1708 netif_stop_queue(dev); 1648 netif_stop_queue(dev);
1709 1649
@@ -1725,9 +1665,9 @@ static void ray_reset(struct net_device *dev) {
1725static int interrupt_ecf(ray_dev_t *local, int ccs) 1665static int interrupt_ecf(ray_dev_t *local, int ccs)
1726{ 1666{
1727 int i = 50; 1667 int i = 50;
1728 dev_link_t *link = local->finder; 1668 struct pcmcia_device *link = local->finder;
1729 1669
1730 if (!(link->state & DEV_PRESENT)) { 1670 if (!(pcmcia_dev_present(link))) {
1731 DEBUG(2,"ray_cs interrupt_ecf - device not present\n"); 1671 DEBUG(2,"ray_cs interrupt_ecf - device not present\n");
1732 return -1; 1672 return -1;
1733 } 1673 }
@@ -1752,9 +1692,9 @@ static int get_free_tx_ccs(ray_dev_t *local)
1752{ 1692{
1753 int i; 1693 int i;
1754 struct ccs __iomem *pccs = ccs_base(local); 1694 struct ccs __iomem *pccs = ccs_base(local);
1755 dev_link_t *link = local->finder; 1695 struct pcmcia_device *link = local->finder;
1756 1696
1757 if (!(link->state & DEV_PRESENT)) { 1697 if (!(pcmcia_dev_present(link))) {
1758 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");
1759 return ECARDGONE; 1699 return ECARDGONE;
1760 } 1700 }
@@ -1783,9 +1723,9 @@ static int get_free_ccs(ray_dev_t *local)
1783{ 1723{
1784 int i; 1724 int i;
1785 struct ccs __iomem *pccs = ccs_base(local); 1725 struct ccs __iomem *pccs = ccs_base(local);
1786 dev_link_t *link = local->finder; 1726 struct pcmcia_device *link = local->finder;
1787 1727
1788 if (!(link->state & DEV_PRESENT)) { 1728 if (!(pcmcia_dev_present(link))) {
1789 DEBUG(2,"ray_cs get_free_ccs - device not present\n"); 1729 DEBUG(2,"ray_cs get_free_ccs - device not present\n");
1790 return ECARDGONE; 1730 return ECARDGONE;
1791 } 1731 }
@@ -1858,9 +1798,9 @@ static int parse_addr(char *in_str, UCHAR *out)
1858static struct net_device_stats *ray_get_stats(struct net_device *dev) 1798static struct net_device_stats *ray_get_stats(struct net_device *dev)
1859{ 1799{
1860 ray_dev_t *local = (ray_dev_t *)dev->priv; 1800 ray_dev_t *local = (ray_dev_t *)dev->priv;
1861 dev_link_t *link = local->finder; 1801 struct pcmcia_device *link = local->finder;
1862 struct status __iomem *p = local->sram + STATUS_BASE; 1802 struct status __iomem *p = local->sram + STATUS_BASE;
1863 if (!(link->state & DEV_PRESENT)) { 1803 if (!(pcmcia_dev_present(link))) {
1864 DEBUG(2,"ray_cs net_device_stats - device not present\n"); 1804 DEBUG(2,"ray_cs net_device_stats - device not present\n");
1865 return &local->stats; 1805 return &local->stats;
1866 } 1806 }
@@ -1888,12 +1828,12 @@ static struct net_device_stats *ray_get_stats(struct net_device *dev)
1888static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value, int len) 1828static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value, int len)
1889{ 1829{
1890 ray_dev_t *local = (ray_dev_t *)dev->priv; 1830 ray_dev_t *local = (ray_dev_t *)dev->priv;
1891 dev_link_t *link = local->finder; 1831 struct pcmcia_device *link = local->finder;
1892 int ccsindex; 1832 int ccsindex;
1893 int i; 1833 int i;
1894 struct ccs __iomem *pccs; 1834 struct ccs __iomem *pccs;
1895 1835
1896 if (!(link->state & DEV_PRESENT)) { 1836 if (!(pcmcia_dev_present(link))) {
1897 DEBUG(2,"ray_update_parm - device not present\n"); 1837 DEBUG(2,"ray_update_parm - device not present\n");
1898 return; 1838 return;
1899 } 1839 }
@@ -1925,10 +1865,10 @@ static void ray_update_multi_list(struct net_device *dev, int all)
1925 struct ccs __iomem *pccs; 1865 struct ccs __iomem *pccs;
1926 int i = 0; 1866 int i = 0;
1927 ray_dev_t *local = (ray_dev_t *)dev->priv; 1867 ray_dev_t *local = (ray_dev_t *)dev->priv;
1928 dev_link_t *link = local->finder; 1868 struct pcmcia_device *link = local->finder;
1929 void __iomem *p = local->sram + HOST_TO_ECF_BASE; 1869 void __iomem *p = local->sram + HOST_TO_ECF_BASE;
1930 1870
1931 if (!(link->state & DEV_PRESENT)) { 1871 if (!(pcmcia_dev_present(link))) {
1932 DEBUG(2,"ray_update_multi_list - device not present\n"); 1872 DEBUG(2,"ray_update_multi_list - device not present\n");
1933 return; 1873 return;
1934 } 1874 }
@@ -2005,7 +1945,7 @@ static void set_multicast_list(struct net_device *dev)
2005static irqreturn_t ray_interrupt(int irq, void *dev_id, struct pt_regs * regs) 1945static irqreturn_t ray_interrupt(int irq, void *dev_id, struct pt_regs * regs)
2006{ 1946{
2007 struct net_device *dev = (struct net_device *)dev_id; 1947 struct net_device *dev = (struct net_device *)dev_id;
2008 dev_link_t *link; 1948 struct pcmcia_device *link;
2009 ray_dev_t *local; 1949 ray_dev_t *local;
2010 struct ccs __iomem *pccs; 1950 struct ccs __iomem *pccs;
2011 struct rcs __iomem *prcs; 1951 struct rcs __iomem *prcs;
@@ -2020,8 +1960,8 @@ static irqreturn_t ray_interrupt(int irq, void *dev_id, struct pt_regs * regs)
2020 DEBUG(4,"ray_cs: interrupt for *dev=%p\n",dev); 1960 DEBUG(4,"ray_cs: interrupt for *dev=%p\n",dev);
2021 1961
2022 local = (ray_dev_t *)dev->priv; 1962 local = (ray_dev_t *)dev->priv;
2023 link = (dev_link_t *)local->finder; 1963 link = (struct pcmcia_device *)local->finder;
2024 if ( ! (link->state & DEV_PRESENT) || link->state & DEV_SUSPEND ) { 1964 if (!pcmcia_dev_present(link)) {
2025 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");
2026 return IRQ_NONE; 1966 return IRQ_NONE;
2027 } 1967 }
@@ -2540,9 +2480,9 @@ static void release_frag_chain(ray_dev_t *local, struct rcs __iomem * prcs)
2540/*===========================================================================*/ 2480/*===========================================================================*/
2541static void authenticate(ray_dev_t *local) 2481static void authenticate(ray_dev_t *local)
2542{ 2482{
2543 dev_link_t *link = local->finder; 2483 struct pcmcia_device *link = local->finder;
2544 DEBUG(0,"ray_cs Starting authentication.\n"); 2484 DEBUG(0,"ray_cs Starting authentication.\n");
2545 if (!(link->state & DEV_PRESENT)) { 2485 if (!(pcmcia_dev_present(link))) {
2546 DEBUG(2,"ray_cs authenticate - device not present\n"); 2486 DEBUG(2,"ray_cs authenticate - device not present\n");
2547 return; 2487 return;
2548 } 2488 }
@@ -2606,10 +2546,10 @@ static void rx_authenticate(ray_dev_t *local, struct rcs __iomem *prcs,
2606static void associate(ray_dev_t *local) 2546static void associate(ray_dev_t *local)
2607{ 2547{
2608 struct ccs __iomem *pccs; 2548 struct ccs __iomem *pccs;
2609 dev_link_t *link = local->finder; 2549 struct pcmcia_device *link = local->finder;
2610 struct net_device *dev = link->priv; 2550 struct net_device *dev = link->priv;
2611 int ccsindex; 2551 int ccsindex;
2612 if (!(link->state & DEV_PRESENT)) { 2552 if (!(pcmcia_dev_present(link))) {
2613 DEBUG(2,"ray_cs associate - device not present\n"); 2553 DEBUG(2,"ray_cs associate - device not present\n");
2614 return; 2554 return;
2615 } 2555 }
@@ -2689,14 +2629,14 @@ static int ray_cs_proc_read(char *buf, char **start, off_t offset, int len)
2689 * eg ifconfig 2629 * eg ifconfig
2690 */ 2630 */
2691 int i; 2631 int i;
2692 dev_link_t *link; 2632 struct pcmcia_device *link;
2693 struct net_device *dev; 2633 struct net_device *dev;
2694 ray_dev_t *local; 2634 ray_dev_t *local;
2695 UCHAR *p; 2635 UCHAR *p;
2696 struct freq_hop_element *pfh; 2636 struct freq_hop_element *pfh;
2697 UCHAR c[33]; 2637 UCHAR c[33];
2698 2638
2699 link = dev_list; 2639 link = this_device;
2700 if (!link) 2640 if (!link)
2701 return 0; 2641 return 0;
2702 dev = (struct net_device *)link->priv; 2642 dev = (struct net_device *)link->priv;
@@ -2898,7 +2838,7 @@ static struct pcmcia_driver ray_driver = {
2898 .drv = { 2838 .drv = {
2899 .name = "ray_cs", 2839 .name = "ray_cs",
2900 }, 2840 },
2901 .probe = ray_attach, 2841 .probe = ray_probe,
2902 .remove = ray_detach, 2842 .remove = ray_detach,
2903 .id_table = ray_ids, 2843 .id_table = ray_ids,
2904 .suspend = ray_suspend, 2844 .suspend = ray_suspend,
@@ -2940,7 +2880,6 @@ static void __exit exit_ray_cs(void)
2940#endif 2880#endif
2941 2881
2942 pcmcia_unregister_driver(&ray_driver); 2882 pcmcia_unregister_driver(&ray_driver);
2943 BUG_ON(dev_list != NULL);
2944} /* exit_ray_cs */ 2883} /* exit_ray_cs */
2945 2884
2946module_init(init_ray_cs); 2885module_init(init_ray_cs);
diff --git a/drivers/net/wireless/ray_cs.h b/drivers/net/wireless/ray_cs.h
index 42660fe64bfd..bd73ebf03340 100644
--- a/drivers/net/wireless/ray_cs.h
+++ b/drivers/net/wireless/ray_cs.h
@@ -31,7 +31,7 @@ typedef struct ray_dev_t {
31 void __iomem *sram; /* pointer to beginning of shared RAM */ 31 void __iomem *sram; /* pointer to beginning of shared RAM */
32 void __iomem *amem; /* pointer to attribute mem window */ 32 void __iomem *amem; /* pointer to attribute mem window */
33 void __iomem *rmem; /* pointer to receive buffer window */ 33 void __iomem *rmem; /* pointer to receive buffer window */
34 dev_link_t *finder; /* pointer back to dev_link_t for card */ 34 struct pcmcia_device *finder; /* pointer back to struct pcmcia_device for card */
35 struct timer_list timer; 35 struct timer_list timer;
36 long tx_ccs_lock; 36 long tx_ccs_lock;
37 long ccs_lock; 37 long ccs_lock;
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index 5fa6fbe35bb9..f7b77ce54d7b 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -63,7 +63,7 @@ MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket
63/* PCMCIA specific device information (goes in the card field of 63/* PCMCIA specific device information (goes in the card field of
64 * struct orinoco_private */ 64 * struct orinoco_private */
65struct orinoco_pccard { 65struct orinoco_pccard {
66 dev_link_t link; 66 struct pcmcia_device *p_dev;
67 dev_node_t node; 67 dev_node_t node;
68}; 68};
69 69
@@ -71,8 +71,8 @@ struct orinoco_pccard {
71/* Function prototypes */ 71/* Function prototypes */
72/********************************************************************/ 72/********************************************************************/
73 73
74static void spectrum_cs_config(dev_link_t *link); 74static int spectrum_cs_config(struct pcmcia_device *link);
75static void spectrum_cs_release(dev_link_t *link); 75static void spectrum_cs_release(struct pcmcia_device *link);
76 76
77/********************************************************************/ 77/********************************************************************/
78/* Firmware downloader */ 78/* Firmware downloader */
@@ -238,14 +238,14 @@ spectrum_aux_open(hermes_t *hw)
238 * If IDLE is 1, stop the firmware, so that it can be safely rewritten. 238 * If IDLE is 1, stop the firmware, so that it can be safely rewritten.
239 */ 239 */
240static int 240static int
241spectrum_reset(dev_link_t *link, int idle) 241spectrum_reset(struct pcmcia_device *link, int idle)
242{ 242{
243 int last_ret, last_fn; 243 int last_ret, last_fn;
244 conf_reg_t reg; 244 conf_reg_t reg;
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 */
@@ -253,7 +253,7 @@ spectrum_reset(dev_link_t *link, int idle)
253 reg.Action = CS_READ; 253 reg.Action = CS_READ;
254 reg.Offset = CISREG_COR; 254 reg.Offset = CISREG_COR;
255 CS_CHECK(AccessConfigurationRegister, 255 CS_CHECK(AccessConfigurationRegister,
256 pcmcia_access_configuration_register(link->handle, &reg)); 256 pcmcia_access_configuration_register(link, &reg));
257 save_cor = reg.Value; 257 save_cor = reg.Value;
258 258
259 /* Soft-Reset card */ 259 /* Soft-Reset card */
@@ -261,14 +261,14 @@ spectrum_reset(dev_link_t *link, int idle)
261 reg.Offset = CISREG_COR; 261 reg.Offset = CISREG_COR;
262 reg.Value = (save_cor | COR_SOFT_RESET); 262 reg.Value = (save_cor | COR_SOFT_RESET);
263 CS_CHECK(AccessConfigurationRegister, 263 CS_CHECK(AccessConfigurationRegister,
264 pcmcia_access_configuration_register(link->handle, &reg)); 264 pcmcia_access_configuration_register(link, &reg));
265 udelay(1000); 265 udelay(1000);
266 266
267 /* Read CCSR */ 267 /* Read CCSR */
268 reg.Action = CS_READ; 268 reg.Action = CS_READ;
269 reg.Offset = CISREG_CCSR; 269 reg.Offset = CISREG_CCSR;
270 CS_CHECK(AccessConfigurationRegister, 270 CS_CHECK(AccessConfigurationRegister,
271 pcmcia_access_configuration_register(link->handle, &reg)); 271 pcmcia_access_configuration_register(link, &reg));
272 272
273 /* 273 /*
274 * Start or stop the firmware. Memory width bit should be 274 * Start or stop the firmware. Memory width bit should be
@@ -278,7 +278,7 @@ spectrum_reset(dev_link_t *link, int idle)
278 reg.Offset = CISREG_CCSR; 278 reg.Offset = CISREG_CCSR;
279 reg.Value = (idle ? HCR_IDLE : HCR_RUN) | (reg.Value & HCR_MEM16); 279 reg.Value = (idle ? HCR_IDLE : HCR_RUN) | (reg.Value & HCR_MEM16);
280 CS_CHECK(AccessConfigurationRegister, 280 CS_CHECK(AccessConfigurationRegister,
281 pcmcia_access_configuration_register(link->handle, &reg)); 281 pcmcia_access_configuration_register(link, &reg));
282 udelay(1000); 282 udelay(1000);
283 283
284 /* Restore original COR configuration index */ 284 /* Restore original COR configuration index */
@@ -286,12 +286,12 @@ spectrum_reset(dev_link_t *link, int idle)
286 reg.Offset = CISREG_COR; 286 reg.Offset = CISREG_COR;
287 reg.Value = (save_cor & ~COR_SOFT_RESET); 287 reg.Value = (save_cor & ~COR_SOFT_RESET);
288 CS_CHECK(AccessConfigurationRegister, 288 CS_CHECK(AccessConfigurationRegister,
289 pcmcia_access_configuration_register(link->handle, &reg)); 289 pcmcia_access_configuration_register(link, &reg));
290 udelay(1000); 290 udelay(1000);
291 return 0; 291 return 0;
292 292
293 cs_failed: 293 cs_failed:
294 cs_error(link->handle, last_fn, last_ret); 294 cs_error(link, last_fn, last_ret);
295 return -ENODEV; 295 return -ENODEV;
296} 296}
297 297
@@ -441,7 +441,7 @@ spectrum_load_blocks(hermes_t *hw, const struct dblock *first_block)
441 * care of the PDA - read it and then write it on top of the firmware. 441 * care of the PDA - read it and then write it on top of the firmware.
442 */ 442 */
443static int 443static int
444spectrum_dl_image(hermes_t *hw, dev_link_t *link, 444spectrum_dl_image(hermes_t *hw, struct pcmcia_device *link,
445 const unsigned char *image) 445 const unsigned char *image)
446{ 446{
447 int ret; 447 int ret;
@@ -505,14 +505,13 @@ spectrum_dl_image(hermes_t *hw, dev_link_t *link,
505 * reset on the card, to make sure it's in a sane state. 505 * reset on the card, to make sure it's in a sane state.
506 */ 506 */
507static int 507static int
508spectrum_dl_firmware(hermes_t *hw, dev_link_t *link) 508spectrum_dl_firmware(hermes_t *hw, struct pcmcia_device *link)
509{ 509{
510 int ret; 510 int ret;
511 client_handle_t handle = link->handle;
512 const struct firmware *fw_entry; 511 const struct firmware *fw_entry;
513 512
514 if (request_firmware(&fw_entry, primary_fw_name, 513 if (request_firmware(&fw_entry, primary_fw_name,
515 &handle_to_dev(handle)) == 0) { 514 &handle_to_dev(link)) == 0) {
516 primsym = fw_entry->data; 515 primsym = fw_entry->data;
517 } else { 516 } else {
518 printk(KERN_ERR PFX "Cannot find firmware: %s\n", 517 printk(KERN_ERR PFX "Cannot find firmware: %s\n",
@@ -521,7 +520,7 @@ spectrum_dl_firmware(hermes_t *hw, dev_link_t *link)
521 } 520 }
522 521
523 if (request_firmware(&fw_entry, secondary_fw_name, 522 if (request_firmware(&fw_entry, secondary_fw_name,
524 &handle_to_dev(handle)) == 0) { 523 &handle_to_dev(link)) == 0) {
525 secsym = fw_entry->data; 524 secsym = fw_entry->data;
526 } else { 525 } else {
527 printk(KERN_ERR PFX "Cannot find firmware: %s\n", 526 printk(KERN_ERR PFX "Cannot find firmware: %s\n",
@@ -554,12 +553,12 @@ static int
554spectrum_cs_hard_reset(struct orinoco_private *priv) 553spectrum_cs_hard_reset(struct orinoco_private *priv)
555{ 554{
556 struct orinoco_pccard *card = priv->card; 555 struct orinoco_pccard *card = priv->card;
557 dev_link_t *link = &card->link; 556 struct pcmcia_device *link = card->p_dev;
558 int err; 557 int err;
559 558
560 if (!hermes_present(&priv->hw)) { 559 if (!hermes_present(&priv->hw)) {
561 /* The firmware needs to be reloaded */ 560 /* The firmware needs to be reloaded */
562 if (spectrum_dl_firmware(&priv->hw, &card->link) != 0) { 561 if (spectrum_dl_firmware(&priv->hw, link) != 0) {
563 printk(KERN_ERR PFX "Firmware download failed\n"); 562 printk(KERN_ERR PFX "Firmware download failed\n");
564 err = -ENODEV; 563 err = -ENODEV;
565 } 564 }
@@ -584,12 +583,11 @@ spectrum_cs_hard_reset(struct orinoco_private *priv)
584 * configure the card at this point -- we wait until we receive a card 583 * configure the card at this point -- we wait until we receive a card
585 * insertion event. */ 584 * insertion event. */
586static int 585static int
587spectrum_cs_attach(struct pcmcia_device *p_dev) 586spectrum_cs_probe(struct pcmcia_device *link)
588{ 587{
589 struct net_device *dev; 588 struct net_device *dev;
590 struct orinoco_private *priv; 589 struct orinoco_private *priv;
591 struct orinoco_pccard *card; 590 struct orinoco_pccard *card;
592 dev_link_t *link;
593 591
594 dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset); 592 dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset);
595 if (! dev) 593 if (! dev)
@@ -598,7 +596,7 @@ spectrum_cs_attach(struct pcmcia_device *p_dev)
598 card = priv->card; 596 card = priv->card;
599 597
600 /* Link both structures together */ 598 /* Link both structures together */
601 link = &card->link; 599 card->p_dev = link;
602 link->priv = dev; 600 link->priv = dev;
603 601
604 /* Interrupt setup */ 602 /* Interrupt setup */
@@ -615,13 +613,7 @@ spectrum_cs_attach(struct pcmcia_device *p_dev)
615 link->conf.Attributes = 0; 613 link->conf.Attributes = 0;
616 link->conf.IntType = INT_MEMORY_AND_IO; 614 link->conf.IntType = INT_MEMORY_AND_IO;
617 615
618 link->handle = p_dev; 616 return spectrum_cs_config(link);
619 p_dev->instance = link;
620
621 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
622 spectrum_cs_config(link);
623
624 return 0;
625} /* spectrum_cs_attach */ 617} /* spectrum_cs_attach */
626 618
627/* 619/*
@@ -630,16 +622,14 @@ spectrum_cs_attach(struct pcmcia_device *p_dev)
630 * are freed. Otherwise, the structures will be freed when the device 622 * are freed. Otherwise, the structures will be freed when the device
631 * is released. 623 * is released.
632 */ 624 */
633static void spectrum_cs_detach(struct pcmcia_device *p_dev) 625static void spectrum_cs_detach(struct pcmcia_device *link)
634{ 626{
635 dev_link_t *link = dev_to_instance(p_dev);
636 struct net_device *dev = link->priv; 627 struct net_device *dev = link->priv;
637 628
638 if (link->state & DEV_CONFIG) 629 spectrum_cs_release(link);
639 spectrum_cs_release(link);
640 630
641 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); 631 DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node);
642 if (link->dev) { 632 if (link->dev_node) {
643 DEBUG(0, PFX "About to unregister net device %p\n", 633 DEBUG(0, PFX "About to unregister net device %p\n",
644 dev); 634 dev);
645 unregister_netdev(dev); 635 unregister_netdev(dev);
@@ -653,11 +643,10 @@ static void spectrum_cs_detach(struct pcmcia_device *p_dev)
653 * device available to the system. 643 * device available to the system.
654 */ 644 */
655 645
656static void 646static int
657spectrum_cs_config(dev_link_t *link) 647spectrum_cs_config(struct pcmcia_device *link)
658{ 648{
659 struct net_device *dev = link->priv; 649 struct net_device *dev = link->priv;
660 client_handle_t handle = link->handle;
661 struct orinoco_private *priv = netdev_priv(dev); 650 struct orinoco_private *priv = netdev_priv(dev);
662 struct orinoco_pccard *card = priv->card; 651 struct orinoco_pccard *card = priv->card;
663 hermes_t *hw = &priv->hw; 652 hermes_t *hw = &priv->hw;
@@ -669,7 +658,7 @@ spectrum_cs_config(dev_link_t *link)
669 cisparse_t parse; 658 cisparse_t parse;
670 void __iomem *mem; 659 void __iomem *mem;
671 660
672 CS_CHECK(ValidateCIS, pcmcia_validate_cis(handle, &info)); 661 CS_CHECK(ValidateCIS, pcmcia_validate_cis(link, &info));
673 662
674 /* 663 /*
675 * This reads the card's CONFIG tuple to find its 664 * This reads the card's CONFIG tuple to find its
@@ -680,19 +669,15 @@ spectrum_cs_config(dev_link_t *link)
680 tuple.TupleData = buf; 669 tuple.TupleData = buf;
681 tuple.TupleDataMax = sizeof(buf); 670 tuple.TupleDataMax = sizeof(buf);
682 tuple.TupleOffset = 0; 671 tuple.TupleOffset = 0;
683 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 672 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
684 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 673 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
685 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 674 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
686 link->conf.ConfigBase = parse.config.base; 675 link->conf.ConfigBase = parse.config.base;
687 link->conf.Present = parse.config.rmask[0]; 676 link->conf.Present = parse.config.rmask[0];
688 677
689 /* Configure card */
690 link->state |= DEV_CONFIG;
691
692 /* Look up the current Vcc */ 678 /* Look up the current Vcc */
693 CS_CHECK(GetConfigurationInfo, 679 CS_CHECK(GetConfigurationInfo,
694 pcmcia_get_configuration_info(handle, &conf)); 680 pcmcia_get_configuration_info(link, &conf));
695 link->conf.Vcc = conf.Vcc;
696 681
697 /* 682 /*
698 * In this loop, we scan the CIS for configuration table 683 * In this loop, we scan the CIS for configuration table
@@ -709,13 +694,13 @@ spectrum_cs_config(dev_link_t *link)
709 * implementation-defined details. 694 * implementation-defined details.
710 */ 695 */
711 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 696 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
712 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 697 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
713 while (1) { 698 while (1) {
714 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 699 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
715 cistpl_cftable_entry_t dflt = { .index = 0 }; 700 cistpl_cftable_entry_t dflt = { .index = 0 };
716 701
717 if ( (pcmcia_get_tuple_data(handle, &tuple) != 0) 702 if ( (pcmcia_get_tuple_data(link, &tuple) != 0)
718 || (pcmcia_parse_tuple(handle, &tuple, &parse) != 0)) 703 || (pcmcia_parse_tuple(link, &tuple, &parse) != 0))
719 goto next_entry; 704 goto next_entry;
720 705
721 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) 706 if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
@@ -747,10 +732,10 @@ spectrum_cs_config(dev_link_t *link)
747 } 732 }
748 733
749 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 734 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
750 link->conf.Vpp1 = link->conf.Vpp2 = 735 link->conf.Vpp =
751 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 736 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
752 else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) 737 else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))
753 link->conf.Vpp1 = link->conf.Vpp2 = 738 link->conf.Vpp =
754 dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; 739 dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;
755 740
756 /* Do we need to allocate an interrupt? */ 741 /* Do we need to allocate an interrupt? */
@@ -780,7 +765,7 @@ spectrum_cs_config(dev_link_t *link)
780 } 765 }
781 766
782 /* This reserves IO space but doesn't actually enable it */ 767 /* This reserves IO space but doesn't actually enable it */
783 if (pcmcia_request_io(link->handle, &link->io) != 0) 768 if (pcmcia_request_io(link, &link->io) != 0)
784 goto next_entry; 769 goto next_entry;
785 } 770 }
786 771
@@ -790,9 +775,8 @@ spectrum_cs_config(dev_link_t *link)
790 break; 775 break;
791 776
792 next_entry: 777 next_entry:
793 if (link->io.NumPorts1) 778 pcmcia_disable_device(link);
794 pcmcia_release_io(link->handle, &link->io); 779 last_ret = pcmcia_get_next_tuple(link, &tuple);
795 last_ret = pcmcia_get_next_tuple(handle, &tuple);
796 if (last_ret == CS_NO_MORE_ITEMS) { 780 if (last_ret == CS_NO_MORE_ITEMS) {
797 printk(KERN_ERR PFX "GetNextTuple(): No matching " 781 printk(KERN_ERR PFX "GetNextTuple(): No matching "
798 "CIS configuration. Maybe you need the " 782 "CIS configuration. Maybe you need the "
@@ -806,7 +790,7 @@ spectrum_cs_config(dev_link_t *link)
806 * a handler to the interrupt, unless the 'Handler' member of 790 * a handler to the interrupt, unless the 'Handler' member of
807 * the irq structure is initialized. 791 * the irq structure is initialized.
808 */ 792 */
809 CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 793 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
810 794
811 /* We initialize the hermes structure before completing PCMCIA 795 /* We initialize the hermes structure before completing PCMCIA
812 * configuration just in case the interrupt handler gets 796 * configuration just in case the interrupt handler gets
@@ -823,7 +807,7 @@ spectrum_cs_config(dev_link_t *link)
823 * card and host interface into "Memory and IO" mode. 807 * card and host interface into "Memory and IO" mode.
824 */ 808 */
825 CS_CHECK(RequestConfiguration, 809 CS_CHECK(RequestConfiguration,
826 pcmcia_request_configuration(link->handle, &link->conf)); 810 pcmcia_request_configuration(link, &link->conf));
827 811
828 /* Ok, we have the configuration, prepare to register the netdev */ 812 /* Ok, we have the configuration, prepare to register the netdev */
829 dev->base_addr = link->io.BasePort1; 813 dev->base_addr = link->io.BasePort1;
@@ -836,7 +820,7 @@ spectrum_cs_config(dev_link_t *link)
836 goto failed; 820 goto failed;
837 } 821 }
838 822
839 SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 823 SET_NETDEV_DEV(dev, &handle_to_dev(link));
840 /* Tell the stack we exist */ 824 /* Tell the stack we exist */
841 if (register_netdev(dev) != 0) { 825 if (register_netdev(dev) != 0) {
842 printk(KERN_ERR PFX "register_netdev() failed\n"); 826 printk(KERN_ERR PFX "register_netdev() failed\n");
@@ -844,20 +828,18 @@ spectrum_cs_config(dev_link_t *link)
844 } 828 }
845 829
846 /* At this point, the dev_node_t structure(s) needs to be 830 /* At this point, the dev_node_t structure(s) needs to be
847 * initialized and arranged in a linked list at link->dev. */ 831 * initialized and arranged in a linked list at link->dev_node. */
848 strcpy(card->node.dev_name, dev->name); 832 strcpy(card->node.dev_name, dev->name);
849 link->dev = &card->node; /* link->dev being non-NULL is also 833 link->dev_node = &card->node; /* link->dev_node being non-NULL is also
850 used to indicate that the 834 used to indicate that the
851 net_device has been registered */ 835 net_device has been registered */
852 link->state &= ~DEV_CONFIG_PENDING;
853 836
854 /* Finally, report what we've done */ 837 /* Finally, report what we've done */
855 printk(KERN_DEBUG "%s: index 0x%02x: Vcc %d.%d", 838 printk(KERN_DEBUG "%s: index 0x%02x: ",
856 dev->name, link->conf.ConfigIndex, 839 dev->name, link->conf.ConfigIndex);
857 link->conf.Vcc / 10, link->conf.Vcc % 10); 840 if (link->conf.Vpp)
858 if (link->conf.Vpp1) 841 printk(", Vpp %d.%d", link->conf.Vpp / 10,
859 printk(", Vpp %d.%d", link->conf.Vpp1 / 10, 842 link->conf.Vpp % 10);
860 link->conf.Vpp1 % 10);
861 printk(", irq %d", link->irq.AssignedIRQ); 843 printk(", irq %d", link->irq.AssignedIRQ);
862 if (link->io.NumPorts1) 844 if (link->io.NumPorts1)
863 printk(", io 0x%04x-0x%04x", link->io.BasePort1, 845 printk(", io 0x%04x-0x%04x", link->io.BasePort1,
@@ -867,13 +849,14 @@ spectrum_cs_config(dev_link_t *link)
867 link->io.BasePort2 + link->io.NumPorts2 - 1); 849 link->io.BasePort2 + link->io.NumPorts2 - 1);
868 printk("\n"); 850 printk("\n");
869 851
870 return; 852 return 0;
871 853
872 cs_failed: 854 cs_failed:
873 cs_error(link->handle, last_fn, last_ret); 855 cs_error(link, last_fn, last_ret);
874 856
875 failed: 857 failed:
876 spectrum_cs_release(link); 858 spectrum_cs_release(link);
859 return -ENODEV;
877} /* spectrum_cs_config */ 860} /* spectrum_cs_config */
878 861
879/* 862/*
@@ -882,7 +865,7 @@ spectrum_cs_config(dev_link_t *link)
882 * still open, this will be postponed until it is closed. 865 * still open, this will be postponed until it is closed.
883 */ 866 */
884static void 867static void
885spectrum_cs_release(dev_link_t *link) 868spectrum_cs_release(struct pcmcia_device *link)
886{ 869{
887 struct net_device *dev = link->priv; 870 struct net_device *dev = link->priv;
888 struct orinoco_private *priv = netdev_priv(dev); 871 struct orinoco_private *priv = netdev_priv(dev);
@@ -894,64 +877,46 @@ spectrum_cs_release(dev_link_t *link)
894 priv->hw_unavailable++; 877 priv->hw_unavailable++;
895 spin_unlock_irqrestore(&priv->lock, flags); 878 spin_unlock_irqrestore(&priv->lock, flags);
896 879
897 /* Don't bother checking to see if these succeed or not */ 880 pcmcia_disable_device(link);
898 pcmcia_release_configuration(link->handle);
899 if (link->io.NumPorts1)
900 pcmcia_release_io(link->handle, &link->io);
901 if (link->irq.AssignedIRQ)
902 pcmcia_release_irq(link->handle, &link->irq);
903 link->state &= ~DEV_CONFIG;
904 if (priv->hw.iobase) 881 if (priv->hw.iobase)
905 ioport_unmap(priv->hw.iobase); 882 ioport_unmap(priv->hw.iobase);
906} /* spectrum_cs_release */ 883} /* spectrum_cs_release */
907 884
908 885
909static int 886static int
910spectrum_cs_suspend(struct pcmcia_device *p_dev) 887spectrum_cs_suspend(struct pcmcia_device *link)
911{ 888{
912 dev_link_t *link = dev_to_instance(p_dev);
913 struct net_device *dev = link->priv; 889 struct net_device *dev = link->priv;
914 struct orinoco_private *priv = netdev_priv(dev); 890 struct orinoco_private *priv = netdev_priv(dev);
915 unsigned long flags; 891 unsigned long flags;
916 int err = 0; 892 int err = 0;
917 893
918 link->state |= DEV_SUSPEND;
919 /* Mark the device as stopped, to block IO until later */ 894 /* Mark the device as stopped, to block IO until later */
920 if (link->state & DEV_CONFIG) { 895 spin_lock_irqsave(&priv->lock, flags);
921 spin_lock_irqsave(&priv->lock, flags);
922
923 err = __orinoco_down(dev);
924 if (err)
925 printk(KERN_WARNING "%s: Error %d downing interface\n",
926 dev->name, err);
927 896
928 netif_device_detach(dev); 897 err = __orinoco_down(dev);
929 priv->hw_unavailable++; 898 if (err)
899 printk(KERN_WARNING "%s: Error %d downing interface\n",
900 dev->name, err);
930 901
931 spin_unlock_irqrestore(&priv->lock, flags); 902 netif_device_detach(dev);
903 priv->hw_unavailable++;
932 904
933 pcmcia_release_configuration(link->handle); 905 spin_unlock_irqrestore(&priv->lock, flags);
934 }
935 906
936 return 0; 907 return 0;
937} 908}
938 909
939static int 910static int
940spectrum_cs_resume(struct pcmcia_device *p_dev) 911spectrum_cs_resume(struct pcmcia_device *link)
941{ 912{
942 dev_link_t *link = dev_to_instance(p_dev);
943 struct net_device *dev = link->priv; 913 struct net_device *dev = link->priv;
944 struct orinoco_private *priv = netdev_priv(dev); 914 struct orinoco_private *priv = netdev_priv(dev);
945 915
946 link->state &= ~DEV_SUSPEND; 916 netif_device_attach(dev);
947 if (link->state & DEV_CONFIG) { 917 priv->hw_unavailable--;
948 /* FIXME: should we double check that this is 918 schedule_work(&priv->reset_work);
949 * the same card as we had before */ 919
950 pcmcia_request_configuration(link->handle, &link->conf);
951 netif_device_attach(dev);
952 priv->hw_unavailable--;
953 schedule_work(&priv->reset_work);
954 }
955 return 0; 920 return 0;
956} 921}
957 922
@@ -979,7 +944,7 @@ static struct pcmcia_driver orinoco_driver = {
979 .drv = { 944 .drv = {
980 .name = DRIVER_NAME, 945 .name = DRIVER_NAME,
981 }, 946 },
982 .probe = spectrum_cs_attach, 947 .probe = spectrum_cs_probe,
983 .remove = spectrum_cs_detach, 948 .remove = spectrum_cs_detach,
984 .suspend = spectrum_cs_suspend, 949 .suspend = spectrum_cs_suspend,
985 .resume = spectrum_cs_resume, 950 .resume = spectrum_cs_resume,
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index 98122f3a4bc2..f7724eb2fa7e 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -1005,7 +1005,7 @@ static inline void
1005wv_82593_reconfig(struct net_device * dev) 1005wv_82593_reconfig(struct net_device * dev)
1006{ 1006{
1007 net_local * lp = netdev_priv(dev); 1007 net_local * lp = netdev_priv(dev);
1008 dev_link_t * link = lp->link; 1008 struct pcmcia_device * link = lp->link;
1009 unsigned long flags; 1009 unsigned long flags;
1010 1010
1011 /* Arm the flag, will be cleard in wv_82593_config() */ 1011 /* Arm the flag, will be cleard in wv_82593_config() */
@@ -3744,16 +3744,16 @@ wv_pcmcia_reset(struct net_device * dev)
3744{ 3744{
3745 int i; 3745 int i;
3746 conf_reg_t reg = { 0, CS_READ, CISREG_COR, 0 }; 3746 conf_reg_t reg = { 0, CS_READ, CISREG_COR, 0 };
3747 dev_link_t * link = ((net_local *)netdev_priv(dev))->link; 3747 struct pcmcia_device * link = ((net_local *)netdev_priv(dev))->link;
3748 3748
3749#ifdef DEBUG_CONFIG_TRACE 3749#ifdef DEBUG_CONFIG_TRACE
3750 printk(KERN_DEBUG "%s: ->wv_pcmcia_reset()\n", dev->name); 3750 printk(KERN_DEBUG "%s: ->wv_pcmcia_reset()\n", dev->name);
3751#endif 3751#endif
3752 3752
3753 i = pcmcia_access_configuration_register(link->handle, &reg); 3753 i = pcmcia_access_configuration_register(link, &reg);
3754 if(i != CS_SUCCESS) 3754 if(i != CS_SUCCESS)
3755 { 3755 {
3756 cs_error(link->handle, AccessConfigurationRegister, i); 3756 cs_error(link, AccessConfigurationRegister, i);
3757 return FALSE; 3757 return FALSE;
3758 } 3758 }
3759 3759
@@ -3764,19 +3764,19 @@ wv_pcmcia_reset(struct net_device * dev)
3764 3764
3765 reg.Action = CS_WRITE; 3765 reg.Action = CS_WRITE;
3766 reg.Value = reg.Value | COR_SW_RESET; 3766 reg.Value = reg.Value | COR_SW_RESET;
3767 i = pcmcia_access_configuration_register(link->handle, &reg); 3767 i = pcmcia_access_configuration_register(link, &reg);
3768 if(i != CS_SUCCESS) 3768 if(i != CS_SUCCESS)
3769 { 3769 {
3770 cs_error(link->handle, AccessConfigurationRegister, i); 3770 cs_error(link, AccessConfigurationRegister, i);
3771 return FALSE; 3771 return FALSE;
3772 } 3772 }
3773 3773
3774 reg.Action = CS_WRITE; 3774 reg.Action = CS_WRITE;
3775 reg.Value = COR_LEVEL_IRQ | COR_CONFIG; 3775 reg.Value = COR_LEVEL_IRQ | COR_CONFIG;
3776 i = pcmcia_access_configuration_register(link->handle, &reg); 3776 i = pcmcia_access_configuration_register(link, &reg);
3777 if(i != CS_SUCCESS) 3777 if(i != CS_SUCCESS)
3778 { 3778 {
3779 cs_error(link->handle, AccessConfigurationRegister, i); 3779 cs_error(link, AccessConfigurationRegister, i);
3780 return FALSE; 3780 return FALSE;
3781 } 3781 }
3782 3782
@@ -3940,9 +3940,8 @@ wv_hw_reset(struct net_device * dev)
3940 * (called by wavelan_event()) 3940 * (called by wavelan_event())
3941 */ 3941 */
3942static inline int 3942static inline int
3943wv_pcmcia_config(dev_link_t * link) 3943wv_pcmcia_config(struct pcmcia_device * link)
3944{ 3944{
3945 client_handle_t handle = link->handle;
3946 tuple_t tuple; 3945 tuple_t tuple;
3947 cisparse_t parse; 3946 cisparse_t parse;
3948 struct net_device * dev = (struct net_device *) link->priv; 3947 struct net_device * dev = (struct net_device *) link->priv;
@@ -3965,16 +3964,16 @@ wv_pcmcia_config(dev_link_t * link)
3965 { 3964 {
3966 tuple.Attributes = 0; 3965 tuple.Attributes = 0;
3967 tuple.DesiredTuple = CISTPL_CONFIG; 3966 tuple.DesiredTuple = CISTPL_CONFIG;
3968 i = pcmcia_get_first_tuple(handle, &tuple); 3967 i = pcmcia_get_first_tuple(link, &tuple);
3969 if(i != CS_SUCCESS) 3968 if(i != CS_SUCCESS)
3970 break; 3969 break;
3971 tuple.TupleData = (cisdata_t *)buf; 3970 tuple.TupleData = (cisdata_t *)buf;
3972 tuple.TupleDataMax = 64; 3971 tuple.TupleDataMax = 64;
3973 tuple.TupleOffset = 0; 3972 tuple.TupleOffset = 0;
3974 i = pcmcia_get_tuple_data(handle, &tuple); 3973 i = pcmcia_get_tuple_data(link, &tuple);
3975 if(i != CS_SUCCESS) 3974 if(i != CS_SUCCESS)
3976 break; 3975 break;
3977 i = pcmcia_parse_tuple(handle, &tuple, &parse); 3976 i = pcmcia_parse_tuple(link, &tuple, &parse);
3978 if(i != CS_SUCCESS) 3977 if(i != CS_SUCCESS)
3979 break; 3978 break;
3980 link->conf.ConfigBase = parse.config.base; 3979 link->conf.ConfigBase = parse.config.base;
@@ -3983,19 +3982,16 @@ wv_pcmcia_config(dev_link_t * link)
3983 while(0); 3982 while(0);
3984 if(i != CS_SUCCESS) 3983 if(i != CS_SUCCESS)
3985 { 3984 {
3986 cs_error(link->handle, ParseTuple, i); 3985 cs_error(link, ParseTuple, i);
3987 link->state &= ~DEV_CONFIG_PENDING;
3988 return FALSE; 3986 return FALSE;
3989 } 3987 }
3990 3988
3991 /* Configure card */
3992 link->state |= DEV_CONFIG;
3993 do 3989 do
3994 { 3990 {
3995 i = pcmcia_request_io(link->handle, &link->io); 3991 i = pcmcia_request_io(link, &link->io);
3996 if(i != CS_SUCCESS) 3992 if(i != CS_SUCCESS)
3997 { 3993 {
3998 cs_error(link->handle, RequestIO, i); 3994 cs_error(link, RequestIO, i);
3999 break; 3995 break;
4000 } 3996 }
4001 3997
@@ -4003,10 +3999,10 @@ wv_pcmcia_config(dev_link_t * link)
4003 * Now allocate an interrupt line. Note that this does not 3999 * Now allocate an interrupt line. Note that this does not
4004 * actually assign a handler to the interrupt. 4000 * actually assign a handler to the interrupt.
4005 */ 4001 */
4006 i = pcmcia_request_irq(link->handle, &link->irq); 4002 i = pcmcia_request_irq(link, &link->irq);
4007 if(i != CS_SUCCESS) 4003 if(i != CS_SUCCESS)
4008 { 4004 {
4009 cs_error(link->handle, RequestIRQ, i); 4005 cs_error(link, RequestIRQ, i);
4010 break; 4006 break;
4011 } 4007 }
4012 4008
@@ -4015,15 +4011,15 @@ wv_pcmcia_config(dev_link_t * link)
4015 * the I/O windows and the interrupt mapping. 4011 * the I/O windows and the interrupt mapping.
4016 */ 4012 */
4017 link->conf.ConfigIndex = 1; 4013 link->conf.ConfigIndex = 1;
4018 i = pcmcia_request_configuration(link->handle, &link->conf); 4014 i = pcmcia_request_configuration(link, &link->conf);
4019 if(i != CS_SUCCESS) 4015 if(i != CS_SUCCESS)
4020 { 4016 {
4021 cs_error(link->handle, RequestConfiguration, i); 4017 cs_error(link, RequestConfiguration, i);
4022 break; 4018 break;
4023 } 4019 }
4024 4020
4025 /* 4021 /*
4026 * Allocate a small memory window. Note that the dev_link_t 4022 * Allocate a small memory window. Note that the struct pcmcia_device
4027 * structure provides space for one window handle -- if your 4023 * structure provides space for one window handle -- if your
4028 * device needs several windows, you'll need to keep track of 4024 * device needs several windows, you'll need to keep track of
4029 * the handles in your private data structure, link->priv. 4025 * the handles in your private data structure, link->priv.
@@ -4031,10 +4027,10 @@ wv_pcmcia_config(dev_link_t * link)
4031 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 4027 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
4032 req.Base = req.Size = 0; 4028 req.Base = req.Size = 0;
4033 req.AccessSpeed = mem_speed; 4029 req.AccessSpeed = mem_speed;
4034 i = pcmcia_request_window(&link->handle, &req, &link->win); 4030 i = pcmcia_request_window(&link, &req, &link->win);
4035 if(i != CS_SUCCESS) 4031 if(i != CS_SUCCESS)
4036 { 4032 {
4037 cs_error(link->handle, RequestWindow, i); 4033 cs_error(link, RequestWindow, i);
4038 break; 4034 break;
4039 } 4035 }
4040 4036
@@ -4046,7 +4042,7 @@ wv_pcmcia_config(dev_link_t * link)
4046 i = pcmcia_map_mem_page(link->win, &mem); 4042 i = pcmcia_map_mem_page(link->win, &mem);
4047 if(i != CS_SUCCESS) 4043 if(i != CS_SUCCESS)
4048 { 4044 {
4049 cs_error(link->handle, MapMemPage, i); 4045 cs_error(link, MapMemPage, i);
4050 break; 4046 break;
4051 } 4047 }
4052 4048
@@ -4060,7 +4056,7 @@ wv_pcmcia_config(dev_link_t * link)
4060 lp->mem, dev->irq, (u_int) dev->base_addr); 4056 lp->mem, dev->irq, (u_int) dev->base_addr);
4061#endif 4057#endif
4062 4058
4063 SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 4059 SET_NETDEV_DEV(dev, &handle_to_dev(link));
4064 i = register_netdev(dev); 4060 i = register_netdev(dev);
4065 if(i != 0) 4061 if(i != 0)
4066 { 4062 {
@@ -4072,7 +4068,6 @@ wv_pcmcia_config(dev_link_t * link)
4072 } 4068 }
4073 while(0); /* Humm... Disguised goto !!! */ 4069 while(0); /* Humm... Disguised goto !!! */
4074 4070
4075 link->state &= ~DEV_CONFIG_PENDING;
4076 /* If any step failed, release any partially configured state */ 4071 /* If any step failed, release any partially configured state */
4077 if(i != 0) 4072 if(i != 0)
4078 { 4073 {
@@ -4081,7 +4076,7 @@ wv_pcmcia_config(dev_link_t * link)
4081 } 4076 }
4082 4077
4083 strcpy(((net_local *) netdev_priv(dev))->node.dev_name, dev->name); 4078 strcpy(((net_local *) netdev_priv(dev))->node.dev_name, dev->name);
4084 link->dev = &((net_local *) netdev_priv(dev))->node; 4079 link->dev_node = &((net_local *) netdev_priv(dev))->node;
4085 4080
4086#ifdef DEBUG_CONFIG_TRACE 4081#ifdef DEBUG_CONFIG_TRACE
4087 printk(KERN_DEBUG "<-wv_pcmcia_config()\n"); 4082 printk(KERN_DEBUG "<-wv_pcmcia_config()\n");
@@ -4096,26 +4091,20 @@ wv_pcmcia_config(dev_link_t * link)
4096 * still open, this will be postponed until it is closed. 4091 * still open, this will be postponed until it is closed.
4097 */ 4092 */
4098static void 4093static void
4099wv_pcmcia_release(dev_link_t *link) 4094wv_pcmcia_release(struct pcmcia_device *link)
4100{ 4095{
4101 struct net_device * dev = (struct net_device *) link->priv; 4096 struct net_device * dev = (struct net_device *) link->priv;
4102 net_local * lp = netdev_priv(dev); 4097 net_local * lp = netdev_priv(dev);
4103 4098
4104#ifdef DEBUG_CONFIG_TRACE 4099#ifdef DEBUG_CONFIG_TRACE
4105 printk(KERN_DEBUG "%s: -> wv_pcmcia_release(0x%p)\n", dev->name, link); 4100 printk(KERN_DEBUG "%s: -> wv_pcmcia_release(0x%p)\n", dev->name, link);
4106#endif 4101#endif
4107 4102
4108 /* Don't bother checking to see if these succeed or not */ 4103 iounmap(lp->mem);
4109 iounmap(lp->mem); 4104 pcmcia_disable_device(link);
4110 pcmcia_release_window(link->win);
4111 pcmcia_release_configuration(link->handle);
4112 pcmcia_release_io(link->handle, &link->io);
4113 pcmcia_release_irq(link->handle, &link->irq);
4114
4115 link->state &= ~DEV_CONFIG;
4116 4105
4117#ifdef DEBUG_CONFIG_TRACE 4106#ifdef DEBUG_CONFIG_TRACE
4118 printk(KERN_DEBUG "%s: <- wv_pcmcia_release()\n", dev->name); 4107 printk(KERN_DEBUG "%s: <- wv_pcmcia_release()\n", dev->name);
4119#endif 4108#endif
4120} 4109}
4121 4110
@@ -4479,7 +4468,7 @@ static int
4479wavelan_open(struct net_device * dev) 4468wavelan_open(struct net_device * dev)
4480{ 4469{
4481 net_local * lp = netdev_priv(dev); 4470 net_local * lp = netdev_priv(dev);
4482 dev_link_t * link = lp->link; 4471 struct pcmcia_device * link = lp->link;
4483 kio_addr_t base = dev->base_addr; 4472 kio_addr_t base = dev->base_addr;
4484 4473
4485#ifdef DEBUG_CALLBACK_TRACE 4474#ifdef DEBUG_CALLBACK_TRACE
@@ -4533,7 +4522,7 @@ wavelan_open(struct net_device * dev)
4533static int 4522static int
4534wavelan_close(struct net_device * dev) 4523wavelan_close(struct net_device * dev)
4535{ 4524{
4536 dev_link_t * link = ((net_local *)netdev_priv(dev))->link; 4525 struct pcmcia_device * link = ((net_local *)netdev_priv(dev))->link;
4537 kio_addr_t base = dev->base_addr; 4526 kio_addr_t base = dev->base_addr;
4538 4527
4539#ifdef DEBUG_CALLBACK_TRACE 4528#ifdef DEBUG_CALLBACK_TRACE
@@ -4587,45 +4576,36 @@ wavelan_close(struct net_device * dev)
4587 * card insertion event. 4576 * card insertion event.
4588 */ 4577 */
4589static int 4578static int
4590wavelan_attach(struct pcmcia_device *p_dev) 4579wavelan_probe(struct pcmcia_device *p_dev)
4591{ 4580{
4592 dev_link_t * link; /* Info for cardmgr */
4593 struct net_device * dev; /* Interface generic data */ 4581 struct net_device * dev; /* Interface generic data */
4594 net_local * lp; /* Interface specific data */ 4582 net_local * lp; /* Interface specific data */
4583 int ret;
4595 4584
4596#ifdef DEBUG_CALLBACK_TRACE 4585#ifdef DEBUG_CALLBACK_TRACE
4597 printk(KERN_DEBUG "-> wavelan_attach()\n"); 4586 printk(KERN_DEBUG "-> wavelan_attach()\n");
4598#endif 4587#endif
4599 4588
4600 /* Initialize the dev_link_t structure */
4601 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL);
4602 if (!link) return -ENOMEM;
4603
4604 /* The io structure describes IO port mapping */ 4589 /* The io structure describes IO port mapping */
4605 link->io.NumPorts1 = 8; 4590 p_dev->io.NumPorts1 = 8;
4606 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 4591 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
4607 link->io.IOAddrLines = 3; 4592 p_dev->io.IOAddrLines = 3;
4608 4593
4609 /* Interrupt setup */ 4594 /* Interrupt setup */
4610 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 4595 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
4611 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 4596 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
4612 link->irq.Handler = wavelan_interrupt; 4597 p_dev->irq.Handler = wavelan_interrupt;
4613 4598
4614 /* General socket configuration */ 4599 /* General socket configuration */
4615 link->conf.Attributes = CONF_ENABLE_IRQ; 4600 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
4616 link->conf.Vcc = 50; 4601 p_dev->conf.IntType = INT_MEMORY_AND_IO;
4617 link->conf.IntType = INT_MEMORY_AND_IO;
4618
4619 /* Chain drivers */
4620 link->next = NULL;
4621 4602
4622 /* Allocate the generic data structure */ 4603 /* Allocate the generic data structure */
4623 dev = alloc_etherdev(sizeof(net_local)); 4604 dev = alloc_etherdev(sizeof(net_local));
4624 if (!dev) { 4605 if (!dev)
4625 kfree(link);
4626 return -ENOMEM; 4606 return -ENOMEM;
4627 } 4607
4628 link->priv = link->irq.Instance = dev; 4608 p_dev->priv = p_dev->irq.Instance = dev;
4629 4609
4630 lp = netdev_priv(dev); 4610 lp = netdev_priv(dev);
4631 4611
@@ -4642,7 +4622,6 @@ wavelan_attach(struct pcmcia_device *p_dev)
4642 spin_lock_init(&lp->spinlock); 4622 spin_lock_init(&lp->spinlock);
4643 4623
4644 /* back links */ 4624 /* back links */
4645 lp->link = link;
4646 lp->dev = dev; 4625 lp->dev = dev;
4647 4626
4648 /* wavelan NET3 callbacks */ 4627 /* wavelan NET3 callbacks */
@@ -4668,15 +4647,18 @@ wavelan_attach(struct pcmcia_device *p_dev)
4668 /* Other specific data */ 4647 /* Other specific data */
4669 dev->mtu = WAVELAN_MTU; 4648 dev->mtu = WAVELAN_MTU;
4670 4649
4671 link->handle = p_dev; 4650 ret = wv_pcmcia_config(p_dev);
4672 p_dev->instance = link; 4651 if (ret)
4652 return ret;
4673 4653
4674 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 4654 ret = wv_hw_config(dev);
4675 if(wv_pcmcia_config(link) && 4655 if (ret) {
4676 wv_hw_config(dev))
4677 wv_init_info(dev);
4678 else
4679 dev->irq = 0; 4656 dev->irq = 0;
4657 pcmcia_disable_device(p_dev);
4658 return ret;
4659 }
4660
4661 wv_init_info(dev);
4680 4662
4681#ifdef DEBUG_CALLBACK_TRACE 4663#ifdef DEBUG_CALLBACK_TRACE
4682 printk(KERN_DEBUG "<- wavelan_attach()\n"); 4664 printk(KERN_DEBUG "<- wavelan_attach()\n");
@@ -4693,25 +4675,14 @@ wavelan_attach(struct pcmcia_device *p_dev)
4693 * is released. 4675 * is released.
4694 */ 4676 */
4695static void 4677static void
4696wavelan_detach(struct pcmcia_device *p_dev) 4678wavelan_detach(struct pcmcia_device *link)
4697{ 4679{
4698 dev_link_t *link = dev_to_instance(p_dev);
4699
4700#ifdef DEBUG_CALLBACK_TRACE 4680#ifdef DEBUG_CALLBACK_TRACE
4701 printk(KERN_DEBUG "-> wavelan_detach(0x%p)\n", link); 4681 printk(KERN_DEBUG "-> wavelan_detach(0x%p)\n", link);
4702#endif 4682#endif
4703 4683
4704 /* 4684 /* Some others haven't done their job : give them another chance */
4705 * If the device is currently configured and active, we won't 4685 wv_pcmcia_release(link);
4706 * actually delete it yet. Instead, it is marked so that when the
4707 * release() function is called, that will trigger a proper
4708 * detach().
4709 */
4710 if(link->state & DEV_CONFIG)
4711 {
4712 /* Some others haven't done their job : give them another chance */
4713 wv_pcmcia_release(link);
4714 }
4715 4686
4716 /* Free pieces */ 4687 /* Free pieces */
4717 if(link->priv) 4688 if(link->priv)
@@ -4720,23 +4691,21 @@ wavelan_detach(struct pcmcia_device *p_dev)
4720 4691
4721 /* Remove ourselves from the kernel list of ethernet devices */ 4692 /* Remove ourselves from the kernel list of ethernet devices */
4722 /* Warning : can't be called from interrupt, timer or wavelan_close() */ 4693 /* Warning : can't be called from interrupt, timer or wavelan_close() */
4723 if (link->dev) 4694 if (link->dev_node)
4724 unregister_netdev(dev); 4695 unregister_netdev(dev);
4725 link->dev = NULL; 4696 link->dev_node = NULL;
4726 ((net_local *)netdev_priv(dev))->link = NULL; 4697 ((net_local *)netdev_priv(dev))->link = NULL;
4727 ((net_local *)netdev_priv(dev))->dev = NULL; 4698 ((net_local *)netdev_priv(dev))->dev = NULL;
4728 free_netdev(dev); 4699 free_netdev(dev);
4729 } 4700 }
4730 kfree(link);
4731 4701
4732#ifdef DEBUG_CALLBACK_TRACE 4702#ifdef DEBUG_CALLBACK_TRACE
4733 printk(KERN_DEBUG "<- wavelan_detach()\n"); 4703 printk(KERN_DEBUG "<- wavelan_detach()\n");
4734#endif 4704#endif
4735} 4705}
4736 4706
4737static int wavelan_suspend(struct pcmcia_device *p_dev) 4707static int wavelan_suspend(struct pcmcia_device *link)
4738{ 4708{
4739 dev_link_t *link = dev_to_instance(p_dev);
4740 struct net_device * dev = (struct net_device *) link->priv; 4709 struct net_device * dev = (struct net_device *) link->priv;
4741 4710
4742 /* NB: wavelan_close will be called, but too late, so we are 4711 /* NB: wavelan_close will be called, but too late, so we are
@@ -4748,36 +4717,22 @@ static int wavelan_suspend(struct pcmcia_device *p_dev)
4748 /* Stop receiving new messages and wait end of transmission */ 4717 /* Stop receiving new messages and wait end of transmission */
4749 wv_ru_stop(dev); 4718 wv_ru_stop(dev);
4750 4719
4720 if (link->open)
4721 netif_device_detach(dev);
4722
4751 /* Power down the module */ 4723 /* Power down the module */
4752 hacr_write(dev->base_addr, HACR_DEFAULT & (~HACR_PWR_STAT)); 4724 hacr_write(dev->base_addr, HACR_DEFAULT & (~HACR_PWR_STAT));
4753 4725
4754 /* The card is now suspended */
4755 link->state |= DEV_SUSPEND;
4756
4757 if(link->state & DEV_CONFIG)
4758 {
4759 if(link->open)
4760 netif_device_detach(dev);
4761 pcmcia_release_configuration(link->handle);
4762 }
4763
4764 return 0; 4726 return 0;
4765} 4727}
4766 4728
4767static int wavelan_resume(struct pcmcia_device *p_dev) 4729static int wavelan_resume(struct pcmcia_device *link)
4768{ 4730{
4769 dev_link_t *link = dev_to_instance(p_dev);
4770 struct net_device * dev = (struct net_device *) link->priv; 4731 struct net_device * dev = (struct net_device *) link->priv;
4771 4732
4772 link->state &= ~DEV_SUSPEND; 4733 if (link->open) {
4773 if(link->state & DEV_CONFIG) 4734 wv_hw_reset(dev);
4774 { 4735 netif_device_attach(dev);
4775 pcmcia_request_configuration(link->handle, &link->conf);
4776 if(link->open) /* If RESET -> True, If RESUME -> False ? */
4777 {
4778 wv_hw_reset(dev);
4779 netif_device_attach(dev);
4780 }
4781 } 4736 }
4782 4737
4783 return 0; 4738 return 0;
@@ -4798,7 +4753,7 @@ static struct pcmcia_driver wavelan_driver = {
4798 .drv = { 4753 .drv = {
4799 .name = "wavelan_cs", 4754 .name = "wavelan_cs",
4800 }, 4755 },
4801 .probe = wavelan_attach, 4756 .probe = wavelan_probe,
4802 .remove = wavelan_detach, 4757 .remove = wavelan_detach,
4803 .id_table = wavelan_ids, 4758 .id_table = wavelan_ids,
4804 .suspend = wavelan_suspend, 4759 .suspend = wavelan_suspend,
diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h
index 451f6271dcbc..c65fe7a391ec 100644
--- a/drivers/net/wireless/wavelan_cs.p.h
+++ b/drivers/net/wireless/wavelan_cs.p.h
@@ -602,7 +602,7 @@ struct net_local
602 dev_node_t node; /* ???? What is this stuff ???? */ 602 dev_node_t node; /* ???? What is this stuff ???? */
603 struct net_device * dev; /* Reverse link... */ 603 struct net_device * dev; /* Reverse link... */
604 spinlock_t spinlock; /* Serialize access to the hardware (SMP) */ 604 spinlock_t spinlock; /* Serialize access to the hardware (SMP) */
605 dev_link_t * link; /* pcmcia structure */ 605 struct pcmcia_device * link; /* pcmcia structure */
606 en_stats stats; /* Ethernet interface statistics */ 606 en_stats stats; /* Ethernet interface statistics */
607 int nresets; /* Number of hw resets */ 607 int nresets; /* Number of hw resets */
608 u_char configured; /* If it is configured */ 608 u_char configured; /* If it is configured */
@@ -733,9 +733,9 @@ static int
733static inline void 733static inline void
734 wv_hw_reset(struct net_device *); /* Same, + start receiver unit */ 734 wv_hw_reset(struct net_device *); /* Same, + start receiver unit */
735static inline int 735static inline int
736 wv_pcmcia_config(dev_link_t *); /* Configure the pcmcia interface */ 736 wv_pcmcia_config(struct pcmcia_device *); /* Configure the pcmcia interface */
737static void 737static void
738 wv_pcmcia_release(dev_link_t *);/* Remove a device */ 738 wv_pcmcia_release(struct pcmcia_device *);/* Remove a device */
739/* ---------------------- INTERRUPT HANDLING ---------------------- */ 739/* ---------------------- INTERRUPT HANDLING ---------------------- */
740static irqreturn_t 740static irqreturn_t
741 wavelan_interrupt(int, /* Interrupt handler */ 741 wavelan_interrupt(int, /* Interrupt handler */
diff --git a/drivers/net/wireless/wl3501.h b/drivers/net/wireless/wl3501.h
index 4303c50c2ab6..65ceb088f700 100644
--- a/drivers/net/wireless/wl3501.h
+++ b/drivers/net/wireless/wl3501.h
@@ -611,5 +611,6 @@ struct wl3501_card {
611 struct iw_spy_data spy_data; 611 struct iw_spy_data spy_data;
612 struct iw_public_data wireless_data; 612 struct iw_public_data wireless_data;
613 struct dev_node_t node; 613 struct dev_node_t node;
614 struct pcmcia_device *p_dev;
614}; 615};
615#endif 616#endif
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index 48e10b0c7e74..e52a650f6737 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -103,8 +103,8 @@ module_param(pc_debug, int, 0);
103 * release a socket, in response to card insertion and ejection events. They 103 * release a socket, in response to card insertion and ejection events. They
104 * are invoked from the wl24 event handler. 104 * are invoked from the wl24 event handler.
105 */ 105 */
106static void wl3501_config(dev_link_t *link); 106static int wl3501_config(struct pcmcia_device *link);
107static void wl3501_release(dev_link_t *link); 107static void wl3501_release(struct pcmcia_device *link);
108 108
109/* 109/*
110 * The dev_info variable is the "key" that is used to match up this 110 * The dev_info variable is the "key" that is used to match up this
@@ -226,17 +226,6 @@ static void iw_copy_mgmt_info_element(struct iw_mgmt_info_element *to,
226 iw_set_mgmt_info_element(from->id, to, from->data, from->len); 226 iw_set_mgmt_info_element(from->id, to, from->data, from->len);
227} 227}
228 228
229/*
230 * A linked list of "instances" of the wl24 device. Each actual PCMCIA card
231 * corresponds to one device instance, and is described by one dev_link_t
232 * structure (defined in ds.h).
233 *
234 * You may not want to use a linked list for this -- for example, the memory
235 * card driver uses an array of dev_link_t pointers, where minor device numbers
236 * are used to derive the corresponding array index.
237 */
238static dev_link_t *wl3501_dev_list;
239
240static inline void wl3501_switch_page(struct wl3501_card *this, u8 page) 229static inline void wl3501_switch_page(struct wl3501_card *this, u8 page)
241{ 230{
242 wl3501_outb(page, this->base_addr + WL3501_NIC_BSS); 231 wl3501_outb(page, this->base_addr + WL3501_NIC_BSS);
@@ -1281,15 +1270,10 @@ static int wl3501_close(struct net_device *dev)
1281 struct wl3501_card *this = dev->priv; 1270 struct wl3501_card *this = dev->priv;
1282 int rc = -ENODEV; 1271 int rc = -ENODEV;
1283 unsigned long flags; 1272 unsigned long flags;
1284 dev_link_t *link; 1273 struct pcmcia_device *link;
1274 link = this->p_dev;
1285 1275
1286 spin_lock_irqsave(&this->lock, flags); 1276 spin_lock_irqsave(&this->lock, flags);
1287 /* Check if the device is in wl3501_dev_list */
1288 for (link = wl3501_dev_list; link; link = link->next)
1289 if (link->priv == dev)
1290 break;
1291 if (!link)
1292 goto out;
1293 link->open--; 1277 link->open--;
1294 1278
1295 /* Stop wl3501_hard_start_xmit() from now on */ 1279 /* Stop wl3501_hard_start_xmit() from now on */
@@ -1301,7 +1285,6 @@ static int wl3501_close(struct net_device *dev)
1301 1285
1302 rc = 0; 1286 rc = 0;
1303 printk(KERN_INFO "%s: WL3501 closed\n", dev->name); 1287 printk(KERN_INFO "%s: WL3501 closed\n", dev->name);
1304out:
1305 spin_unlock_irqrestore(&this->lock, flags); 1288 spin_unlock_irqrestore(&this->lock, flags);
1306 return rc; 1289 return rc;
1307} 1290}
@@ -1400,14 +1383,11 @@ static int wl3501_open(struct net_device *dev)
1400 int rc = -ENODEV; 1383 int rc = -ENODEV;
1401 struct wl3501_card *this = dev->priv; 1384 struct wl3501_card *this = dev->priv;
1402 unsigned long flags; 1385 unsigned long flags;
1403 dev_link_t *link; 1386 struct pcmcia_device *link;
1387 link = this->p_dev;
1404 1388
1405 spin_lock_irqsave(&this->lock, flags); 1389 spin_lock_irqsave(&this->lock, flags);
1406 /* Check if the device is in wl3501_dev_list */ 1390 if (!pcmcia_dev_present(link))
1407 for (link = wl3501_dev_list; link; link = link->next)
1408 if (link->priv == dev)
1409 break;
1410 if (!DEV_OK(link))
1411 goto out; 1391 goto out;
1412 netif_device_attach(dev); 1392 netif_device_attach(dev);
1413 link->open++; 1393 link->open++;
@@ -1497,38 +1477,23 @@ static struct ethtool_ops ops = {
1497 * Services. If it has been released, all local data structures are freed. 1477 * Services. If it has been released, all local data structures are freed.
1498 * Otherwise, the structures will be freed when the device is released. 1478 * Otherwise, the structures will be freed when the device is released.
1499 */ 1479 */
1500static void wl3501_detach(struct pcmcia_device *p_dev) 1480static void wl3501_detach(struct pcmcia_device *link)
1501{ 1481{
1502 dev_link_t *link = dev_to_instance(p_dev);
1503 dev_link_t **linkp;
1504 struct net_device *dev = link->priv; 1482 struct net_device *dev = link->priv;
1505 1483
1506 /* Locate device structure */
1507 for (linkp = &wl3501_dev_list; *linkp; linkp = &(*linkp)->next)
1508 if (*linkp == link)
1509 break;
1510 if (!*linkp)
1511 goto out;
1512
1513 /* If the device is currently configured and active, we won't actually 1484 /* If the device is currently configured and active, we won't actually
1514 * delete it yet. Instead, it is marked so that when the release() 1485 * delete it yet. Instead, it is marked so that when the release()
1515 * function is called, that will trigger a proper detach(). */ 1486 * function is called, that will trigger a proper detach(). */
1516 1487
1517 if (link->state & DEV_CONFIG) { 1488 while (link->open > 0)
1518 while (link->open > 0) 1489 wl3501_close(dev);
1519 wl3501_close(dev);
1520
1521 netif_device_detach(dev);
1522 wl3501_release(link);
1523 }
1524 1490
1525 /* Unlink device structure, free pieces */ 1491 netif_device_detach(dev);
1526 *linkp = link->next; 1492 wl3501_release(link);
1527 1493
1528 if (link->priv) 1494 if (link->priv)
1529 free_netdev(link->priv); 1495 free_netdev(link->priv);
1530 kfree(link); 1496
1531out:
1532 return; 1497 return;
1533} 1498}
1534 1499
@@ -1953,33 +1918,26 @@ static const struct iw_handler_def wl3501_handler_def = {
1953 * The dev_link structure is initialized, but we don't actually configure the 1918 * The dev_link structure is initialized, but we don't actually configure the
1954 * card at this point -- we wait until we receive a card insertion event. 1919 * card at this point -- we wait until we receive a card insertion event.
1955 */ 1920 */
1956static int wl3501_attach(struct pcmcia_device *p_dev) 1921static int wl3501_probe(struct pcmcia_device *p_dev)
1957{ 1922{
1958 dev_link_t *link;
1959 struct net_device *dev; 1923 struct net_device *dev;
1960 struct wl3501_card *this; 1924 struct wl3501_card *this;
1961 1925
1962 /* Initialize the dev_link_t structure */
1963 link = kzalloc(sizeof(*link), GFP_KERNEL);
1964 if (!link)
1965 return -ENOMEM;
1966
1967 /* The io structure describes IO port mapping */ 1926 /* The io structure describes IO port mapping */
1968 link->io.NumPorts1 = 16; 1927 p_dev->io.NumPorts1 = 16;
1969 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 1928 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
1970 link->io.IOAddrLines = 5; 1929 p_dev->io.IOAddrLines = 5;
1971 1930
1972 /* Interrupt setup */ 1931 /* Interrupt setup */
1973 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 1932 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
1974 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 1933 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
1975 link->irq.Handler = wl3501_interrupt; 1934 p_dev->irq.Handler = wl3501_interrupt;
1976 1935
1977 /* General socket configuration */ 1936 /* General socket configuration */
1978 link->conf.Attributes = CONF_ENABLE_IRQ; 1937 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
1979 link->conf.Vcc = 50; 1938 p_dev->conf.IntType = INT_MEMORY_AND_IO;
1980 link->conf.IntType = INT_MEMORY_AND_IO; 1939 p_dev->conf.ConfigIndex = 1;
1981 link->conf.ConfigIndex = 1; 1940 p_dev->conf.Present = PRESENT_OPTION;
1982 link->conf.Present = PRESENT_OPTION;
1983 1941
1984 dev = alloc_etherdev(sizeof(struct wl3501_card)); 1942 dev = alloc_etherdev(sizeof(struct wl3501_card));
1985 if (!dev) 1943 if (!dev)
@@ -1992,22 +1950,15 @@ static int wl3501_attach(struct pcmcia_device *p_dev)
1992 dev->get_stats = wl3501_get_stats; 1950 dev->get_stats = wl3501_get_stats;
1993 this = dev->priv; 1951 this = dev->priv;
1994 this->wireless_data.spy_data = &this->spy_data; 1952 this->wireless_data.spy_data = &this->spy_data;
1953 this->p_dev = p_dev;
1995 dev->wireless_data = &this->wireless_data; 1954 dev->wireless_data = &this->wireless_data;
1996 dev->wireless_handlers = (struct iw_handler_def *)&wl3501_handler_def; 1955 dev->wireless_handlers = (struct iw_handler_def *)&wl3501_handler_def;
1997 SET_ETHTOOL_OPS(dev, &ops); 1956 SET_ETHTOOL_OPS(dev, &ops);
1998 netif_stop_queue(dev); 1957 netif_stop_queue(dev);
1999 link->priv = link->irq.Instance = dev; 1958 p_dev->priv = p_dev->irq.Instance = dev;
2000
2001 link->handle = p_dev;
2002 p_dev->instance = link;
2003
2004 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
2005 wl3501_config(link);
2006 1959
2007 return 0; 1960 return wl3501_config(p_dev);
2008out_link: 1961out_link:
2009 kfree(link);
2010 link = NULL;
2011 return -ENOMEM; 1962 return -ENOMEM;
2012} 1963}
2013 1964
@@ -2022,11 +1973,10 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
2022 * received, to configure the PCMCIA socket, and to make the ethernet device 1973 * received, to configure the PCMCIA socket, and to make the ethernet device
2023 * available to the system. 1974 * available to the system.
2024 */ 1975 */
2025static void wl3501_config(dev_link_t *link) 1976static int wl3501_config(struct pcmcia_device *link)
2026{ 1977{
2027 tuple_t tuple; 1978 tuple_t tuple;
2028 cisparse_t parse; 1979 cisparse_t parse;
2029 client_handle_t handle = link->handle;
2030 struct net_device *dev = link->priv; 1980 struct net_device *dev = link->priv;
2031 int i = 0, j, last_fn, last_ret; 1981 int i = 0, j, last_fn, last_ret;
2032 unsigned char bf[64]; 1982 unsigned char bf[64];
@@ -2035,18 +1985,15 @@ static void wl3501_config(dev_link_t *link)
2035 /* This reads the card's CONFIG tuple to find its config registers. */ 1985 /* This reads the card's CONFIG tuple to find its config registers. */
2036 tuple.Attributes = 0; 1986 tuple.Attributes = 0;
2037 tuple.DesiredTuple = CISTPL_CONFIG; 1987 tuple.DesiredTuple = CISTPL_CONFIG;
2038 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 1988 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
2039 tuple.TupleData = bf; 1989 tuple.TupleData = bf;
2040 tuple.TupleDataMax = sizeof(bf); 1990 tuple.TupleDataMax = sizeof(bf);
2041 tuple.TupleOffset = 0; 1991 tuple.TupleOffset = 0;
2042 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 1992 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
2043 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 1993 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
2044 link->conf.ConfigBase = parse.config.base; 1994 link->conf.ConfigBase = parse.config.base;
2045 link->conf.Present = parse.config.rmask[0]; 1995 link->conf.Present = parse.config.rmask[0];
2046 1996
2047 /* Configure card */
2048 link->state |= DEV_CONFIG;
2049
2050 /* 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
2051 * 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 --
2052 * see the serial driver for an example. */ 1999 * see the serial driver for an example. */
@@ -2056,28 +2003,28 @@ static void wl3501_config(dev_link_t *link)
2056 * 0x200-0x2ff, and so on, because this seems safer */ 2003 * 0x200-0x2ff, and so on, because this seems safer */
2057 link->io.BasePort1 = j; 2004 link->io.BasePort1 = j;
2058 link->io.BasePort2 = link->io.BasePort1 + 0x10; 2005 link->io.BasePort2 = link->io.BasePort1 + 0x10;
2059 i = pcmcia_request_io(link->handle, &link->io); 2006 i = pcmcia_request_io(link, &link->io);
2060 if (i == CS_SUCCESS) 2007 if (i == CS_SUCCESS)
2061 break; 2008 break;
2062 } 2009 }
2063 if (i != CS_SUCCESS) { 2010 if (i != CS_SUCCESS) {
2064 cs_error(link->handle, RequestIO, i); 2011 cs_error(link, RequestIO, i);
2065 goto failed; 2012 goto failed;
2066 } 2013 }
2067 2014
2068 /* Now allocate an interrupt line. Note that this does not actually 2015 /* Now allocate an interrupt line. Note that this does not actually
2069 * assign a handler to the interrupt. */ 2016 * assign a handler to the interrupt. */
2070 2017
2071 CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 2018 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
2072 2019
2073 /* This actually configures the PCMCIA socket -- setting up the I/O 2020 /* This actually configures the PCMCIA socket -- setting up the I/O
2074 * windows and the interrupt mapping. */ 2021 * windows and the interrupt mapping. */
2075 2022
2076 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 2023 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
2077 2024
2078 dev->irq = link->irq.AssignedIRQ; 2025 dev->irq = link->irq.AssignedIRQ;
2079 dev->base_addr = link->io.BasePort1; 2026 dev->base_addr = link->io.BasePort1;
2080 SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 2027 SET_NETDEV_DEV(dev, &handle_to_dev(link));
2081 if (register_netdev(dev)) { 2028 if (register_netdev(dev)) {
2082 printk(KERN_NOTICE "wl3501_cs: register_netdev() failed\n"); 2029 printk(KERN_NOTICE "wl3501_cs: register_netdev() failed\n");
2083 goto failed; 2030 goto failed;
@@ -2088,10 +2035,9 @@ static void wl3501_config(dev_link_t *link)
2088 this = dev->priv; 2035 this = dev->priv;
2089 /* 2036 /*
2090 * At this point, the dev_node_t structure(s) should be initialized and 2037 * At this point, the dev_node_t structure(s) should be initialized and
2091 * arranged in a linked list at link->dev. 2038 * arranged in a linked list at link->dev_node.
2092 */ 2039 */
2093 link->dev = &this->node; 2040 link->dev_node = &this->node;
2094 link->state &= ~DEV_CONFIG_PENDING;
2095 2041
2096 this->base_addr = dev->base_addr; 2042 this->base_addr = dev->base_addr;
2097 2043
@@ -2127,13 +2073,13 @@ static void wl3501_config(dev_link_t *link)
2127 spin_lock_init(&this->lock); 2073 spin_lock_init(&this->lock);
2128 init_waitqueue_head(&this->wait); 2074 init_waitqueue_head(&this->wait);
2129 netif_start_queue(dev); 2075 netif_start_queue(dev);
2130 goto out; 2076 return 0;
2077
2131cs_failed: 2078cs_failed:
2132 cs_error(link->handle, last_fn, last_ret); 2079 cs_error(link, last_fn, last_ret);
2133failed: 2080failed:
2134 wl3501_release(link); 2081 wl3501_release(link);
2135out: 2082 return -ENODEV;
2136 return;
2137} 2083}
2138 2084
2139/** 2085/**
@@ -2144,52 +2090,36 @@ out:
2144 * and release the PCMCIA configuration. If the device is still open, this 2090 * and release the PCMCIA configuration. If the device is still open, this
2145 * will be postponed until it is closed. 2091 * will be postponed until it is closed.
2146 */ 2092 */
2147static void wl3501_release(dev_link_t *link) 2093static void wl3501_release(struct pcmcia_device *link)
2148{ 2094{
2149 struct net_device *dev = link->priv; 2095 struct net_device *dev = link->priv;
2150 2096
2151 /* Unlink the device chain */ 2097 /* Unlink the device chain */
2152 if (link->dev) { 2098 if (link->dev_node)
2153 unregister_netdev(dev); 2099 unregister_netdev(dev);
2154 link->dev = NULL;
2155 }
2156 2100
2157 /* Don't bother checking to see if these succeed or not */ 2101 pcmcia_disable_device(link);
2158 pcmcia_release_configuration(link->handle);
2159 pcmcia_release_io(link->handle, &link->io);
2160 pcmcia_release_irq(link->handle, &link->irq);
2161 link->state &= ~DEV_CONFIG;
2162} 2102}
2163 2103
2164static int wl3501_suspend(struct pcmcia_device *p_dev) 2104static int wl3501_suspend(struct pcmcia_device *link)
2165{ 2105{
2166 dev_link_t *link = dev_to_instance(p_dev);
2167 struct net_device *dev = link->priv; 2106 struct net_device *dev = link->priv;
2168 2107
2169 link->state |= DEV_SUSPEND;
2170
2171 wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND); 2108 wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND);
2172 if (link->state & DEV_CONFIG) { 2109 if (link->open)
2173 if (link->open) 2110 netif_device_detach(dev);
2174 netif_device_detach(dev);
2175 pcmcia_release_configuration(link->handle);
2176 }
2177 2111
2178 return 0; 2112 return 0;
2179} 2113}
2180 2114
2181static int wl3501_resume(struct pcmcia_device *p_dev) 2115static int wl3501_resume(struct pcmcia_device *link)
2182{ 2116{
2183 dev_link_t *link = dev_to_instance(p_dev);
2184 struct net_device *dev = link->priv; 2117 struct net_device *dev = link->priv;
2185 2118
2186 wl3501_pwr_mgmt(dev->priv, WL3501_RESUME); 2119 wl3501_pwr_mgmt(dev->priv, WL3501_RESUME);
2187 if (link->state & DEV_CONFIG) { 2120 if (link->open) {
2188 pcmcia_request_configuration(link->handle, &link->conf); 2121 wl3501_reset(dev);
2189 if (link->open) { 2122 netif_device_attach(dev);
2190 wl3501_reset(dev);
2191 netif_device_attach(dev);
2192 }
2193 } 2123 }
2194 2124
2195 return 0; 2125 return 0;
@@ -2207,7 +2137,7 @@ static struct pcmcia_driver wl3501_driver = {
2207 .drv = { 2137 .drv = {
2208 .name = "wl3501_cs", 2138 .name = "wl3501_cs",
2209 }, 2139 },
2210 .probe = wl3501_attach, 2140 .probe = wl3501_probe,
2211 .remove = wl3501_detach, 2141 .remove = wl3501_detach,
2212 .id_table = wl3501_ids, 2142 .id_table = wl3501_ids,
2213 .suspend = wl3501_suspend, 2143 .suspend = wl3501_suspend,
@@ -2221,9 +2151,7 @@ static int __init wl3501_init_module(void)
2221 2151
2222static void __exit wl3501_exit_module(void) 2152static void __exit wl3501_exit_module(void)
2223{ 2153{
2224 dprintk(0, ": unloading");
2225 pcmcia_unregister_driver(&wl3501_driver); 2154 pcmcia_unregister_driver(&wl3501_driver);
2226 BUG_ON(wl3501_dev_list != NULL);
2227} 2155}
2228 2156
2229module_init(wl3501_init_module); 2157module_init(wl3501_init_module);