hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/ethernet/ti/tlan.c
....@@ -69,7 +69,9 @@
6969 MODULE_DESCRIPTION("Driver for TI ThunderLAN based ethernet PCI adapters");
7070 MODULE_LICENSE("GPL");
7171
72
-/* Turn on debugging. See Documentation/networking/tlan.txt for details */
72
+/* Turn on debugging.
73
+ * See Documentation/networking/device_drivers/ethernet/ti/tlan.rst for details
74
+ */
7375 static int debug;
7476 module_param(debug, int, 0);
7577 MODULE_PARM_DESC(debug, "ThunderLAN debug mask");
....@@ -159,7 +161,7 @@
159161 static int tlan_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
160162 static int tlan_probe1(struct pci_dev *pdev, long ioaddr,
161163 int irq, int rev, const struct pci_device_id *ent);
162
-static void tlan_tx_timeout(struct net_device *dev);
164
+static void tlan_tx_timeout(struct net_device *dev, unsigned int txqueue);
163165 static void tlan_tx_timeout_work(struct work_struct *work);
164166 static int tlan_init_one(struct pci_dev *pdev,
165167 const struct pci_device_id *ent);
....@@ -303,9 +305,8 @@
303305 unregister_netdev(dev);
304306
305307 if (priv->dma_storage) {
306
- pci_free_consistent(priv->pci_dev,
307
- priv->dma_size, priv->dma_storage,
308
- priv->dma_storage_dma);
308
+ dma_free_coherent(&priv->pci_dev->dev, priv->dma_size,
309
+ priv->dma_storage, priv->dma_storage_dma);
309310 }
310311
311312 #ifdef CONFIG_PCI
....@@ -342,33 +343,21 @@
342343 }
343344 }
344345
345
-#ifdef CONFIG_PM
346
-
347
-static int tlan_suspend(struct pci_dev *pdev, pm_message_t state)
346
+static int __maybe_unused tlan_suspend(struct device *dev_d)
348347 {
349
- struct net_device *dev = pci_get_drvdata(pdev);
348
+ struct net_device *dev = dev_get_drvdata(dev_d);
350349
351350 if (netif_running(dev))
352351 tlan_stop(dev);
353352
354353 netif_device_detach(dev);
355
- pci_save_state(pdev);
356
- pci_disable_device(pdev);
357
- pci_wake_from_d3(pdev, false);
358
- pci_set_power_state(pdev, PCI_D3hot);
359354
360355 return 0;
361356 }
362357
363
-static int tlan_resume(struct pci_dev *pdev)
358
+static int __maybe_unused tlan_resume(struct device *dev_d)
364359 {
365
- struct net_device *dev = pci_get_drvdata(pdev);
366
- int rc = pci_enable_device(pdev);
367
-
368
- if (rc)
369
- return rc;
370
- pci_restore_state(pdev);
371
- pci_enable_wake(pdev, PCI_D0, 0);
360
+ struct net_device *dev = dev_get_drvdata(dev_d);
372361 netif_device_attach(dev);
373362
374363 if (netif_running(dev))
....@@ -377,21 +366,14 @@
377366 return 0;
378367 }
379368
380
-#else /* CONFIG_PM */
381
-
382
-#define tlan_suspend NULL
383
-#define tlan_resume NULL
384
-
385
-#endif /* CONFIG_PM */
386
-
369
+static SIMPLE_DEV_PM_OPS(tlan_pm_ops, tlan_suspend, tlan_resume);
387370
388371 static struct pci_driver tlan_driver = {
389372 .name = "tlan",
390373 .id_table = tlan_pci_tbl,
391374 .probe = tlan_init_one,
392375 .remove = tlan_remove_one,
393
- .suspend = tlan_suspend,
394
- .resume = tlan_resume,
376
+ .driver.pm = &tlan_pm_ops,
395377 };
396378
397379 static int __init tlan_probe(void)
....@@ -498,7 +480,7 @@
498480
499481 priv->adapter = &board_info[ent->driver_data];
500482
501
- rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
483
+ rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
502484 if (rc) {
503485 pr_err("No suitable PCI mapping available\n");
504486 goto err_out_free_dev;
....@@ -600,8 +582,8 @@
600582 return 0;
601583
602584 err_out_uninit:
603
- pci_free_consistent(priv->pci_dev, priv->dma_size, priv->dma_storage,
604
- priv->dma_storage_dma);
585
+ dma_free_coherent(&priv->pci_dev->dev, priv->dma_size,
586
+ priv->dma_storage, priv->dma_storage_dma);
605587 err_out_free_dev:
606588 free_netdev(dev);
607589 err_out_regions:
....@@ -625,9 +607,9 @@
625607 dev = tlan_eisa_devices;
626608 priv = netdev_priv(dev);
627609 if (priv->dma_storage) {
628
- pci_free_consistent(priv->pci_dev, priv->dma_size,
629
- priv->dma_storage,
630
- priv->dma_storage_dma);
610
+ dma_free_coherent(&priv->pci_dev->dev, priv->dma_size,
611
+ priv->dma_storage,
612
+ priv->dma_storage_dma);
631613 }
632614 release_region(dev->base_addr, 0x10);
633615 unregister_netdev(dev);
....@@ -840,9 +822,8 @@
840822
841823 dma_size = (TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS)
842824 * (sizeof(struct tlan_list));
843
- priv->dma_storage = pci_alloc_consistent(priv->pci_dev,
844
- dma_size,
845
- &priv->dma_storage_dma);
825
+ priv->dma_storage = dma_alloc_coherent(&priv->pci_dev->dev, dma_size,
826
+ &priv->dma_storage_dma, GFP_KERNEL);
846827 priv->dma_size = dma_size;
847828
848829 if (priv->dma_storage == NULL) {
....@@ -850,7 +831,6 @@
850831 dev->name);
851832 return -ENOMEM;
852833 }
853
- memset(priv->dma_storage, 0, dma_size);
854834 priv->rx_list = (struct tlan_list *)
855835 ALIGN((unsigned long)priv->dma_storage, 8);
856836 priv->rx_list_dma = ALIGN(priv->dma_storage_dma, 8);
....@@ -963,7 +943,7 @@
963943 switch (cmd) {
964944 case SIOCGMIIPHY: /* get address of MII PHY in use. */
965945 data->phy_id = phy;
966
- /* fall through */
946
+ fallthrough;
967947
968948
969949 case SIOCGMIIREG: /* read MII PHY register. */
....@@ -993,7 +973,7 @@
993973 *
994974 **************************************************************/
995975
996
-static void tlan_tx_timeout(struct net_device *dev)
976
+static void tlan_tx_timeout(struct net_device *dev, unsigned int txqueue)
997977 {
998978
999979 TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Transmit timed out.\n", dev->name);
....@@ -1024,7 +1004,7 @@
10241004 struct tlan_priv *priv =
10251005 container_of(work, struct tlan_priv, tlan_tqueue);
10261006
1027
- tlan_tx_timeout(priv->dev);
1007
+ tlan_tx_timeout(priv->dev, UINT_MAX);
10281008 }
10291009
10301010
....@@ -1084,9 +1064,9 @@
10841064
10851065 tail_list->forward = 0;
10861066
1087
- tail_list->buffer[0].address = pci_map_single(priv->pci_dev,
1067
+ tail_list->buffer[0].address = dma_map_single(&priv->pci_dev->dev,
10881068 skb->data, txlen,
1089
- PCI_DMA_TODEVICE);
1069
+ DMA_TO_DEVICE);
10901070 tlan_store_skb(tail_list, skb);
10911071
10921072 tail_list->frame_size = (u16) txlen;
....@@ -1380,10 +1360,10 @@
13801360 struct sk_buff *skb = tlan_get_skb(head_list);
13811361
13821362 ack++;
1383
- pci_unmap_single(priv->pci_dev, head_list->buffer[0].address,
1384
- max(skb->len,
1385
- (unsigned int)TLAN_MIN_FRAME_SIZE),
1386
- PCI_DMA_TODEVICE);
1363
+ dma_unmap_single(&priv->pci_dev->dev,
1364
+ head_list->buffer[0].address,
1365
+ max(skb->len, (unsigned int)TLAN_MIN_FRAME_SIZE),
1366
+ DMA_TO_DEVICE);
13871367 dev_kfree_skb_any(skb);
13881368 head_list->buffer[8].address = 0;
13891369 head_list->buffer[9].address = 0;
....@@ -1526,8 +1506,8 @@
15261506 goto drop_and_reuse;
15271507
15281508 skb = tlan_get_skb(head_list);
1529
- pci_unmap_single(priv->pci_dev, frame_dma,
1530
- TLAN_MAX_FRAME_SIZE, PCI_DMA_FROMDEVICE);
1509
+ dma_unmap_single(&priv->pci_dev->dev, frame_dma,
1510
+ TLAN_MAX_FRAME_SIZE, DMA_FROM_DEVICE);
15311511 skb_put(skb, frame_size);
15321512
15331513 dev->stats.rx_bytes += frame_size;
....@@ -1536,8 +1516,8 @@
15361516 netif_rx(skb);
15371517
15381518 head_list->buffer[0].address =
1539
- pci_map_single(priv->pci_dev, new_skb->data,
1540
- TLAN_MAX_FRAME_SIZE, PCI_DMA_FROMDEVICE);
1519
+ dma_map_single(&priv->pci_dev->dev, new_skb->data,
1520
+ TLAN_MAX_FRAME_SIZE, DMA_FROM_DEVICE);
15411521
15421522 tlan_store_skb(head_list, new_skb);
15431523 drop_and_reuse:
....@@ -1938,10 +1918,10 @@
19381918 if (!skb)
19391919 break;
19401920
1941
- list->buffer[0].address = pci_map_single(priv->pci_dev,
1921
+ list->buffer[0].address = dma_map_single(&priv->pci_dev->dev,
19421922 skb->data,
19431923 TLAN_MAX_FRAME_SIZE,
1944
- PCI_DMA_FROMDEVICE);
1924
+ DMA_FROM_DEVICE);
19451925 tlan_store_skb(list, skb);
19461926 list->buffer[1].count = 0;
19471927 list->buffer[1].address = 0;
....@@ -1969,12 +1949,10 @@
19691949 list = priv->tx_list + i;
19701950 skb = tlan_get_skb(list);
19711951 if (skb) {
1972
- pci_unmap_single(
1973
- priv->pci_dev,
1974
- list->buffer[0].address,
1975
- max(skb->len,
1976
- (unsigned int)TLAN_MIN_FRAME_SIZE),
1977
- PCI_DMA_TODEVICE);
1952
+ dma_unmap_single(&priv->pci_dev->dev,
1953
+ list->buffer[0].address,
1954
+ max(skb->len, (unsigned int)TLAN_MIN_FRAME_SIZE),
1955
+ DMA_TO_DEVICE);
19781956 dev_kfree_skb_any(skb);
19791957 list->buffer[8].address = 0;
19801958 list->buffer[9].address = 0;
....@@ -1985,10 +1963,9 @@
19851963 list = priv->rx_list + i;
19861964 skb = tlan_get_skb(list);
19871965 if (skb) {
1988
- pci_unmap_single(priv->pci_dev,
1966
+ dma_unmap_single(&priv->pci_dev->dev,
19891967 list->buffer[0].address,
1990
- TLAN_MAX_FRAME_SIZE,
1991
- PCI_DMA_FROMDEVICE);
1968
+ TLAN_MAX_FRAME_SIZE, DMA_FROM_DEVICE);
19921969 dev_kfree_skb_any(skb);
19931970 list->buffer[8].address = 0;
19941971 list->buffer[9].address = 0;
....@@ -2526,7 +2503,7 @@
25262503 }
25272504
25282505 /* Wait for 50 ms and powerup
2529
- * This is abitrary. It is intended to make sure the
2506
+ * This is arbitrary. It is intended to make sure the
25302507 * transceiver settles.
25312508 */
25322509 tlan_set_timer(dev, msecs_to_jiffies(50), TLAN_TIMER_PHY_PUP);