Fix Connectathon locking test failure
[powerpc.git] / drivers / net / forcedeth.c
index 1e69102..d6eefdb 100644 (file)
  *                        per-packet flags.
  *      0.39: 18 Jul 2005: Add 64bit descriptor support.
  *      0.40: 19 Jul 2005: Add support for mac address change.
+ *      0.41: 30 Jul 2005: Write back original MAC in nv_close instead
+ *                        of nv_remove
+ *      0.42: 06 Aug 2005: Fix lack of link speed initialization
+ *                        in the second (and later) nv_open call
  *
  * Known bugs:
  * We suspect that on some hardware no TX done interrupts are generated.
  * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few
  * superfluous timer interrupts from the nic.
  */
-#define FORCEDETH_VERSION              "0.40"
+#define FORCEDETH_VERSION              "0.41"
 #define DRV_NAME                       "forcedeth"
 
 #include <linux/module.h>
@@ -1368,7 +1372,7 @@ static int nv_change_mtu(struct net_device *dev, int new_mtu)
 
        /* synchronized against open : rtnl_lock() held by caller */
        if (netif_running(dev)) {
-               u8 *base = get_hwbase(dev);
+               u8 __iomem *base = get_hwbase(dev);
                /*
                 * It seems that the nic preloads valid ring entries into an
                 * internal buffer. The procedure for flushing everything is
@@ -1419,7 +1423,7 @@ static int nv_change_mtu(struct net_device *dev, int new_mtu)
 
 static void nv_copy_mac_to_hw(struct net_device *dev)
 {
-       u8 *base = get_hwbase(dev);
+       u8 __iomem *base = get_hwbase(dev);
        u32 mac[2];
 
        mac[0] = (dev->dev_addr[0] << 0) + (dev->dev_addr[1] << 8) +
@@ -2176,6 +2180,9 @@ static int nv_open(struct net_device *dev)
                writel(NVREG_MIISTAT_MASK, base + NvRegMIIStatus);
                dprintk(KERN_INFO "startup: got 0x%08x.\n", miistat);
        }
+       /* set linkspeed to invalid value, thus force nv_update_linkspeed
+        * to init hw */
+       np->linkspeed = 0;
        ret = nv_update_linkspeed(dev);
        nv_start_rx(dev);
        nv_start_tx(dev);
@@ -2230,6 +2237,12 @@ static int nv_close(struct net_device *dev)
        if (np->wolenabled)
                nv_start_rx(dev);
 
+       /* special op: write back the misordered MAC address - otherwise
+        * the next nv_probe would see a wrong address.
+        */
+       writel(np->orig_mac[0], base + NvRegMacAddrA);
+       writel(np->orig_mac[1], base + NvRegMacAddrB);
+
        /* FIXME: power down nic */
 
        return 0;
@@ -2482,16 +2495,9 @@ static void __devexit nv_remove(struct pci_dev *pci_dev)
 {
        struct net_device *dev = pci_get_drvdata(pci_dev);
        struct fe_priv *np = get_nvpriv(dev);
-       u8 __iomem *base = get_hwbase(dev);
 
        unregister_netdev(dev);
 
-       /* special op: write back the misordered MAC address - otherwise
-        * the next nv_probe would see a wrong address.
-        */
-       writel(np->orig_mac[0], base + NvRegMacAddrA);
-       writel(np->orig_mac[1], base + NvRegMacAddrB);
-
        /* free all structures */
        if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
                pci_free_consistent(np->pci_dev, sizeof(struct ring_desc) * (RX_RING + TX_RING), np->rx_ring.orig, np->ring_addr);