hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/net/ethernet/allwinner/sun4i-emac.c
....@@ -33,7 +33,6 @@
3333 #include "sun4i-emac.h"
3434
3535 #define DRV_NAME "sun4i-emac"
36
-#define DRV_VERSION "1.02"
3736
3837 #define EMAC_MAX_FRAME_LEN 0x0600
3938
....@@ -172,8 +171,7 @@
172171 }
173172
174173 /* mask with MAC supported features */
175
- phydev->supported &= PHY_BASIC_FEATURES;
176
- phydev->advertising = phydev->supported;
174
+ phy_set_max_speed(phydev, SPEED_100);
177175
178176 db->link = 0;
179177 db->speed = 0;
....@@ -208,25 +206,11 @@
208206 readsl(reg, data, round_up(count, 4) / 4);
209207 }
210208
211
-static int emac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
212
-{
213
- struct phy_device *phydev = dev->phydev;
214
-
215
- if (!netif_running(dev))
216
- return -EINVAL;
217
-
218
- if (!phydev)
219
- return -ENODEV;
220
-
221
- return phy_mii_ioctl(phydev, rq, cmd);
222
-}
223
-
224209 /* ethtool ops */
225210 static void emac_get_drvinfo(struct net_device *dev,
226211 struct ethtool_drvinfo *info)
227212 {
228
- strlcpy(info->driver, DRV_NAME, sizeof(DRV_NAME));
229
- strlcpy(info->version, DRV_VERSION, sizeof(DRV_VERSION));
213
+ strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
230214 strlcpy(info->bus_info, dev_name(&dev->dev), sizeof(info->bus_info));
231215 }
232216
....@@ -408,7 +392,7 @@
408392 }
409393
410394 /* Our watchdog timed out. Called by the networking layer */
411
-static void emac_timeout(struct net_device *dev)
395
+static void emac_timeout(struct net_device *dev, unsigned int txqueue)
412396 {
413397 struct emac_board_info *db = netdev_priv(dev);
414398 unsigned long flags;
....@@ -656,13 +640,11 @@
656640 struct net_device *dev = dev_id;
657641 struct emac_board_info *db = netdev_priv(dev);
658642 int int_status;
659
- unsigned long flags;
660643 unsigned int reg_val;
661644
662645 /* A real interrupt coming */
663646
664
- /* holders of db->lock must always block IRQs */
665
- spin_lock_irqsave(&db->lock, flags);
647
+ spin_lock(&db->lock);
666648
667649 /* Disable all interrupts */
668650 writel(0, db->membase + EMAC_INT_CTL_REG);
....@@ -696,7 +678,7 @@
696678 reg_val |= (0xf << 0) | (0x01 << 8);
697679 writel(reg_val, db->membase + EMAC_INT_CTL_REG);
698680 }
699
- spin_unlock_irqrestore(&db->lock, flags);
681
+ spin_unlock(&db->lock);
700682
701683 return IRQ_HANDLED;
702684 }
....@@ -792,7 +774,7 @@
792774 .ndo_start_xmit = emac_start_xmit,
793775 .ndo_tx_timeout = emac_timeout,
794776 .ndo_set_rx_mode = emac_set_rx_mode,
795
- .ndo_do_ioctl = emac_ioctl,
777
+ .ndo_do_ioctl = phy_do_ioctl_running,
796778 .ndo_validate_addr = eth_validate_addr,
797779 .ndo_set_mac_address = emac_set_mac_address,
798780 #ifdef CONFIG_NET_POLL_CONTROLLER
....@@ -819,7 +801,6 @@
819801 SET_NETDEV_DEV(ndev, &pdev->dev);
820802
821803 db = netdev_priv(ndev);
822
- memset(db, 0, sizeof(*db));
823804
824805 db->dev = &pdev->dev;
825806 db->ndev = ndev;
....@@ -862,7 +843,9 @@
862843 goto out_clk_disable_unprepare;
863844 }
864845
865
- db->phy_node = of_parse_phandle(np, "phy", 0);
846
+ db->phy_node = of_parse_phandle(np, "phy-handle", 0);
847
+ if (!db->phy_node)
848
+ db->phy_node = of_parse_phandle(np, "phy", 0);
866849 if (!db->phy_node) {
867850 dev_err(&pdev->dev, "no associated PHY\n");
868851 ret = -ENODEV;
....@@ -871,8 +854,8 @@
871854
872855 /* Read MAC-address from DT */
873856 mac_addr = of_get_mac_address(np);
874
- if (mac_addr)
875
- memcpy(ndev->dev_addr, mac_addr, ETH_ALEN);
857
+ if (!IS_ERR(mac_addr))
858
+ ether_addr_copy(ndev->dev_addr, mac_addr);
876859
877860 /* Check if the MAC address is valid, if not get a random one */
878861 if (!is_valid_ether_addr(ndev->dev_addr)) {