forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/net/ethernet/hisilicon/hisi_femac.c
....@@ -1,20 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Hisilicon Fast Ethernet MAC Driver
34 *
45 * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
186 */
197
208 #include <linux/circ_buf.h>
....@@ -295,7 +283,7 @@
295283 skb->protocol = eth_type_trans(skb, dev);
296284 napi_gro_receive(&priv->napi, skb);
297285 dev->stats.rx_packets++;
298
- dev->stats.rx_bytes += skb->len;
286
+ dev->stats.rx_bytes += len;
299287 next:
300288 pos = (pos + 1) % rxq->num;
301289 if (rx_pkts_num >= limit)
....@@ -687,18 +675,6 @@
687675 }
688676 }
689677
690
-static int hisi_femac_net_ioctl(struct net_device *dev,
691
- struct ifreq *ifreq, int cmd)
692
-{
693
- if (!netif_running(dev))
694
- return -EINVAL;
695
-
696
- if (!dev->phydev)
697
- return -EINVAL;
698
-
699
- return phy_mii_ioctl(dev->phydev, ifreq, cmd);
700
-}
701
-
702678 static const struct ethtool_ops hisi_femac_ethtools_ops = {
703679 .get_link = ethtool_op_get_link,
704680 .get_link_ksettings = phy_ethtool_get_link_ksettings,
....@@ -709,7 +685,7 @@
709685 .ndo_open = hisi_femac_net_open,
710686 .ndo_stop = hisi_femac_net_close,
711687 .ndo_start_xmit = hisi_femac_net_xmit,
712
- .ndo_do_ioctl = hisi_femac_net_ioctl,
688
+ .ndo_do_ioctl = phy_do_ioctl_running,
713689 .ndo_set_mac_address = hisi_femac_set_mac_address,
714690 .ndo_set_rx_mode = hisi_femac_net_set_rx_mode,
715691 };
....@@ -793,7 +769,6 @@
793769 {
794770 struct device *dev = &pdev->dev;
795771 struct device_node *node = dev->of_node;
796
- struct resource *res;
797772 struct net_device *ndev;
798773 struct hisi_femac_priv *priv;
799774 struct phy_device *phy;
....@@ -811,15 +786,13 @@
811786 priv->dev = dev;
812787 priv->ndev = ndev;
813788
814
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
815
- priv->port_base = devm_ioremap_resource(dev, res);
789
+ priv->port_base = devm_platform_ioremap_resource(pdev, 0);
816790 if (IS_ERR(priv->port_base)) {
817791 ret = PTR_ERR(priv->port_base);
818792 goto out_free_netdev;
819793 }
820794
821
- res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
822
- priv->glb_base = devm_ioremap_resource(dev, res);
795
+ priv->glb_base = devm_platform_ioremap_resource(pdev, 1);
823796 if (IS_ERR(priv->glb_base)) {
824797 ret = PTR_ERR(priv->glb_base);
825798 goto out_free_netdev;
....@@ -870,7 +843,7 @@
870843 phy_modes(phy->interface));
871844
872845 mac_addr = of_get_mac_address(node);
873
- if (mac_addr)
846
+ if (!IS_ERR(mac_addr))
874847 ether_addr_copy(ndev->dev_addr, mac_addr);
875848 if (!is_valid_ether_addr(ndev->dev_addr)) {
876849 eth_hw_addr_random(ndev);
....@@ -892,7 +865,6 @@
892865
893866 ndev->irq = platform_get_irq(pdev, 0);
894867 if (ndev->irq <= 0) {
895
- dev_err(dev, "No irq resource\n");
896868 ret = -ENODEV;
897869 goto out_disconnect_phy;
898870 }