[PATCH] drivers/net: fix-up schedule_timeout() usage
[firefly-linux-kernel-4.4.55.git] / drivers / net / 8139cp.c
index 72cdf19e1be1fd6358c39718ea534e73e5531b87..bd99c268e2daba16e3579246a9adf39cf71bf210 100644 (file)
@@ -61,6 +61,7 @@
 #include <linux/etherdevice.h>
 #include <linux/init.h>
 #include <linux/pci.h>
+#include <linux/dma-mapping.h>
 #include <linux/delay.h>
 #include <linux/ethtool.h>
 #include <linux/mii.h>
@@ -595,7 +596,7 @@ rx_status_loop:
 
                mapping =
                cp->rx_skb[rx_tail].mapping =
-                       pci_map_single(cp->pdev, new_skb->tail,
+                       pci_map_single(cp->pdev, new_skb->data,
                                       buflen, PCI_DMA_FROMDEVICE);
                cp->rx_skb[rx_tail].skb = new_skb;
 
@@ -1028,8 +1029,7 @@ static void cp_reset_hw (struct cp_private *cp)
                if (!(cpr8(Cmd) & CmdReset))
                        return;
 
-               set_current_state(TASK_UNINTERRUPTIBLE);
-               schedule_timeout(10);
+               schedule_timeout_uninterruptible(10);
        }
 
        printk(KERN_ERR "%s: hardware reset timeout\n", cp->dev->name);
@@ -1100,7 +1100,7 @@ static int cp_refill_rx (struct cp_private *cp)
                skb_reserve(skb, RX_OFFSET);
 
                cp->rx_skb[i].mapping = pci_map_single(cp->pdev,
-                       skb->tail, cp->rx_buf_sz, PCI_DMA_FROMDEVICE);
+                       skb->data, cp->rx_buf_sz, PCI_DMA_FROMDEVICE);
                cp->rx_skb[i].skb = skb;
 
                cp->rx_ring[i].opts2 = 0;
@@ -1515,22 +1515,22 @@ static void cp_get_ethtool_stats (struct net_device *dev,
                                  struct ethtool_stats *estats, u64 *tmp_stats)
 {
        struct cp_private *cp = netdev_priv(dev);
-       unsigned int work = 100;
        int i;
 
+       memset(cp->nic_stats, 0, sizeof(struct cp_dma_stats));
+
        /* begin NIC statistics dump */
        cpw32(StatsAddr + 4, (cp->nic_stats_dma >> 16) >> 16);
        cpw32(StatsAddr, (cp->nic_stats_dma & 0xffffffff) | DumpStats);
        cpr32(StatsAddr);
 
-       while (work-- > 0) {
+       for (i = 0; i < 1000; i++) {
                if ((cpr32(StatsAddr) & DumpStats) == 0)
                        break;
-               cpu_relax();
+               udelay(10);
        }
-
-       if (cpr32(StatsAddr) & DumpStats)
-               return /* -EIO */;
+       cpw32(StatsAddr, 0);
+       cpw32(StatsAddr + 4, 0);
 
        i = 0;
        tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_ok);
@@ -1574,6 +1574,7 @@ static struct ethtool_ops cp_ethtool_ops = {
        .set_wol                = cp_set_wol,
        .get_strings            = cp_get_strings,
        .get_ethtool_stats      = cp_get_ethtool_stats,
+       .get_perm_addr          = ethtool_op_get_perm_addr,
 };
 
 static int cp_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
@@ -1732,19 +1733,19 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 
        /* Configure DMA attributes. */
        if ((sizeof(dma_addr_t) > 4) &&
-           !pci_set_consistent_dma_mask(pdev, 0xffffffffffffffffULL) &&
-           !pci_set_dma_mask(pdev, 0xffffffffffffffffULL)) {
+           !pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK) &&
+           !pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
                pci_using_dac = 1;
        } else {
                pci_using_dac = 0;
 
-               rc = pci_set_dma_mask(pdev, 0xffffffffULL);
+               rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
                if (rc) {
                        printk(KERN_ERR PFX "No usable DMA configuration, "
                               "aborting.\n");
                        goto err_out_res;
                }
-               rc = pci_set_consistent_dma_mask(pdev, 0xffffffffULL);
+               rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
                if (rc) {
                        printk(KERN_ERR PFX "No usable consistent DMA configuration, "
                               "aborting.\n");
@@ -1772,6 +1773,7 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        for (i = 0; i < 3; i++)
                ((u16 *) (dev->dev_addr))[i] =
                    le16_to_cpu (read_eeprom (regs, i + 7, addr_len));
+       memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
 
        dev->open = cp_open;
        dev->stop = cp_close;
@@ -1896,6 +1898,7 @@ static int cp_resume (struct pci_dev *pdev)
 {
        struct net_device *dev;
        struct cp_private *cp;
+       unsigned long flags;
 
        dev = pci_get_drvdata (pdev);
        cp  = netdev_priv(dev);
@@ -1909,6 +1912,12 @@ static int cp_resume (struct pci_dev *pdev)
        
        cp_init_hw (cp);
        netif_start_queue (dev);
+
+       spin_lock_irqsave (&cp->lock, flags);
+
+       mii_check_media(&cp->mii_if, netif_msg_link(cp), FALSE);
+
+       spin_unlock_irqrestore (&cp->lock, flags);
        
        return 0;
 }