aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/8139too.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-06-16 20:24:53 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-06-16 20:24:53 -0400
commit492b057c426e4aa747484958e18e9da29003985d (patch)
tree34e08c24618688d8bcc190523028b5f94cce0c0b /drivers/net/8139too.c
parent313485175da221c388f6a8ecf4c30062ba9bea17 (diff)
parent300df7dc89cc276377fc020704e34875d5c473b6 (diff)
Merge commit 'origin/master' into next
Diffstat (limited to 'drivers/net/8139too.c')
-rw-r--r--drivers/net/8139too.c210
1 files changed, 97 insertions, 113 deletions
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index 1fc45431a620..8ae72ec14456 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -126,19 +126,12 @@
126#undef RTL8139_NDEBUG 126#undef RTL8139_NDEBUG
127 127
128 128
129#if RTL8139_DEBUG
130/* note: prints function name for you */
131# define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
132#else
133# define DPRINTK(fmt, args...)
134#endif
135
136#ifdef RTL8139_NDEBUG 129#ifdef RTL8139_NDEBUG
137# define assert(expr) do {} while (0) 130# define assert(expr) do {} while (0)
138#else 131#else
139# define assert(expr) \ 132# define assert(expr) \
140 if(unlikely(!(expr))) { \ 133 if(unlikely(!(expr))) { \
141 printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n", \ 134 pr_err("Assertion failed! %s,%s,%s,line=%d\n", \
142 #expr, __FILE__, __func__, __LINE__); \ 135 #expr, __FILE__, __func__, __LINE__); \
143 } 136 }
144#endif 137#endif
@@ -784,8 +777,8 @@ static __devinit struct net_device * rtl8139_init_board (struct pci_dev *pdev)
784 777
785 /* set this immediately, we need to know before 778 /* set this immediately, we need to know before
786 * we talk to the chip directly */ 779 * we talk to the chip directly */
787 DPRINTK("PIO region size == 0x%02X\n", pio_len); 780 pr_debug("PIO region size == 0x%02lX\n", pio_len);
788 DPRINTK("MMIO region size == 0x%02lX\n", mmio_len); 781 pr_debug("MMIO region size == 0x%02lX\n", mmio_len);
789 782
790retry: 783retry:
791 if (use_io) { 784 if (use_io) {
@@ -865,19 +858,17 @@ retry:
865 } 858 }
866 859
867 /* if unknown chip, assume array element #0, original RTL-8139 in this case */ 860 /* if unknown chip, assume array element #0, original RTL-8139 in this case */
868 dev_printk (KERN_DEBUG, &pdev->dev, 861 dev_dbg(&pdev->dev, "unknown chip version, assuming RTL-8139\n");
869 "unknown chip version, assuming RTL-8139\n"); 862 dev_dbg(&pdev->dev, "TxConfig = 0x%lx\n", RTL_R32 (TxConfig));
870 dev_printk (KERN_DEBUG, &pdev->dev,
871 "TxConfig = 0x%lx\n", RTL_R32 (TxConfig));
872 tp->chipset = 0; 863 tp->chipset = 0;
873 864
874match: 865match:
875 DPRINTK ("chipset id (%d) == index %d, '%s'\n", 866 pr_debug("chipset id (%d) == index %d, '%s'\n",
876 version, i, rtl_chip_info[i].name); 867 version, i, rtl_chip_info[i].name);
877 868
878 if (tp->chipset >= CH_8139B) { 869 if (tp->chipset >= CH_8139B) {
879 u8 new_tmp8 = tmp8 = RTL_R8 (Config1); 870 u8 new_tmp8 = tmp8 = RTL_R8 (Config1);
880 DPRINTK("PCI PM wakeup\n"); 871 pr_debug("PCI PM wakeup\n");
881 if ((rtl_chip_info[tp->chipset].flags & HasLWake) && 872 if ((rtl_chip_info[tp->chipset].flags & HasLWake) &&
882 (tmp8 & LWAKE)) 873 (tmp8 & LWAKE))
883 new_tmp8 &= ~LWAKE; 874 new_tmp8 &= ~LWAKE;
@@ -896,7 +887,7 @@ match:
896 } 887 }
897 } 888 }
898 } else { 889 } else {
899 DPRINTK("Old chip wakeup\n"); 890 pr_debug("Old chip wakeup\n");
900 tmp8 = RTL_R8 (Config1); 891 tmp8 = RTL_R8 (Config1);
901 tmp8 &= ~(SLEEP | PWRDN); 892 tmp8 &= ~(SLEEP | PWRDN);
902 RTL_W8 (Config1, tmp8); 893 RTL_W8 (Config1, tmp8);
@@ -949,7 +940,7 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
949 { 940 {
950 static int printed_version; 941 static int printed_version;
951 if (!printed_version++) 942 if (!printed_version++)
952 printk (KERN_INFO RTL8139_DRIVER_NAME "\n"); 943 pr_info(RTL8139_DRIVER_NAME "\n");
953 } 944 }
954#endif 945#endif
955 946
@@ -965,7 +956,7 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
965 pdev->device == PCI_DEVICE_ID_REALTEK_8139 && 956 pdev->device == PCI_DEVICE_ID_REALTEK_8139 &&
966 pdev->subsystem_vendor == PCI_VENDOR_ID_ATHEROS && 957 pdev->subsystem_vendor == PCI_VENDOR_ID_ATHEROS &&
967 pdev->subsystem_device == PCI_DEVICE_ID_REALTEK_8139) { 958 pdev->subsystem_device == PCI_DEVICE_ID_REALTEK_8139) {
968 printk(KERN_INFO "8139too: OQO Model 2 detected. Forcing PIO\n"); 959 pr_info("8139too: OQO Model 2 detected. Forcing PIO\n");
969 use_io = 1; 960 use_io = 1;
970 } 961 }
971 962
@@ -1018,21 +1009,20 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
1018 tp->mii.reg_num_mask = 0x1f; 1009 tp->mii.reg_num_mask = 0x1f;
1019 1010
1020 /* dev is fully set up and ready to use now */ 1011 /* dev is fully set up and ready to use now */
1021 DPRINTK("about to register device named %s (%p)...\n", dev->name, dev); 1012 pr_debug("about to register device named %s (%p)...\n", dev->name, dev);
1022 i = register_netdev (dev); 1013 i = register_netdev (dev);
1023 if (i) goto err_out; 1014 if (i) goto err_out;
1024 1015
1025 pci_set_drvdata (pdev, dev); 1016 pci_set_drvdata (pdev, dev);
1026 1017
1027 printk (KERN_INFO "%s: %s at 0x%lx, " 1018 pr_info("%s: %s at 0x%lx, %pM, IRQ %d\n",
1028 "%pM, IRQ %d\n",
1029 dev->name, 1019 dev->name,
1030 board_info[ent->driver_data].name, 1020 board_info[ent->driver_data].name,
1031 dev->base_addr, 1021 dev->base_addr,
1032 dev->dev_addr, 1022 dev->dev_addr,
1033 dev->irq); 1023 dev->irq);
1034 1024
1035 printk (KERN_DEBUG "%s: Identified 8139 chip type '%s'\n", 1025 pr_debug("%s: Identified 8139 chip type '%s'\n",
1036 dev->name, rtl_chip_info[tp->chipset].name); 1026 dev->name, rtl_chip_info[tp->chipset].name);
1037 1027
1038 /* Find the connected MII xcvrs. 1028 /* Find the connected MII xcvrs.
@@ -1046,14 +1036,12 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
1046 if (mii_status != 0xffff && mii_status != 0x0000) { 1036 if (mii_status != 0xffff && mii_status != 0x0000) {
1047 u16 advertising = mdio_read(dev, phy, 4); 1037 u16 advertising = mdio_read(dev, phy, 4);
1048 tp->phys[phy_idx++] = phy; 1038 tp->phys[phy_idx++] = phy;
1049 printk(KERN_INFO "%s: MII transceiver %d status 0x%4.4x " 1039 pr_info("%s: MII transceiver %d status 0x%4.4x advertising %4.4x.\n",
1050 "advertising %4.4x.\n",
1051 dev->name, phy, mii_status, advertising); 1040 dev->name, phy, mii_status, advertising);
1052 } 1041 }
1053 } 1042 }
1054 if (phy_idx == 0) { 1043 if (phy_idx == 0) {
1055 printk(KERN_INFO "%s: No MII transceivers found! Assuming SYM " 1044 pr_info("%s: No MII transceivers found! Assuming SYM transceiver.\n",
1056 "transceiver.\n",
1057 dev->name); 1045 dev->name);
1058 tp->phys[0] = 32; 1046 tp->phys[0] = 32;
1059 } 1047 }
@@ -1073,13 +1061,13 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
1073 if (board_idx < MAX_UNITS && full_duplex[board_idx] > 0) 1061 if (board_idx < MAX_UNITS && full_duplex[board_idx] > 0)
1074 tp->mii.full_duplex = full_duplex[board_idx]; 1062 tp->mii.full_duplex = full_duplex[board_idx];
1075 if (tp->mii.full_duplex) { 1063 if (tp->mii.full_duplex) {
1076 printk(KERN_INFO "%s: Media type forced to Full Duplex.\n", dev->name); 1064 pr_info("%s: Media type forced to Full Duplex.\n", dev->name);
1077 /* Changing the MII-advertised media because might prevent 1065 /* Changing the MII-advertised media because might prevent
1078 re-connection. */ 1066 re-connection. */
1079 tp->mii.force_media = 1; 1067 tp->mii.force_media = 1;
1080 } 1068 }
1081 if (tp->default_port) { 1069 if (tp->default_port) {
1082 printk(KERN_INFO " Forcing %dMbps %s-duplex operation.\n", 1070 pr_info(" Forcing %dMbps %s-duplex operation.\n",
1083 (option & 0x20 ? 100 : 10), 1071 (option & 0x20 ? 100 : 10),
1084 (option & 0x10 ? "full" : "half")); 1072 (option & 0x10 ? "full" : "half"));
1085 mdio_write(dev, tp->phys[0], 0, 1073 mdio_write(dev, tp->phys[0], 0,
@@ -1342,7 +1330,7 @@ static int rtl8139_open (struct net_device *dev)
1342 netif_start_queue (dev); 1330 netif_start_queue (dev);
1343 1331
1344 if (netif_msg_ifup(tp)) 1332 if (netif_msg_ifup(tp))
1345 printk(KERN_DEBUG "%s: rtl8139_open() ioaddr %#llx IRQ %d" 1333 pr_debug("%s: rtl8139_open() ioaddr %#llx IRQ %d"
1346 " GP Pins %2.2x %s-duplex.\n", dev->name, 1334 " GP Pins %2.2x %s-duplex.\n", dev->name,
1347 (unsigned long long)pci_resource_start (tp->pci_dev, 1), 1335 (unsigned long long)pci_resource_start (tp->pci_dev, 1),
1348 dev->irq, RTL_R8 (MediaStatus), 1336 dev->irq, RTL_R8 (MediaStatus),
@@ -1404,7 +1392,7 @@ static void rtl8139_hw_start (struct net_device *dev)
1404 RTL_W8 (Config3, RTL_R8 (Config3) & ~Cfg3_Magic); 1392 RTL_W8 (Config3, RTL_R8 (Config3) & ~Cfg3_Magic);
1405 } 1393 }
1406 1394
1407 DPRINTK("init buffer addresses\n"); 1395 pr_debug("init buffer addresses\n");
1408 1396
1409 /* Lock Config[01234] and BMCR register writes */ 1397 /* Lock Config[01234] and BMCR register writes */
1410 RTL_W8 (Cfg9346, Cfg9346_Lock); 1398 RTL_W8 (Cfg9346, Cfg9346_Lock);
@@ -1566,14 +1554,13 @@ static inline void rtl8139_thread_iter (struct net_device *dev,
1566 tp->mii.full_duplex = duplex; 1554 tp->mii.full_duplex = duplex;
1567 1555
1568 if (mii_lpa) { 1556 if (mii_lpa) {
1569 printk (KERN_INFO 1557 pr_info("%s: Setting %s-duplex based on MII #%d link"
1570 "%s: Setting %s-duplex based on MII #%d link"
1571 " partner ability of %4.4x.\n", 1558 " partner ability of %4.4x.\n",
1572 dev->name, 1559 dev->name,
1573 tp->mii.full_duplex ? "full" : "half", 1560 tp->mii.full_duplex ? "full" : "half",
1574 tp->phys[0], mii_lpa); 1561 tp->phys[0], mii_lpa);
1575 } else { 1562 } else {
1576 printk(KERN_INFO"%s: media is unconnected, link down, or incompatible connection\n", 1563 pr_info("%s: media is unconnected, link down, or incompatible connection\n",
1577 dev->name); 1564 dev->name);
1578 } 1565 }
1579#if 0 1566#if 0
@@ -1588,11 +1575,11 @@ static inline void rtl8139_thread_iter (struct net_device *dev,
1588 1575
1589 rtl8139_tune_twister (dev, tp); 1576 rtl8139_tune_twister (dev, tp);
1590 1577
1591 DPRINTK ("%s: Media selection tick, Link partner %4.4x.\n", 1578 pr_debug("%s: Media selection tick, Link partner %4.4x.\n",
1592 dev->name, RTL_R16 (NWayLPAR)); 1579 dev->name, RTL_R16 (NWayLPAR));
1593 DPRINTK ("%s: Other registers are IntMask %4.4x IntStatus %4.4x\n", 1580 pr_debug("%s: Other registers are IntMask %4.4x IntStatus %4.4x\n",
1594 dev->name, RTL_R16 (IntrMask), RTL_R16 (IntrStatus)); 1581 dev->name, RTL_R16 (IntrMask), RTL_R16 (IntrStatus));
1595 DPRINTK ("%s: Chip config %2.2x %2.2x.\n", 1582 pr_debug("%s: Chip config %2.2x %2.2x.\n",
1596 dev->name, RTL_R8 (Config0), 1583 dev->name, RTL_R8 (Config0),
1597 RTL_R8 (Config1)); 1584 RTL_R8 (Config1));
1598} 1585}
@@ -1652,14 +1639,14 @@ static void rtl8139_tx_timeout_task (struct work_struct *work)
1652 int i; 1639 int i;
1653 u8 tmp8; 1640 u8 tmp8;
1654 1641
1655 printk (KERN_DEBUG "%s: Transmit timeout, status %2.2x %4.4x %4.4x " 1642 pr_debug("%s: Transmit timeout, status %2.2x %4.4x %4.4x media %2.2x.\n",
1656 "media %2.2x.\n", dev->name, RTL_R8 (ChipCmd), 1643 dev->name, RTL_R8 (ChipCmd),
1657 RTL_R16(IntrStatus), RTL_R16(IntrMask), RTL_R8(MediaStatus)); 1644 RTL_R16(IntrStatus), RTL_R16(IntrMask), RTL_R8(MediaStatus));
1658 /* Emit info to figure out what went wrong. */ 1645 /* Emit info to figure out what went wrong. */
1659 printk (KERN_DEBUG "%s: Tx queue start entry %ld dirty entry %ld.\n", 1646 pr_debug("%s: Tx queue start entry %ld dirty entry %ld.\n",
1660 dev->name, tp->cur_tx, tp->dirty_tx); 1647 dev->name, tp->cur_tx, tp->dirty_tx);
1661 for (i = 0; i < NUM_TX_DESC; i++) 1648 for (i = 0; i < NUM_TX_DESC; i++)
1662 printk (KERN_DEBUG "%s: Tx descriptor %d is %8.8lx.%s\n", 1649 pr_debug("%s: Tx descriptor %d is %8.8lx.%s\n",
1663 dev->name, i, RTL_R32 (TxStatus0 + (i * 4)), 1650 dev->name, i, RTL_R32 (TxStatus0 + (i * 4)),
1664 i == tp->dirty_tx % NUM_TX_DESC ? 1651 i == tp->dirty_tx % NUM_TX_DESC ?
1665 " (queue head)" : ""); 1652 " (queue head)" : "");
@@ -1741,7 +1728,7 @@ static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev)
1741 spin_unlock_irqrestore(&tp->lock, flags); 1728 spin_unlock_irqrestore(&tp->lock, flags);
1742 1729
1743 if (netif_msg_tx_queued(tp)) 1730 if (netif_msg_tx_queued(tp))
1744 printk (KERN_DEBUG "%s: Queued Tx packet size %u to slot %d.\n", 1731 pr_debug("%s: Queued Tx packet size %u to slot %d.\n",
1745 dev->name, len, entry); 1732 dev->name, len, entry);
1746 1733
1747 return 0; 1734 return 0;
@@ -1772,7 +1759,7 @@ static void rtl8139_tx_interrupt (struct net_device *dev,
1772 if (txstatus & (TxOutOfWindow | TxAborted)) { 1759 if (txstatus & (TxOutOfWindow | TxAborted)) {
1773 /* There was an major error, log it. */ 1760 /* There was an major error, log it. */
1774 if (netif_msg_tx_err(tp)) 1761 if (netif_msg_tx_err(tp))
1775 printk(KERN_DEBUG "%s: Transmit error, Tx status %8.8x.\n", 1762 pr_debug("%s: Transmit error, Tx status %8.8x.\n",
1776 dev->name, txstatus); 1763 dev->name, txstatus);
1777 dev->stats.tx_errors++; 1764 dev->stats.tx_errors++;
1778 if (txstatus & TxAborted) { 1765 if (txstatus & TxAborted) {
@@ -1803,7 +1790,7 @@ static void rtl8139_tx_interrupt (struct net_device *dev,
1803 1790
1804#ifndef RTL8139_NDEBUG 1791#ifndef RTL8139_NDEBUG
1805 if (tp->cur_tx - dirty_tx > NUM_TX_DESC) { 1792 if (tp->cur_tx - dirty_tx > NUM_TX_DESC) {
1806 printk (KERN_ERR "%s: Out-of-sync dirty pointer, %ld vs. %ld.\n", 1793 pr_err("%s: Out-of-sync dirty pointer, %ld vs. %ld.\n",
1807 dev->name, dirty_tx, tp->cur_tx); 1794 dev->name, dirty_tx, tp->cur_tx);
1808 dirty_tx += NUM_TX_DESC; 1795 dirty_tx += NUM_TX_DESC;
1809 } 1796 }
@@ -1828,12 +1815,12 @@ static void rtl8139_rx_err (u32 rx_status, struct net_device *dev,
1828#endif 1815#endif
1829 1816
1830 if (netif_msg_rx_err (tp)) 1817 if (netif_msg_rx_err (tp))
1831 printk(KERN_DEBUG "%s: Ethernet frame had errors, status %8.8x.\n", 1818 pr_debug("%s: Ethernet frame had errors, status %8.8x.\n",
1832 dev->name, rx_status); 1819 dev->name, rx_status);
1833 dev->stats.rx_errors++; 1820 dev->stats.rx_errors++;
1834 if (!(rx_status & RxStatusOK)) { 1821 if (!(rx_status & RxStatusOK)) {
1835 if (rx_status & RxTooLong) { 1822 if (rx_status & RxTooLong) {
1836 DPRINTK ("%s: Oversized Ethernet frame, status %4.4x!\n", 1823 pr_debug("%s: Oversized Ethernet frame, status %4.4x!\n",
1837 dev->name, rx_status); 1824 dev->name, rx_status);
1838 /* A.C.: The chip hangs here. */ 1825 /* A.C.: The chip hangs here. */
1839 } 1826 }
@@ -1866,7 +1853,7 @@ static void rtl8139_rx_err (u32 rx_status, struct net_device *dev,
1866 break; 1853 break;
1867 } 1854 }
1868 if (tmp_work <= 0) 1855 if (tmp_work <= 0)
1869 printk (KERN_WARNING PFX "rx stop wait too long\n"); 1856 pr_warning(PFX "rx stop wait too long\n");
1870 /* restart receive */ 1857 /* restart receive */
1871 tmp_work = 200; 1858 tmp_work = 200;
1872 while (--tmp_work > 0) { 1859 while (--tmp_work > 0) {
@@ -1877,7 +1864,7 @@ static void rtl8139_rx_err (u32 rx_status, struct net_device *dev,
1877 break; 1864 break;
1878 } 1865 }
1879 if (tmp_work <= 0) 1866 if (tmp_work <= 0)
1880 printk (KERN_WARNING PFX "tx/rx enable wait too long\n"); 1867 pr_warning(PFX "tx/rx enable wait too long\n");
1881 1868
1882 /* and reinitialize all rx related registers */ 1869 /* and reinitialize all rx related registers */
1883 RTL_W8_F (Cfg9346, Cfg9346_Unlock); 1870 RTL_W8_F (Cfg9346, Cfg9346_Unlock);
@@ -1888,7 +1875,7 @@ static void rtl8139_rx_err (u32 rx_status, struct net_device *dev,
1888 RTL_W32 (RxConfig, tp->rx_config); 1875 RTL_W32 (RxConfig, tp->rx_config);
1889 tp->cur_rx = 0; 1876 tp->cur_rx = 0;
1890 1877
1891 DPRINTK("init buffer addresses\n"); 1878 pr_debug("init buffer addresses\n");
1892 1879
1893 /* Lock Config[01234] and BMCR register writes */ 1880 /* Lock Config[01234] and BMCR register writes */
1894 RTL_W8 (Cfg9346, Cfg9346_Lock); 1881 RTL_W8 (Cfg9346, Cfg9346_Lock);
@@ -1942,7 +1929,7 @@ static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp,
1942 unsigned int cur_rx = tp->cur_rx; 1929 unsigned int cur_rx = tp->cur_rx;
1943 unsigned int rx_size = 0; 1930 unsigned int rx_size = 0;
1944 1931
1945 DPRINTK ("%s: In rtl8139_rx(), current %4.4x BufAddr %4.4x," 1932 pr_debug("%s: In rtl8139_rx(), current %4.4x BufAddr %4.4x,"
1946 " free to %4.4x, Cmd %2.2x.\n", dev->name, (u16)cur_rx, 1933 " free to %4.4x, Cmd %2.2x.\n", dev->name, (u16)cur_rx,
1947 RTL_R16 (RxBufAddr), 1934 RTL_R16 (RxBufAddr),
1948 RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd)); 1935 RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd));
@@ -1962,17 +1949,17 @@ static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp,
1962 pkt_size = rx_size - 4; 1949 pkt_size = rx_size - 4;
1963 1950
1964 if (netif_msg_rx_status(tp)) 1951 if (netif_msg_rx_status(tp))
1965 printk(KERN_DEBUG "%s: rtl8139_rx() status %4.4x, size %4.4x," 1952 pr_debug("%s: rtl8139_rx() status %4.4x, size %4.4x,"
1966 " cur %4.4x.\n", dev->name, rx_status, 1953 " cur %4.4x.\n", dev->name, rx_status,
1967 rx_size, cur_rx); 1954 rx_size, cur_rx);
1968#if RTL8139_DEBUG > 2 1955#if RTL8139_DEBUG > 2
1969 { 1956 {
1970 int i; 1957 int i;
1971 DPRINTK ("%s: Frame contents ", dev->name); 1958 pr_debug("%s: Frame contents ", dev->name);
1972 for (i = 0; i < 70; i++) 1959 for (i = 0; i < 70; i++)
1973 printk (" %2.2x", 1960 pr_cont(" %2.2x",
1974 rx_ring[ring_offset + i]); 1961 rx_ring[ring_offset + i]);
1975 printk (".\n"); 1962 pr_cont(".\n");
1976 } 1963 }
1977#endif 1964#endif
1978 1965
@@ -1984,12 +1971,12 @@ static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp,
1984 if (!tp->fifo_copy_timeout) 1971 if (!tp->fifo_copy_timeout)
1985 tp->fifo_copy_timeout = jiffies + 2; 1972 tp->fifo_copy_timeout = jiffies + 2;
1986 else if (time_after(jiffies, tp->fifo_copy_timeout)) { 1973 else if (time_after(jiffies, tp->fifo_copy_timeout)) {
1987 DPRINTK ("%s: hung FIFO. Reset.", dev->name); 1974 pr_debug("%s: hung FIFO. Reset.", dev->name);
1988 rx_size = 0; 1975 rx_size = 0;
1989 goto no_early_rx; 1976 goto no_early_rx;
1990 } 1977 }
1991 if (netif_msg_intr(tp)) { 1978 if (netif_msg_intr(tp)) {
1992 printk(KERN_DEBUG "%s: fifo copy in progress.", 1979 pr_debug("%s: fifo copy in progress.",
1993 dev->name); 1980 dev->name);
1994 } 1981 }
1995 tp->xstats.early_rx++; 1982 tp->xstats.early_rx++;
@@ -2033,8 +2020,7 @@ no_early_rx:
2033 netif_receive_skb (skb); 2020 netif_receive_skb (skb);
2034 } else { 2021 } else {
2035 if (net_ratelimit()) 2022 if (net_ratelimit())
2036 printk (KERN_WARNING 2023 pr_warning("%s: Memory squeeze, dropping packet.\n",
2037 "%s: Memory squeeze, dropping packet.\n",
2038 dev->name); 2024 dev->name);
2039 dev->stats.rx_dropped++; 2025 dev->stats.rx_dropped++;
2040 } 2026 }
@@ -2049,12 +2035,10 @@ no_early_rx:
2049 if (unlikely(!received || rx_size == 0xfff0)) 2035 if (unlikely(!received || rx_size == 0xfff0))
2050 rtl8139_isr_ack(tp); 2036 rtl8139_isr_ack(tp);
2051 2037
2052#if RTL8139_DEBUG > 1 2038 pr_debug("%s: Done rtl8139_rx(), current %4.4x BufAddr %4.4x,"
2053 DPRINTK ("%s: Done rtl8139_rx(), current %4.4x BufAddr %4.4x,"
2054 " free to %4.4x, Cmd %2.2x.\n", dev->name, cur_rx, 2039 " free to %4.4x, Cmd %2.2x.\n", dev->name, cur_rx,
2055 RTL_R16 (RxBufAddr), 2040 RTL_R16 (RxBufAddr),
2056 RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd)); 2041 RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd));
2057#endif
2058 2042
2059 tp->cur_rx = cur_rx; 2043 tp->cur_rx = cur_rx;
2060 2044
@@ -2075,7 +2059,7 @@ static void rtl8139_weird_interrupt (struct net_device *dev,
2075 void __iomem *ioaddr, 2059 void __iomem *ioaddr,
2076 int status, int link_changed) 2060 int status, int link_changed)
2077{ 2061{
2078 DPRINTK ("%s: Abnormal interrupt, status %8.8x.\n", 2062 pr_debug("%s: Abnormal interrupt, status %8.8x.\n",
2079 dev->name, status); 2063 dev->name, status);
2080 2064
2081 assert (dev != NULL); 2065 assert (dev != NULL);
@@ -2104,7 +2088,7 @@ static void rtl8139_weird_interrupt (struct net_device *dev,
2104 pci_read_config_word (tp->pci_dev, PCI_STATUS, &pci_cmd_status); 2088 pci_read_config_word (tp->pci_dev, PCI_STATUS, &pci_cmd_status);
2105 pci_write_config_word (tp->pci_dev, PCI_STATUS, pci_cmd_status); 2089 pci_write_config_word (tp->pci_dev, PCI_STATUS, pci_cmd_status);
2106 2090
2107 printk (KERN_ERR "%s: PCI Bus error %4.4x.\n", 2091 pr_err("%s: PCI Bus error %4.4x.\n",
2108 dev->name, pci_cmd_status); 2092 dev->name, pci_cmd_status);
2109 } 2093 }
2110} 2094}
@@ -2198,7 +2182,7 @@ static irqreturn_t rtl8139_interrupt (int irq, void *dev_instance)
2198 out: 2182 out:
2199 spin_unlock (&tp->lock); 2183 spin_unlock (&tp->lock);
2200 2184
2201 DPRINTK ("%s: exiting interrupt, intr_status=%#4.4x.\n", 2185 pr_debug("%s: exiting interrupt, intr_status=%#4.4x.\n",
2202 dev->name, RTL_R16 (IntrStatus)); 2186 dev->name, RTL_R16 (IntrStatus));
2203 return IRQ_RETVAL(handled); 2187 return IRQ_RETVAL(handled);
2204} 2188}
@@ -2249,7 +2233,7 @@ static int rtl8139_close (struct net_device *dev)
2249 napi_disable(&tp->napi); 2233 napi_disable(&tp->napi);
2250 2234
2251 if (netif_msg_ifdown(tp)) 2235 if (netif_msg_ifdown(tp))
2252 printk(KERN_DEBUG "%s: Shutting down ethercard, status was 0x%4.4x.\n", 2236 pr_debug("%s: Shutting down ethercard, status was 0x%4.4x.\n",
2253 dev->name, RTL_R16 (IntrStatus)); 2237 dev->name, RTL_R16 (IntrStatus));
2254 2238
2255 spin_lock_irqsave (&tp->lock, flags); 2239 spin_lock_irqsave (&tp->lock, flags);
@@ -2292,11 +2276,11 @@ static int rtl8139_close (struct net_device *dev)
2292 other threads or interrupts aren't messing with the 8139. */ 2276 other threads or interrupts aren't messing with the 8139. */
2293static void rtl8139_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 2277static void rtl8139_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
2294{ 2278{
2295 struct rtl8139_private *np = netdev_priv(dev); 2279 struct rtl8139_private *tp = netdev_priv(dev);
2296 void __iomem *ioaddr = np->mmio_addr; 2280 void __iomem *ioaddr = tp->mmio_addr;
2297 2281
2298 spin_lock_irq(&np->lock); 2282 spin_lock_irq(&tp->lock);
2299 if (rtl_chip_info[np->chipset].flags & HasLWake) { 2283 if (rtl_chip_info[tp->chipset].flags & HasLWake) {
2300 u8 cfg3 = RTL_R8 (Config3); 2284 u8 cfg3 = RTL_R8 (Config3);
2301 u8 cfg5 = RTL_R8 (Config5); 2285 u8 cfg5 = RTL_R8 (Config5);
2302 2286
@@ -2317,7 +2301,7 @@ static void rtl8139_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
2317 if (cfg5 & Cfg5_BWF) 2301 if (cfg5 & Cfg5_BWF)
2318 wol->wolopts |= WAKE_BCAST; 2302 wol->wolopts |= WAKE_BCAST;
2319 } 2303 }
2320 spin_unlock_irq(&np->lock); 2304 spin_unlock_irq(&tp->lock);
2321} 2305}
2322 2306
2323 2307
@@ -2326,19 +2310,19 @@ static void rtl8139_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
2326 aren't messing with the 8139. */ 2310 aren't messing with the 8139. */
2327static int rtl8139_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 2311static int rtl8139_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
2328{ 2312{
2329 struct rtl8139_private *np = netdev_priv(dev); 2313 struct rtl8139_private *tp = netdev_priv(dev);
2330 void __iomem *ioaddr = np->mmio_addr; 2314 void __iomem *ioaddr = tp->mmio_addr;
2331 u32 support; 2315 u32 support;
2332 u8 cfg3, cfg5; 2316 u8 cfg3, cfg5;
2333 2317
2334 support = ((rtl_chip_info[np->chipset].flags & HasLWake) 2318 support = ((rtl_chip_info[tp->chipset].flags & HasLWake)
2335 ? (WAKE_PHY | WAKE_MAGIC 2319 ? (WAKE_PHY | WAKE_MAGIC
2336 | WAKE_UCAST | WAKE_MCAST | WAKE_BCAST) 2320 | WAKE_UCAST | WAKE_MCAST | WAKE_BCAST)
2337 : 0); 2321 : 0);
2338 if (wol->wolopts & ~support) 2322 if (wol->wolopts & ~support)
2339 return -EINVAL; 2323 return -EINVAL;
2340 2324
2341 spin_lock_irq(&np->lock); 2325 spin_lock_irq(&tp->lock);
2342 cfg3 = RTL_R8 (Config3) & ~(Cfg3_LinkUp | Cfg3_Magic); 2326 cfg3 = RTL_R8 (Config3) & ~(Cfg3_LinkUp | Cfg3_Magic);
2343 if (wol->wolopts & WAKE_PHY) 2327 if (wol->wolopts & WAKE_PHY)
2344 cfg3 |= Cfg3_LinkUp; 2328 cfg3 |= Cfg3_LinkUp;
@@ -2359,87 +2343,87 @@ static int rtl8139_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
2359 if (wol->wolopts & WAKE_BCAST) 2343 if (wol->wolopts & WAKE_BCAST)
2360 cfg5 |= Cfg5_BWF; 2344 cfg5 |= Cfg5_BWF;
2361 RTL_W8 (Config5, cfg5); /* need not unlock via Cfg9346 */ 2345 RTL_W8 (Config5, cfg5); /* need not unlock via Cfg9346 */
2362 spin_unlock_irq(&np->lock); 2346 spin_unlock_irq(&tp->lock);
2363 2347
2364 return 0; 2348 return 0;
2365} 2349}
2366 2350
2367static void rtl8139_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 2351static void rtl8139_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
2368{ 2352{
2369 struct rtl8139_private *np = netdev_priv(dev); 2353 struct rtl8139_private *tp = netdev_priv(dev);
2370 strcpy(info->driver, DRV_NAME); 2354 strcpy(info->driver, DRV_NAME);
2371 strcpy(info->version, DRV_VERSION); 2355 strcpy(info->version, DRV_VERSION);
2372 strcpy(info->bus_info, pci_name(np->pci_dev)); 2356 strcpy(info->bus_info, pci_name(tp->pci_dev));
2373 info->regdump_len = np->regs_len; 2357 info->regdump_len = tp->regs_len;
2374} 2358}
2375 2359
2376static int rtl8139_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 2360static int rtl8139_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2377{ 2361{
2378 struct rtl8139_private *np = netdev_priv(dev); 2362 struct rtl8139_private *tp = netdev_priv(dev);
2379 spin_lock_irq(&np->lock); 2363 spin_lock_irq(&tp->lock);
2380 mii_ethtool_gset(&np->mii, cmd); 2364 mii_ethtool_gset(&tp->mii, cmd);
2381 spin_unlock_irq(&np->lock); 2365 spin_unlock_irq(&tp->lock);
2382 return 0; 2366 return 0;
2383} 2367}
2384 2368
2385static int rtl8139_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 2369static int rtl8139_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2386{ 2370{
2387 struct rtl8139_private *np = netdev_priv(dev); 2371 struct rtl8139_private *tp = netdev_priv(dev);
2388 int rc; 2372 int rc;
2389 spin_lock_irq(&np->lock); 2373 spin_lock_irq(&tp->lock);
2390 rc = mii_ethtool_sset(&np->mii, cmd); 2374 rc = mii_ethtool_sset(&tp->mii, cmd);
2391 spin_unlock_irq(&np->lock); 2375 spin_unlock_irq(&tp->lock);
2392 return rc; 2376 return rc;
2393} 2377}
2394 2378
2395static int rtl8139_nway_reset(struct net_device *dev) 2379static int rtl8139_nway_reset(struct net_device *dev)
2396{ 2380{
2397 struct rtl8139_private *np = netdev_priv(dev); 2381 struct rtl8139_private *tp = netdev_priv(dev);
2398 return mii_nway_restart(&np->mii); 2382 return mii_nway_restart(&tp->mii);
2399} 2383}
2400 2384
2401static u32 rtl8139_get_link(struct net_device *dev) 2385static u32 rtl8139_get_link(struct net_device *dev)
2402{ 2386{
2403 struct rtl8139_private *np = netdev_priv(dev); 2387 struct rtl8139_private *tp = netdev_priv(dev);
2404 return mii_link_ok(&np->mii); 2388 return mii_link_ok(&tp->mii);
2405} 2389}
2406 2390
2407static u32 rtl8139_get_msglevel(struct net_device *dev) 2391static u32 rtl8139_get_msglevel(struct net_device *dev)
2408{ 2392{
2409 struct rtl8139_private *np = netdev_priv(dev); 2393 struct rtl8139_private *tp = netdev_priv(dev);
2410 return np->msg_enable; 2394 return tp->msg_enable;
2411} 2395}
2412 2396
2413static void rtl8139_set_msglevel(struct net_device *dev, u32 datum) 2397static void rtl8139_set_msglevel(struct net_device *dev, u32 datum)
2414{ 2398{
2415 struct rtl8139_private *np = netdev_priv(dev); 2399 struct rtl8139_private *tp = netdev_priv(dev);
2416 np->msg_enable = datum; 2400 tp->msg_enable = datum;
2417} 2401}
2418 2402
2419static int rtl8139_get_regs_len(struct net_device *dev) 2403static int rtl8139_get_regs_len(struct net_device *dev)
2420{ 2404{
2421 struct rtl8139_private *np; 2405 struct rtl8139_private *tp;
2422 /* TODO: we are too slack to do reg dumping for pio, for now */ 2406 /* TODO: we are too slack to do reg dumping for pio, for now */
2423 if (use_io) 2407 if (use_io)
2424 return 0; 2408 return 0;
2425 np = netdev_priv(dev); 2409 tp = netdev_priv(dev);
2426 return np->regs_len; 2410 return tp->regs_len;
2427} 2411}
2428 2412
2429static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf) 2413static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf)
2430{ 2414{
2431 struct rtl8139_private *np; 2415 struct rtl8139_private *tp;
2432 2416
2433 /* TODO: we are too slack to do reg dumping for pio, for now */ 2417 /* TODO: we are too slack to do reg dumping for pio, for now */
2434 if (use_io) 2418 if (use_io)
2435 return; 2419 return;
2436 np = netdev_priv(dev); 2420 tp = netdev_priv(dev);
2437 2421
2438 regs->version = RTL_REGS_VER; 2422 regs->version = RTL_REGS_VER;
2439 2423
2440 spin_lock_irq(&np->lock); 2424 spin_lock_irq(&tp->lock);
2441 memcpy_fromio(regbuf, np->mmio_addr, regs->len); 2425 memcpy_fromio(regbuf, tp->mmio_addr, regs->len);
2442 spin_unlock_irq(&np->lock); 2426 spin_unlock_irq(&tp->lock);
2443} 2427}
2444 2428
2445static int rtl8139_get_sset_count(struct net_device *dev, int sset) 2429static int rtl8139_get_sset_count(struct net_device *dev, int sset)
@@ -2454,12 +2438,12 @@ static int rtl8139_get_sset_count(struct net_device *dev, int sset)
2454 2438
2455static void rtl8139_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, u64 *data) 2439static void rtl8139_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, u64 *data)
2456{ 2440{
2457 struct rtl8139_private *np = netdev_priv(dev); 2441 struct rtl8139_private *tp = netdev_priv(dev);
2458 2442
2459 data[0] = np->xstats.early_rx; 2443 data[0] = tp->xstats.early_rx;
2460 data[1] = np->xstats.tx_buf_mapped; 2444 data[1] = tp->xstats.tx_buf_mapped;
2461 data[2] = np->xstats.tx_timeouts; 2445 data[2] = tp->xstats.tx_timeouts;
2462 data[3] = np->xstats.rx_lost_in_ring; 2446 data[3] = tp->xstats.rx_lost_in_ring;
2463} 2447}
2464 2448
2465static void rtl8139_get_strings(struct net_device *dev, u32 stringset, u8 *data) 2449static void rtl8139_get_strings(struct net_device *dev, u32 stringset, u8 *data)
@@ -2486,15 +2470,15 @@ static const struct ethtool_ops rtl8139_ethtool_ops = {
2486 2470
2487static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 2471static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2488{ 2472{
2489 struct rtl8139_private *np = netdev_priv(dev); 2473 struct rtl8139_private *tp = netdev_priv(dev);
2490 int rc; 2474 int rc;
2491 2475
2492 if (!netif_running(dev)) 2476 if (!netif_running(dev))
2493 return -EINVAL; 2477 return -EINVAL;
2494 2478
2495 spin_lock_irq(&np->lock); 2479 spin_lock_irq(&tp->lock);
2496 rc = generic_mii_ioctl(&np->mii, if_mii(rq), cmd, NULL); 2480 rc = generic_mii_ioctl(&tp->mii, if_mii(rq), cmd, NULL);
2497 spin_unlock_irq(&np->lock); 2481 spin_unlock_irq(&tp->lock);
2498 2482
2499 return rc; 2483 return rc;
2500} 2484}
@@ -2527,7 +2511,7 @@ static void __set_rx_mode (struct net_device *dev)
2527 int i, rx_mode; 2511 int i, rx_mode;
2528 u32 tmp; 2512 u32 tmp;
2529 2513
2530 DPRINTK ("%s: rtl8139_set_rx_mode(%4.4x) done -- Rx config %8.8lx.\n", 2514 pr_debug("%s: rtl8139_set_rx_mode(%4.4x) done -- Rx config %8.8lx.\n",
2531 dev->name, dev->flags, RTL_R32 (RxConfig)); 2515 dev->name, dev->flags, RTL_R32 (RxConfig));
2532 2516
2533 /* Note: do not reorder, GCC is clever about common statements. */ 2517 /* Note: do not reorder, GCC is clever about common statements. */
@@ -2643,7 +2627,7 @@ static int __init rtl8139_init_module (void)
2643 * even if no 8139 board is found. 2627 * even if no 8139 board is found.
2644 */ 2628 */
2645#ifdef MODULE 2629#ifdef MODULE
2646 printk (KERN_INFO RTL8139_DRIVER_NAME "\n"); 2630 pr_info(RTL8139_DRIVER_NAME "\n");
2647#endif 2631#endif
2648 2632
2649 return pci_register_driver(&rtl8139_pci_driver); 2633 return pci_register_driver(&rtl8139_pci_driver);