[PATCH] PCI: MSI(X) save/restore for suspend/resume
[safe/jmp/linux-2.6] / drivers / net / pcmcia / 3c574_cs.c
index f4e293b..fab9336 100644 (file)
@@ -225,7 +225,7 @@ static char mii_preamble_required = 0;
 
 /* Index of functions. */
 
-static void tc574_config(struct pcmcia_device *link);
+static int tc574_config(struct pcmcia_device *link);
 static void tc574_release(struct pcmcia_device *link);
 
 static void mdio_sync(kio_addr_t ioaddr, int bits);
@@ -256,7 +256,7 @@ static void tc574_detach(struct pcmcia_device *p_dev);
        with Card Services.
 */
 
-static int tc574_attach(struct pcmcia_device *link)
+static int tc574_probe(struct pcmcia_device *link)
 {
        struct el3_private *lp;
        struct net_device *dev;
@@ -296,10 +296,7 @@ static int tc574_attach(struct pcmcia_device *link)
        dev->watchdog_timeo = TX_TIMEOUT;
 #endif
 
-       link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
-       tc574_config(link);
-
-       return 0;
+       return tc574_config(link);
 } /* tc574_attach */
 
 /*
@@ -320,8 +317,7 @@ static void tc574_detach(struct pcmcia_device *link)
        if (link->dev_node)
                unregister_netdev(dev);
 
-       if (link->state & DEV_CONFIG)
-               tc574_release(link);
+       tc574_release(link);
 
        free_netdev(dev);
 } /* tc574_detach */
@@ -337,7 +333,7 @@ static void tc574_detach(struct pcmcia_device *link)
 
 static const char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"};
 
-static void tc574_config(struct pcmcia_device *link)
+static int tc574_config(struct pcmcia_device *link)
 {
        struct net_device *dev = link->priv;
        struct el3_private *lp = netdev_priv(dev);
@@ -365,9 +361,6 @@ static void tc574_config(struct pcmcia_device *link)
        link->conf.ConfigBase = parse.config.base;
        link->conf.Present = parse.config.rmask[0];
 
-       /* Configure card */
-       link->state |= DEV_CONFIG;
-
        link->io.IOAddrLines = 16;
        for (i = j = 0; j < 0x400; j += 0x20) {
                link->io.BasePort1 = j ^ 0x300;
@@ -466,7 +459,6 @@ static void tc574_config(struct pcmcia_device *link)
                }
        }
 
-       link->state &= ~DEV_CONFIG_PENDING;
        link->dev_node = &lp->node;
        SET_NETDEV_DEV(dev, &handle_to_dev(link));
 
@@ -486,13 +478,13 @@ static void tc574_config(struct pcmcia_device *link)
                   8 << config.u.ram_size, ram_split[config.u.ram_split],
                   config.u.autoselect ? "autoselect " : "");
 
-       return;
+       return 0;
 
 cs_failed:
        cs_error(link, last_fn, last_ret);
 failed:
        tc574_release(link);
-       return;
+       return -ENODEV;
 
 } /* tc574_config */
 
@@ -511,7 +503,7 @@ static int tc574_suspend(struct pcmcia_device *link)
 {
        struct net_device *dev = link->priv;
 
-       if ((link->state & DEV_CONFIG) && (link->open))
+       if (link->open)
                netif_device_detach(dev);
 
        return 0;
@@ -521,7 +513,7 @@ static int tc574_resume(struct pcmcia_device *link)
 {
        struct net_device *dev = link->priv;
 
-       if ((link->state & DEV_CONFIG) && (link->open)) {
+       if (link->open) {
                tc574_reset(dev);
                netif_device_attach(dev);
        }
@@ -736,7 +728,7 @@ static int el3_open(struct net_device *dev)
        struct el3_private *lp = netdev_priv(dev);
        struct pcmcia_device *link = lp->p_dev;
 
-       if (!DEV_OK(link))
+       if (!pcmcia_dev_present(link))
                return -ENODEV;
        
        link->open++;
@@ -1184,7 +1176,7 @@ static int el3_close(struct net_device *dev)
 
        DEBUG(2, "%s: shutting down ethercard.\n", dev->name);
        
-       if (DEV_OK(link)) {
+       if (pcmcia_dev_present(link)) {
                unsigned long flags;
 
                /* Turn off statistics ASAP.  We update lp->stats below. */
@@ -1223,7 +1215,7 @@ static struct pcmcia_driver tc574_driver = {
        .drv            = {
                .name   = "3c574_cs",
        },
-       .probe          = tc574_attach,
+       .probe          = tc574_probe,
        .remove         = tc574_detach,
        .id_table       = tc574_ids,
        .suspend        = tc574_suspend,