| .. | .. |
|---|
| 47 | 47 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| 48 | 48 | |
|---|
| 49 | 49 | #define DRV_NAME "winbond-840" |
|---|
| 50 | | -#define DRV_VERSION "1.01-e" |
|---|
| 51 | | -#define DRV_RELDATE "Sep-11-2006" |
|---|
| 52 | | - |
|---|
| 53 | 50 | |
|---|
| 54 | 51 | /* Automatically extracted configuration info: |
|---|
| 55 | 52 | probe-func: winbond840_probe |
|---|
| .. | .. |
|---|
| 139 | 136 | #undef PKT_BUF_SZ /* tulip.h also defines this */ |
|---|
| 140 | 137 | #define PKT_BUF_SZ 1536 /* Size of each temporary Rx buffer.*/ |
|---|
| 141 | 138 | |
|---|
| 142 | | -/* These identify the driver base version and may not be removed. */ |
|---|
| 143 | | -static const char version[] __initconst = |
|---|
| 144 | | - "v" DRV_VERSION " (2.4 port) " |
|---|
| 145 | | - DRV_RELDATE " Donald Becker <becker@scyld.com>\n" |
|---|
| 146 | | - " http://www.scyld.com/network/drivers.html\n"; |
|---|
| 147 | | - |
|---|
| 148 | 139 | MODULE_AUTHOR("Donald Becker <becker@scyld.com>"); |
|---|
| 149 | 140 | MODULE_DESCRIPTION("Winbond W89c840 Ethernet driver"); |
|---|
| 150 | 141 | MODULE_LICENSE("GPL"); |
|---|
| 151 | | -MODULE_VERSION(DRV_VERSION); |
|---|
| 152 | 142 | |
|---|
| 153 | 143 | module_param(max_interrupt_work, int, 0); |
|---|
| 154 | 144 | module_param(debug, int, 0); |
|---|
| .. | .. |
|---|
| 331 | 321 | static void init_rxtx_rings(struct net_device *dev); |
|---|
| 332 | 322 | static void free_rxtx_rings(struct netdev_private *np); |
|---|
| 333 | 323 | static void init_registers(struct net_device *dev); |
|---|
| 334 | | -static void tx_timeout(struct net_device *dev); |
|---|
| 324 | +static void tx_timeout(struct net_device *dev, unsigned int txqueue); |
|---|
| 335 | 325 | static int alloc_ringdesc(struct net_device *dev); |
|---|
| 336 | 326 | static void free_ringdesc(struct netdev_private *np); |
|---|
| 337 | 327 | static netdev_tx_t start_tx(struct sk_buff *skb, struct net_device *dev); |
|---|
| .. | .. |
|---|
| 374 | 364 | |
|---|
| 375 | 365 | irq = pdev->irq; |
|---|
| 376 | 366 | |
|---|
| 377 | | - if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { |
|---|
| 367 | + if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { |
|---|
| 378 | 368 | pr_warn("Device %s disabled due to DMA limitations\n", |
|---|
| 379 | 369 | pci_name(pdev)); |
|---|
| 380 | 370 | return -EIO; |
|---|
| .. | .. |
|---|
| 638 | 628 | goto out_err; |
|---|
| 639 | 629 | |
|---|
| 640 | 630 | if (debug > 1) |
|---|
| 641 | | - netdev_dbg(dev, "w89c840_open() irq %d\n", irq); |
|---|
| 631 | + netdev_dbg(dev, "%s() irq %d\n", __func__, irq); |
|---|
| 642 | 632 | |
|---|
| 643 | | - if((i=alloc_ringdesc(dev))) |
|---|
| 633 | + i = alloc_ringdesc(dev); |
|---|
| 634 | + if (i) |
|---|
| 644 | 635 | goto out_err; |
|---|
| 645 | 636 | |
|---|
| 646 | 637 | spin_lock_irq(&np->lock); |
|---|
| .. | .. |
|---|
| 650 | 641 | |
|---|
| 651 | 642 | netif_start_queue(dev); |
|---|
| 652 | 643 | if (debug > 2) |
|---|
| 653 | | - netdev_dbg(dev, "Done netdev_open()\n"); |
|---|
| 644 | + netdev_dbg(dev, "Done %s()\n", __func__); |
|---|
| 654 | 645 | |
|---|
| 655 | 646 | /* Set the timer to check for link beat. */ |
|---|
| 656 | 647 | timer_setup(&np->timer, netdev_timer, 0); |
|---|
| .. | .. |
|---|
| 810 | 801 | np->rx_skbuff[i] = skb; |
|---|
| 811 | 802 | if (skb == NULL) |
|---|
| 812 | 803 | break; |
|---|
| 813 | | - np->rx_addr[i] = pci_map_single(np->pci_dev,skb->data, |
|---|
| 814 | | - np->rx_buf_sz,PCI_DMA_FROMDEVICE); |
|---|
| 804 | + np->rx_addr[i] = dma_map_single(&np->pci_dev->dev, skb->data, |
|---|
| 805 | + np->rx_buf_sz, |
|---|
| 806 | + DMA_FROM_DEVICE); |
|---|
| 815 | 807 | |
|---|
| 816 | 808 | np->rx_ring[i].buffer1 = np->rx_addr[i]; |
|---|
| 817 | 809 | np->rx_ring[i].status = DescOwned; |
|---|
| .. | .. |
|---|
| 841 | 833 | for (i = 0; i < RX_RING_SIZE; i++) { |
|---|
| 842 | 834 | np->rx_ring[i].status = 0; |
|---|
| 843 | 835 | if (np->rx_skbuff[i]) { |
|---|
| 844 | | - pci_unmap_single(np->pci_dev, |
|---|
| 845 | | - np->rx_addr[i], |
|---|
| 846 | | - np->rx_skbuff[i]->len, |
|---|
| 847 | | - PCI_DMA_FROMDEVICE); |
|---|
| 836 | + dma_unmap_single(&np->pci_dev->dev, np->rx_addr[i], |
|---|
| 837 | + np->rx_skbuff[i]->len, |
|---|
| 838 | + DMA_FROM_DEVICE); |
|---|
| 848 | 839 | dev_kfree_skb(np->rx_skbuff[i]); |
|---|
| 849 | 840 | } |
|---|
| 850 | 841 | np->rx_skbuff[i] = NULL; |
|---|
| 851 | 842 | } |
|---|
| 852 | 843 | for (i = 0; i < TX_RING_SIZE; i++) { |
|---|
| 853 | 844 | if (np->tx_skbuff[i]) { |
|---|
| 854 | | - pci_unmap_single(np->pci_dev, |
|---|
| 855 | | - np->tx_addr[i], |
|---|
| 856 | | - np->tx_skbuff[i]->len, |
|---|
| 857 | | - PCI_DMA_TODEVICE); |
|---|
| 845 | + dma_unmap_single(&np->pci_dev->dev, np->tx_addr[i], |
|---|
| 846 | + np->tx_skbuff[i]->len, DMA_TO_DEVICE); |
|---|
| 858 | 847 | dev_kfree_skb(np->tx_skbuff[i]); |
|---|
| 859 | 848 | } |
|---|
| 860 | 849 | np->tx_skbuff[i] = NULL; |
|---|
| .. | .. |
|---|
| 919 | 908 | iowrite32(0, ioaddr + RxStartDemand); |
|---|
| 920 | 909 | } |
|---|
| 921 | 910 | |
|---|
| 922 | | -static void tx_timeout(struct net_device *dev) |
|---|
| 911 | +static void tx_timeout(struct net_device *dev, unsigned int txqueue) |
|---|
| 923 | 912 | { |
|---|
| 924 | 913 | struct netdev_private *np = netdev_priv(dev); |
|---|
| 925 | 914 | void __iomem *ioaddr = np->base_addr; |
|---|
| .. | .. |
|---|
| 972 | 961 | |
|---|
| 973 | 962 | np->rx_buf_sz = (dev->mtu <= 1500 ? PKT_BUF_SZ : dev->mtu + 32); |
|---|
| 974 | 963 | |
|---|
| 975 | | - np->rx_ring = pci_alloc_consistent(np->pci_dev, |
|---|
| 976 | | - sizeof(struct w840_rx_desc)*RX_RING_SIZE + |
|---|
| 977 | | - sizeof(struct w840_tx_desc)*TX_RING_SIZE, |
|---|
| 978 | | - &np->ring_dma_addr); |
|---|
| 964 | + np->rx_ring = dma_alloc_coherent(&np->pci_dev->dev, |
|---|
| 965 | + sizeof(struct w840_rx_desc) * RX_RING_SIZE + |
|---|
| 966 | + sizeof(struct w840_tx_desc) * TX_RING_SIZE, |
|---|
| 967 | + &np->ring_dma_addr, GFP_KERNEL); |
|---|
| 979 | 968 | if(!np->rx_ring) |
|---|
| 980 | 969 | return -ENOMEM; |
|---|
| 981 | 970 | init_rxtx_rings(dev); |
|---|
| .. | .. |
|---|
| 984 | 973 | |
|---|
| 985 | 974 | static void free_ringdesc(struct netdev_private *np) |
|---|
| 986 | 975 | { |
|---|
| 987 | | - pci_free_consistent(np->pci_dev, |
|---|
| 988 | | - sizeof(struct w840_rx_desc)*RX_RING_SIZE + |
|---|
| 989 | | - sizeof(struct w840_tx_desc)*TX_RING_SIZE, |
|---|
| 990 | | - np->rx_ring, np->ring_dma_addr); |
|---|
| 976 | + dma_free_coherent(&np->pci_dev->dev, |
|---|
| 977 | + sizeof(struct w840_rx_desc) * RX_RING_SIZE + |
|---|
| 978 | + sizeof(struct w840_tx_desc) * TX_RING_SIZE, |
|---|
| 979 | + np->rx_ring, np->ring_dma_addr); |
|---|
| 991 | 980 | |
|---|
| 992 | 981 | } |
|---|
| 993 | 982 | |
|---|
| .. | .. |
|---|
| 1002 | 991 | /* Calculate the next Tx descriptor entry. */ |
|---|
| 1003 | 992 | entry = np->cur_tx % TX_RING_SIZE; |
|---|
| 1004 | 993 | |
|---|
| 1005 | | - np->tx_addr[entry] = pci_map_single(np->pci_dev, |
|---|
| 1006 | | - skb->data,skb->len, PCI_DMA_TODEVICE); |
|---|
| 994 | + np->tx_addr[entry] = dma_map_single(&np->pci_dev->dev, skb->data, |
|---|
| 995 | + skb->len, DMA_TO_DEVICE); |
|---|
| 1007 | 996 | np->tx_skbuff[entry] = skb; |
|---|
| 1008 | 997 | |
|---|
| 1009 | 998 | np->tx_ring[entry].buffer1 = np->tx_addr[entry]; |
|---|
| .. | .. |
|---|
| 1086 | 1075 | np->stats.tx_packets++; |
|---|
| 1087 | 1076 | } |
|---|
| 1088 | 1077 | /* Free the original skb. */ |
|---|
| 1089 | | - pci_unmap_single(np->pci_dev,np->tx_addr[entry], |
|---|
| 1090 | | - np->tx_skbuff[entry]->len, |
|---|
| 1091 | | - PCI_DMA_TODEVICE); |
|---|
| 1078 | + dma_unmap_single(&np->pci_dev->dev, np->tx_addr[entry], |
|---|
| 1079 | + np->tx_skbuff[entry]->len, DMA_TO_DEVICE); |
|---|
| 1092 | 1080 | np->tx_q_bytes -= np->tx_skbuff[entry]->len; |
|---|
| 1093 | 1081 | dev_kfree_skb_irq(np->tx_skbuff[entry]); |
|---|
| 1094 | 1082 | np->tx_skbuff[entry] = NULL; |
|---|
| .. | .. |
|---|
| 1225 | 1213 | if (pkt_len < rx_copybreak && |
|---|
| 1226 | 1214 | (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) { |
|---|
| 1227 | 1215 | skb_reserve(skb, 2); /* 16 byte align the IP header */ |
|---|
| 1228 | | - pci_dma_sync_single_for_cpu(np->pci_dev,np->rx_addr[entry], |
|---|
| 1229 | | - np->rx_skbuff[entry]->len, |
|---|
| 1230 | | - PCI_DMA_FROMDEVICE); |
|---|
| 1216 | + dma_sync_single_for_cpu(&np->pci_dev->dev, |
|---|
| 1217 | + np->rx_addr[entry], |
|---|
| 1218 | + np->rx_skbuff[entry]->len, |
|---|
| 1219 | + DMA_FROM_DEVICE); |
|---|
| 1231 | 1220 | skb_copy_to_linear_data(skb, np->rx_skbuff[entry]->data, pkt_len); |
|---|
| 1232 | 1221 | skb_put(skb, pkt_len); |
|---|
| 1233 | | - pci_dma_sync_single_for_device(np->pci_dev,np->rx_addr[entry], |
|---|
| 1234 | | - np->rx_skbuff[entry]->len, |
|---|
| 1235 | | - PCI_DMA_FROMDEVICE); |
|---|
| 1222 | + dma_sync_single_for_device(&np->pci_dev->dev, |
|---|
| 1223 | + np->rx_addr[entry], |
|---|
| 1224 | + np->rx_skbuff[entry]->len, |
|---|
| 1225 | + DMA_FROM_DEVICE); |
|---|
| 1236 | 1226 | } else { |
|---|
| 1237 | | - pci_unmap_single(np->pci_dev,np->rx_addr[entry], |
|---|
| 1238 | | - np->rx_skbuff[entry]->len, |
|---|
| 1239 | | - PCI_DMA_FROMDEVICE); |
|---|
| 1227 | + dma_unmap_single(&np->pci_dev->dev, |
|---|
| 1228 | + np->rx_addr[entry], |
|---|
| 1229 | + np->rx_skbuff[entry]->len, |
|---|
| 1230 | + DMA_FROM_DEVICE); |
|---|
| 1240 | 1231 | skb_put(skb = np->rx_skbuff[entry], pkt_len); |
|---|
| 1241 | 1232 | np->rx_skbuff[entry] = NULL; |
|---|
| 1242 | 1233 | } |
|---|
| .. | .. |
|---|
| 1266 | 1257 | np->rx_skbuff[entry] = skb; |
|---|
| 1267 | 1258 | if (skb == NULL) |
|---|
| 1268 | 1259 | break; /* Better luck next round. */ |
|---|
| 1269 | | - np->rx_addr[entry] = pci_map_single(np->pci_dev, |
|---|
| 1270 | | - skb->data, |
|---|
| 1271 | | - np->rx_buf_sz, PCI_DMA_FROMDEVICE); |
|---|
| 1260 | + np->rx_addr[entry] = dma_map_single(&np->pci_dev->dev, |
|---|
| 1261 | + skb->data, |
|---|
| 1262 | + np->rx_buf_sz, |
|---|
| 1263 | + DMA_FROM_DEVICE); |
|---|
| 1272 | 1264 | np->rx_ring[entry].buffer1 = np->rx_addr[entry]; |
|---|
| 1273 | 1265 | } |
|---|
| 1274 | 1266 | wmb(); |
|---|
| .. | .. |
|---|
| 1383 | 1375 | struct netdev_private *np = netdev_priv(dev); |
|---|
| 1384 | 1376 | |
|---|
| 1385 | 1377 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
|---|
| 1386 | | - strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
|---|
| 1387 | 1378 | strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); |
|---|
| 1388 | 1379 | } |
|---|
| 1389 | 1380 | |
|---|
| .. | .. |
|---|
| 1452 | 1443 | switch(cmd) { |
|---|
| 1453 | 1444 | case SIOCGMIIPHY: /* Get address of MII PHY in use. */ |
|---|
| 1454 | 1445 | data->phy_id = ((struct netdev_private *)netdev_priv(dev))->phys[0] & 0x1f; |
|---|
| 1455 | | - /* Fall Through */ |
|---|
| 1446 | + fallthrough; |
|---|
| 1456 | 1447 | |
|---|
| 1457 | 1448 | case SIOCGMIIREG: /* Read MII PHY register. */ |
|---|
| 1458 | 1449 | spin_lock_irq(&np->lock); |
|---|
| .. | .. |
|---|
| 1538 | 1529 | } |
|---|
| 1539 | 1530 | } |
|---|
| 1540 | 1531 | |
|---|
| 1541 | | -#ifdef CONFIG_PM |
|---|
| 1542 | | - |
|---|
| 1543 | 1532 | /* |
|---|
| 1544 | 1533 | * suspend/resume synchronization: |
|---|
| 1545 | 1534 | * - open, close, do_ioctl: |
|---|
| .. | .. |
|---|
| 1563 | 1552 | * Detach must occur under spin_unlock_irq(), interrupts from a detached |
|---|
| 1564 | 1553 | * device would cause an irq storm. |
|---|
| 1565 | 1554 | */ |
|---|
| 1566 | | -static int w840_suspend (struct pci_dev *pdev, pm_message_t state) |
|---|
| 1555 | +static int __maybe_unused w840_suspend(struct device *dev_d) |
|---|
| 1567 | 1556 | { |
|---|
| 1568 | | - struct net_device *dev = pci_get_drvdata (pdev); |
|---|
| 1557 | + struct net_device *dev = dev_get_drvdata(dev_d); |
|---|
| 1569 | 1558 | struct netdev_private *np = netdev_priv(dev); |
|---|
| 1570 | 1559 | void __iomem *ioaddr = np->base_addr; |
|---|
| 1571 | 1560 | |
|---|
| .. | .. |
|---|
| 1598 | 1587 | return 0; |
|---|
| 1599 | 1588 | } |
|---|
| 1600 | 1589 | |
|---|
| 1601 | | -static int w840_resume (struct pci_dev *pdev) |
|---|
| 1590 | +static int __maybe_unused w840_resume(struct device *dev_d) |
|---|
| 1602 | 1591 | { |
|---|
| 1603 | | - struct net_device *dev = pci_get_drvdata (pdev); |
|---|
| 1592 | + struct net_device *dev = dev_get_drvdata(dev_d); |
|---|
| 1604 | 1593 | struct netdev_private *np = netdev_priv(dev); |
|---|
| 1605 | | - int retval = 0; |
|---|
| 1606 | 1594 | |
|---|
| 1607 | 1595 | rtnl_lock(); |
|---|
| 1608 | 1596 | if (netif_device_present(dev)) |
|---|
| 1609 | 1597 | goto out; /* device not suspended */ |
|---|
| 1610 | 1598 | if (netif_running(dev)) { |
|---|
| 1611 | | - if ((retval = pci_enable_device(pdev))) { |
|---|
| 1612 | | - dev_err(&dev->dev, |
|---|
| 1613 | | - "pci_enable_device failed in resume\n"); |
|---|
| 1614 | | - goto out; |
|---|
| 1615 | | - } |
|---|
| 1616 | 1599 | spin_lock_irq(&np->lock); |
|---|
| 1617 | 1600 | iowrite32(1, np->base_addr+PCIBusCfg); |
|---|
| 1618 | 1601 | ioread32(np->base_addr+PCIBusCfg); |
|---|
| .. | .. |
|---|
| 1630 | 1613 | } |
|---|
| 1631 | 1614 | out: |
|---|
| 1632 | 1615 | rtnl_unlock(); |
|---|
| 1633 | | - return retval; |
|---|
| 1616 | + return 0; |
|---|
| 1634 | 1617 | } |
|---|
| 1635 | | -#endif |
|---|
| 1618 | + |
|---|
| 1619 | +static SIMPLE_DEV_PM_OPS(w840_pm_ops, w840_suspend, w840_resume); |
|---|
| 1636 | 1620 | |
|---|
| 1637 | 1621 | static struct pci_driver w840_driver = { |
|---|
| 1638 | 1622 | .name = DRV_NAME, |
|---|
| 1639 | 1623 | .id_table = w840_pci_tbl, |
|---|
| 1640 | 1624 | .probe = w840_probe1, |
|---|
| 1641 | 1625 | .remove = w840_remove1, |
|---|
| 1642 | | -#ifdef CONFIG_PM |
|---|
| 1643 | | - .suspend = w840_suspend, |
|---|
| 1644 | | - .resume = w840_resume, |
|---|
| 1645 | | -#endif |
|---|
| 1626 | + .driver.pm = &w840_pm_ops, |
|---|
| 1646 | 1627 | }; |
|---|
| 1647 | 1628 | |
|---|
| 1648 | 1629 | static int __init w840_init(void) |
|---|
| 1649 | 1630 | { |
|---|
| 1650 | | - printk(version); |
|---|
| 1651 | 1631 | return pci_register_driver(&w840_driver); |
|---|
| 1652 | 1632 | } |
|---|
| 1653 | 1633 | |
|---|