hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/ethernet/dlink/sundance.c
....@@ -18,14 +18,11 @@
1818 http://www.scyld.com/network/sundance.html
1919 [link no longer provides useful info -jgarzik]
2020 Archives of the mailing list are still available at
21
- http://www.beowulf.org/pipermail/netdrivers/
21
+ https://www.beowulf.org/pipermail/netdrivers/
2222
2323 */
2424
2525 #define DRV_NAME "sundance"
26
-#define DRV_VERSION "1.2"
27
-#define DRV_RELDATE "11-Sep-2006"
28
-
2926
3027 /* The user-configurable values.
3128 These may be modified when a driver module is loaded.*/
....@@ -100,11 +97,6 @@
10097 #include <linux/crc32.h>
10198 #include <linux/ethtool.h>
10299 #include <linux/mii.h>
103
-
104
-/* These identify the driver base version and may not be removed. */
105
-static const char version[] =
106
- KERN_INFO DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE
107
- " Written by Donald Becker\n";
108100
109101 MODULE_AUTHOR("Donald Becker <becker@scyld.com>");
110102 MODULE_DESCRIPTION("Sundance Alta Ethernet driver");
....@@ -375,6 +367,7 @@
375367 dma_addr_t tx_ring_dma;
376368 dma_addr_t rx_ring_dma;
377369 struct timer_list timer; /* Media monitoring timer. */
370
+ struct net_device *ndev; /* backpointer */
378371 /* ethtool extra stats */
379372 struct {
380373 u64 tx_multiple_collisions;
....@@ -432,13 +425,13 @@
432425 static int netdev_open(struct net_device *dev);
433426 static void check_duplex(struct net_device *dev);
434427 static void netdev_timer(struct timer_list *t);
435
-static void tx_timeout(struct net_device *dev);
428
+static void tx_timeout(struct net_device *dev, unsigned int txqueue);
436429 static void init_ring(struct net_device *dev);
437430 static netdev_tx_t start_tx(struct sk_buff *skb, struct net_device *dev);
438431 static int reset_tx (struct net_device *dev);
439432 static irqreturn_t intr_handler(int irq, void *dev_instance);
440
-static void rx_poll(unsigned long data);
441
-static void tx_poll(unsigned long data);
433
+static void rx_poll(struct tasklet_struct *t);
434
+static void tx_poll(struct tasklet_struct *t);
442435 static void refill_rx (struct net_device *dev);
443436 static void netdev_error(struct net_device *dev, int intr_status);
444437 static void netdev_error(struct net_device *dev, int intr_status);
....@@ -516,13 +509,6 @@
516509 #endif
517510 int phy, phy_end, phy_idx = 0;
518511
519
-/* when built into the kernel, we only print version if device is found */
520
-#ifndef MODULE
521
- static int printed_version;
522
- if (!printed_version++)
523
- printk(version);
524
-#endif
525
-
526512 if (pci_enable_device(pdev))
527513 return -EIO;
528514 pci_set_master(pdev);
....@@ -546,14 +532,15 @@
546532 cpu_to_le16(eeprom_read(ioaddr, i + EEPROM_SA_OFFSET));
547533
548534 np = netdev_priv(dev);
535
+ np->ndev = dev;
549536 np->base = ioaddr;
550537 np->pci_dev = pdev;
551538 np->chip_id = chip_idx;
552539 np->msg_enable = (1 << debug) - 1;
553540 spin_lock_init(&np->lock);
554541 spin_lock_init(&np->statlock);
555
- tasklet_init(&np->rx_tasklet, rx_poll, (unsigned long)dev);
556
- tasklet_init(&np->tx_tasklet, tx_poll, (unsigned long)dev);
542
+ tasklet_setup(&np->rx_tasklet, rx_poll);
543
+ tasklet_setup(&np->tx_tasklet, tx_poll);
557544
558545 ring_space = dma_alloc_coherent(&pdev->dev, TX_TOTAL_SIZE,
559546 &ring_dma, GFP_KERNEL);
....@@ -969,7 +956,7 @@
969956 add_timer(&np->timer);
970957 }
971958
972
-static void tx_timeout(struct net_device *dev)
959
+static void tx_timeout(struct net_device *dev, unsigned int txqueue)
973960 {
974961 struct netdev_private *np = netdev_priv(dev);
975962 void __iomem *ioaddr = np->base;
....@@ -1069,10 +1056,9 @@
10691056 }
10701057 }
10711058
1072
-static void tx_poll (unsigned long data)
1059
+static void tx_poll(struct tasklet_struct *t)
10731060 {
1074
- struct net_device *dev = (struct net_device *)data;
1075
- struct netdev_private *np = netdev_priv(dev);
1061
+ struct netdev_private *np = from_tasklet(np, t, tx_tasklet);
10761062 unsigned head = np->cur_task % TX_RING_SIZE;
10771063 struct netdev_desc *txdesc =
10781064 &np->tx_ring[(np->cur_tx - 1) % TX_RING_SIZE];
....@@ -1193,7 +1179,6 @@
11931179 int handled = 0;
11941180 int i;
11951181
1196
-
11971182 do {
11981183 int intr_status = ioread16(ioaddr + IntrStatus);
11991184 iowrite16(intr_status, ioaddr + IntrStatus);
....@@ -1286,7 +1271,7 @@
12861271 dma_unmap_single(&np->pci_dev->dev,
12871272 le32_to_cpu(np->tx_ring[entry].frag[0].addr),
12881273 skb->len, DMA_TO_DEVICE);
1289
- dev_kfree_skb_irq (np->tx_skbuff[entry]);
1274
+ dev_consume_skb_irq(np->tx_skbuff[entry]);
12901275 np->tx_skbuff[entry] = NULL;
12911276 np->tx_ring[entry].frag[0].addr = 0;
12921277 np->tx_ring[entry].frag[0].length = 0;
....@@ -1305,7 +1290,7 @@
13051290 dma_unmap_single(&np->pci_dev->dev,
13061291 le32_to_cpu(np->tx_ring[entry].frag[0].addr),
13071292 skb->len, DMA_TO_DEVICE);
1308
- dev_kfree_skb_irq (np->tx_skbuff[entry]);
1293
+ dev_consume_skb_irq(np->tx_skbuff[entry]);
13091294 np->tx_skbuff[entry] = NULL;
13101295 np->tx_ring[entry].frag[0].addr = 0;
13111296 np->tx_ring[entry].frag[0].length = 0;
....@@ -1328,10 +1313,10 @@
13281313 return IRQ_RETVAL(handled);
13291314 }
13301315
1331
-static void rx_poll(unsigned long data)
1316
+static void rx_poll(struct tasklet_struct *t)
13321317 {
1333
- struct net_device *dev = (struct net_device *)data;
1334
- struct netdev_private *np = netdev_priv(dev);
1318
+ struct netdev_private *np = from_tasklet(np, t, rx_tasklet);
1319
+ struct net_device *dev = np->ndev;
13351320 int entry = np->cur_rx % RX_RING_SIZE;
13361321 int boguscnt = np->budget;
13371322 void __iomem *ioaddr = np->base;
....@@ -1658,7 +1643,6 @@
16581643 {
16591644 struct netdev_private *np = netdev_priv(dev);
16601645 strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
1661
- strlcpy(info->version, DRV_VERSION, sizeof(info->version));
16621646 strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info));
16631647 }
16641648
....@@ -1945,11 +1929,9 @@
19451929 }
19461930 }
19471931
1948
-#ifdef CONFIG_PM
1949
-
1950
-static int sundance_suspend(struct pci_dev *pci_dev, pm_message_t state)
1932
+static int __maybe_unused sundance_suspend(struct device *dev_d)
19511933 {
1952
- struct net_device *dev = pci_get_drvdata(pci_dev);
1934
+ struct net_device *dev = dev_get_drvdata(dev_d);
19531935 struct netdev_private *np = netdev_priv(dev);
19541936 void __iomem *ioaddr = np->base;
19551937
....@@ -1959,29 +1941,23 @@
19591941 netdev_close(dev);
19601942 netif_device_detach(dev);
19611943
1962
- pci_save_state(pci_dev);
19631944 if (np->wol_enabled) {
19641945 iowrite8(AcceptBroadcast | AcceptMyPhys, ioaddr + RxMode);
19651946 iowrite16(RxEnable, ioaddr + MACCtrl1);
19661947 }
1967
- pci_enable_wake(pci_dev, pci_choose_state(pci_dev, state),
1968
- np->wol_enabled);
1969
- pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
1948
+
1949
+ device_set_wakeup_enable(dev_d, np->wol_enabled);
19701950
19711951 return 0;
19721952 }
19731953
1974
-static int sundance_resume(struct pci_dev *pci_dev)
1954
+static int __maybe_unused sundance_resume(struct device *dev_d)
19751955 {
1976
- struct net_device *dev = pci_get_drvdata(pci_dev);
1956
+ struct net_device *dev = dev_get_drvdata(dev_d);
19771957 int err = 0;
19781958
19791959 if (!netif_running(dev))
19801960 return 0;
1981
-
1982
- pci_set_power_state(pci_dev, PCI_D0);
1983
- pci_restore_state(pci_dev);
1984
- pci_enable_wake(pci_dev, PCI_D0, 0);
19851961
19861962 err = netdev_open(dev);
19871963 if (err) {
....@@ -1996,25 +1972,18 @@
19961972 return err;
19971973 }
19981974
1999
-#endif /* CONFIG_PM */
1975
+static SIMPLE_DEV_PM_OPS(sundance_pm_ops, sundance_suspend, sundance_resume);
20001976
20011977 static struct pci_driver sundance_driver = {
20021978 .name = DRV_NAME,
20031979 .id_table = sundance_pci_tbl,
20041980 .probe = sundance_probe1,
20051981 .remove = sundance_remove1,
2006
-#ifdef CONFIG_PM
2007
- .suspend = sundance_suspend,
2008
- .resume = sundance_resume,
2009
-#endif /* CONFIG_PM */
1982
+ .driver.pm = &sundance_pm_ops,
20101983 };
20111984
20121985 static int __init sundance_init(void)
20131986 {
2014
-/* when a module, this is printed whether or not devices are found in probe */
2015
-#ifdef MODULE
2016
- printk(version);
2017
-#endif
20181987 return pci_register_driver(&sundance_driver);
20191988 }
20201989