aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pcmcia/nmclan_cs.c
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2005-11-14 15:25:51 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2006-01-05 18:03:24 -0500
commitf8cfa618dccbdc6dab5297f75779566a388a98fd (patch)
treeb91e0952038dafc6e03bf8b1d8948b1fdefec031 /drivers/net/pcmcia/nmclan_cs.c
parentb463581154f3f3eecda27cae60df813fefcd84d3 (diff)
[PATCH] pcmcia: unify attach, EVENT_CARD_INSERTION handlers into one probe callback
Unify the EVENT_CARD_INSERTION and "attach" callbacks to one unified probe() callback. As all in-kernel drivers are changed to this new callback, there will be no temporary backwards-compatibility. Inside a probe() function, each driver _must_ set struct pcmcia_device *p_dev->instance and instance->handle correctly. With these patches, the basic driver interface for 16-bit PCMCIA drivers now has the classic four callbacks known also from other buses: int (*probe) (struct pcmcia_device *dev); void (*remove) (struct pcmcia_device *dev); int (*suspend) (struct pcmcia_device *dev); int (*resume) (struct pcmcia_device *dev); Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/net/pcmcia/nmclan_cs.c')
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c57
1 files changed, 9 insertions, 48 deletions
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index 0c9cb9f49a81..4a232254a497 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -388,8 +388,6 @@ static char *version =
388DRV_NAME " " DRV_VERSION " (Roger C. Pao)"; 388DRV_NAME " " DRV_VERSION " (Roger C. Pao)";
389#endif 389#endif
390 390
391static dev_info_t dev_info="nmclan_cs";
392
393static char *if_names[]={ 391static char *if_names[]={
394 "Auto", "10baseT", "BNC", 392 "Auto", "10baseT", "BNC",
395}; 393};
@@ -421,8 +419,6 @@ Function Prototypes
421 419
422static void nmclan_config(dev_link_t *link); 420static void nmclan_config(dev_link_t *link);
423static void nmclan_release(dev_link_t *link); 421static void nmclan_release(dev_link_t *link);
424static int nmclan_event(event_t event, int priority,
425 event_callback_args_t *args);
426 422
427static void nmclan_reset(struct net_device *dev); 423static void nmclan_reset(struct net_device *dev);
428static int mace_config(struct net_device *dev, struct ifmap *map); 424static int mace_config(struct net_device *dev, struct ifmap *map);
@@ -438,7 +434,6 @@ static void set_multicast_list(struct net_device *dev);
438static struct ethtool_ops netdev_ethtool_ops; 434static struct ethtool_ops netdev_ethtool_ops;
439 435
440 436
441static dev_link_t *nmclan_attach(void);
442static void nmclan_detach(struct pcmcia_device *p_dev); 437static void nmclan_detach(struct pcmcia_device *p_dev);
443 438
444/* ---------------------------------------------------------------------------- 439/* ----------------------------------------------------------------------------
@@ -448,13 +443,11 @@ nmclan_attach
448 Services. 443 Services.
449---------------------------------------------------------------------------- */ 444---------------------------------------------------------------------------- */
450 445
451static dev_link_t *nmclan_attach(void) 446static int nmclan_attach(struct pcmcia_device *p_dev)
452{ 447{
453 mace_private *lp; 448 mace_private *lp;
454 dev_link_t *link; 449 dev_link_t *link;
455 struct net_device *dev; 450 struct net_device *dev;
456 client_reg_t client_reg;
457 int ret;
458 451
459 DEBUG(0, "nmclan_attach()\n"); 452 DEBUG(0, "nmclan_attach()\n");
460 DEBUG(1, "%s\n", rcsid); 453 DEBUG(1, "%s\n", rcsid);
@@ -462,7 +455,7 @@ static dev_link_t *nmclan_attach(void)
462 /* Create new ethernet device */ 455 /* Create new ethernet device */
463 dev = alloc_etherdev(sizeof(mace_private)); 456 dev = alloc_etherdev(sizeof(mace_private));
464 if (!dev) 457 if (!dev)
465 return NULL; 458 return -ENOMEM;
466 lp = netdev_priv(dev); 459 lp = netdev_priv(dev);
467 link = &lp->link; 460 link = &lp->link;
468 link->priv = dev; 461 link->priv = dev;
@@ -496,19 +489,13 @@ static dev_link_t *nmclan_attach(void)
496 dev->watchdog_timeo = TX_TIMEOUT; 489 dev->watchdog_timeo = TX_TIMEOUT;
497#endif 490#endif
498 491
499 /* Register with Card Services */ 492 link->handle = p_dev;
500 link->next = NULL; 493 p_dev->instance = link;
501 client_reg.dev_info = &dev_info; 494
502 client_reg.Version = 0x0210; 495 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
503 client_reg.event_callback_args.client_data = link; 496 nmclan_config(link);
504 ret = pcmcia_register_client(&link->handle, &client_reg);
505 if (ret != 0) {
506 cs_error(link->handle, RegisterClient, ret);
507 nmclan_detach(link->handle);
508 return NULL;
509 }
510 497
511 return link; 498 return 0;
512} /* nmclan_attach */ 499} /* nmclan_attach */
513 500
514/* ---------------------------------------------------------------------------- 501/* ----------------------------------------------------------------------------
@@ -821,31 +808,6 @@ static int nmclan_resume(struct pcmcia_device *p_dev)
821 return 0; 808 return 0;
822} 809}
823 810
824/* ----------------------------------------------------------------------------
825nmclan_event
826 The card status event handler. Mostly, this schedules other
827 stuff to run after an event is received. A CARD_REMOVAL event
828 also sets some flags to discourage the net drivers from trying
829 to talk to the card any more.
830---------------------------------------------------------------------------- */
831static int nmclan_event(event_t event, int priority,
832 event_callback_args_t *args)
833{
834 dev_link_t *link = args->client_data;
835
836 DEBUG(1, "nmclan_event(0x%06x)\n", event);
837
838 switch (event) {
839 case CS_EVENT_CARD_INSERTION:
840 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
841 nmclan_config(link);
842 break;
843 case CS_EVENT_RESET_REQUEST:
844 return 1;
845 break;
846 }
847 return 0;
848} /* nmclan_event */
849 811
850/* ---------------------------------------------------------------------------- 812/* ----------------------------------------------------------------------------
851nmclan_reset 813nmclan_reset
@@ -1673,8 +1635,7 @@ static struct pcmcia_driver nmclan_cs_driver = {
1673 .drv = { 1635 .drv = {
1674 .name = "nmclan_cs", 1636 .name = "nmclan_cs",
1675 }, 1637 },
1676 .attach = nmclan_attach, 1638 .probe = nmclan_attach,
1677 .event = nmclan_event,
1678 .remove = nmclan_detach, 1639 .remove = nmclan_detach,
1679 .id_table = nmclan_ids, 1640 .id_table = nmclan_ids,
1680 .suspend = nmclan_suspend, 1641 .suspend = nmclan_suspend,