aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pcmcia
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/pcmcia
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/pcmcia')
-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
10 files changed, 571 insertions, 913 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,