hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/net/ethernet/arc/emac_main.c
....@@ -1,9 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2004-2013 Synopsys, Inc. (www.synopsys.com)
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License version 2 as
6
- * published by the Free Software Foundation.
74 *
85 * Driver for the ARC EMAC 10100 (hardware revision 5)
96 *
....@@ -95,7 +92,6 @@
9592 struct arc_emac_priv *priv = netdev_priv(ndev);
9693
9794 strlcpy(info->driver, priv->drv_name, sizeof(info->driver));
98
- strlcpy(info->version, priv->drv_version, sizeof(info->version));
9995 }
10096
10197 static const struct ethtool_ops arc_emac_ethtool_ops = {
....@@ -144,11 +140,11 @@
144140 stats->tx_bytes += skb->len;
145141 }
146142
147
- dma_unmap_single(&ndev->dev, dma_unmap_addr(tx_buff, addr),
143
+ dma_unmap_single(ndev->dev.parent, dma_unmap_addr(tx_buff, addr),
148144 dma_unmap_len(tx_buff, len), DMA_TO_DEVICE);
149145
150146 /* return the sk_buff to system */
151
- dev_kfree_skb_irq(skb);
147
+ dev_consume_skb_irq(skb);
152148
153149 txbd->data = 0;
154150 txbd->info = 0;
....@@ -227,9 +223,9 @@
227223 continue;
228224 }
229225
230
- addr = dma_map_single(&ndev->dev, (void *)skb->data,
226
+ addr = dma_map_single(ndev->dev.parent, (void *)skb->data,
231227 EMAC_BUFFER_SIZE, DMA_FROM_DEVICE);
232
- if (dma_mapping_error(&ndev->dev, addr)) {
228
+ if (dma_mapping_error(ndev->dev.parent, addr)) {
233229 if (net_ratelimit())
234230 netdev_err(ndev, "cannot map dma buffer\n");
235231 dev_kfree_skb(skb);
....@@ -241,7 +237,7 @@
241237 }
242238
243239 /* unmap previosly mapped skb */
244
- dma_unmap_single(&ndev->dev, dma_unmap_addr(rx_buff, addr),
240
+ dma_unmap_single(ndev->dev.parent, dma_unmap_addr(rx_buff, addr),
245241 dma_unmap_len(rx_buff, len), DMA_FROM_DEVICE);
246242
247243 pktlen = info & LEN_MASK;
....@@ -431,7 +427,8 @@
431427 phy_dev->autoneg = AUTONEG_ENABLE;
432428 phy_dev->speed = 0;
433429 phy_dev->duplex = 0;
434
- phy_dev->advertising &= phy_dev->supported;
430
+ linkmode_and(phy_dev->advertising, phy_dev->advertising,
431
+ phy_dev->supported);
435432
436433 priv->last_rx_bd = 0;
437434
....@@ -447,9 +444,9 @@
447444 if (unlikely(!rx_buff->skb))
448445 return -ENOMEM;
449446
450
- addr = dma_map_single(&ndev->dev, (void *)rx_buff->skb->data,
447
+ addr = dma_map_single(ndev->dev.parent, (void *)rx_buff->skb->data,
451448 EMAC_BUFFER_SIZE, DMA_FROM_DEVICE);
452
- if (dma_mapping_error(&ndev->dev, addr)) {
449
+ if (dma_mapping_error(ndev->dev.parent, addr)) {
453450 netdev_err(ndev, "cannot dma map\n");
454451 dev_kfree_skb(rx_buff->skb);
455452 return -ENOMEM;
....@@ -557,7 +554,7 @@
557554 struct buffer_state *tx_buff = &priv->tx_buff[i];
558555
559556 if (tx_buff->skb) {
560
- dma_unmap_single(&ndev->dev,
557
+ dma_unmap_single(ndev->dev.parent,
561558 dma_unmap_addr(tx_buff, addr),
562559 dma_unmap_len(tx_buff, len),
563560 DMA_TO_DEVICE);
....@@ -588,7 +585,7 @@
588585 struct buffer_state *rx_buff = &priv->rx_buff[i];
589586
590587 if (rx_buff->skb) {
591
- dma_unmap_single(&ndev->dev,
588
+ dma_unmap_single(ndev->dev.parent,
592589 dma_unmap_addr(rx_buff, addr),
593590 dma_unmap_len(rx_buff, len),
594591 DMA_FROM_DEVICE);
....@@ -675,7 +672,7 @@
675672 *
676673 * This function is invoked from upper layers to initiate transmission.
677674 */
678
-static int arc_emac_tx(struct sk_buff *skb, struct net_device *ndev)
675
+static netdev_tx_t arc_emac_tx(struct sk_buff *skb, struct net_device *ndev)
679676 {
680677 struct arc_emac_priv *priv = netdev_priv(ndev);
681678 unsigned int len, *txbd_curr = &priv->txbd_curr;
....@@ -696,10 +693,10 @@
696693 return NETDEV_TX_BUSY;
697694 }
698695
699
- addr = dma_map_single(&ndev->dev, (void *)skb->data, len,
696
+ addr = dma_map_single(ndev->dev.parent, (void *)skb->data, len,
700697 DMA_TO_DEVICE);
701698
702
- if (unlikely(dma_mapping_error(&ndev->dev, addr))) {
699
+ if (unlikely(dma_mapping_error(ndev->dev.parent, addr))) {
703700 stats->tx_dropped++;
704701 stats->tx_errors++;
705702 dev_kfree_skb_any(skb);
....@@ -784,18 +781,6 @@
784781 return 0;
785782 }
786783
787
-static int arc_emac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
788
-{
789
- if (!netif_running(dev))
790
- return -EINVAL;
791
-
792
- if (!dev->phydev)
793
- return -ENODEV;
794
-
795
- return phy_mii_ioctl(dev->phydev, rq, cmd);
796
-}
797
-
798
-
799784 /**
800785 * arc_emac_restart - Restart EMAC
801786 * @ndev: Pointer to net_device structure.
....@@ -860,7 +845,7 @@
860845 .ndo_set_mac_address = arc_emac_set_address,
861846 .ndo_get_stats = arc_emac_stats,
862847 .ndo_set_rx_mode = arc_emac_set_rx_mode,
863
- .ndo_do_ioctl = arc_emac_ioctl,
848
+ .ndo_do_ioctl = phy_do_ioctl_running,
864849 #ifdef CONFIG_NET_POLL_CONTROLLER
865850 .ndo_poll_controller = arc_emac_poll_controller,
866851 #endif
....@@ -960,8 +945,8 @@
960945 /* Get MAC address from device tree */
961946 mac_addr = of_get_mac_address(dev->of_node);
962947
963
- if (mac_addr)
964
- memcpy(ndev->dev_addr, mac_addr, ETH_ALEN);
948
+ if (!IS_ERR(mac_addr))
949
+ ether_addr_copy(ndev->dev_addr, mac_addr);
965950 else
966951 eth_hw_addr_random(ndev);
967952