forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
....@@ -1,10 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* Copyright (c) 2014 Linaro Ltd.
23 * Copyright (c) 2014 Hisilicon Limited.
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 as published by
6
- * the Free Software Foundation; either version 2 of the License, or
7
- * (at your option) any later version.
84 */
95
106 #include <linux/module.h>
....@@ -554,7 +550,7 @@
554550 skb->protocol = eth_type_trans(skb, dev);
555551 napi_gro_receive(&priv->napi, skb);
556552 dev->stats.rx_packets++;
557
- dev->stats.rx_bytes += skb->len;
553
+ dev->stats.rx_bytes += len;
558554 next:
559555 pos = dma_ring_incr(pos, RX_DESC_NUM);
560556 }
....@@ -723,7 +719,7 @@
723719
724720 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
725721 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
726
- int len = frag->size;
722
+ int len = skb_frag_size(frag);
727723
728724 addr = skb_frag_dma_map(priv->dev, frag, 0, len, DMA_TO_DEVICE);
729725 ret = dma_mapping_error(priv->dev, addr);
....@@ -897,7 +893,7 @@
897893 hix5hd2_net_open(priv->netdev);
898894 }
899895
900
-static void hix5hd2_net_timeout(struct net_device *dev)
896
+static void hix5hd2_net_timeout(struct net_device *dev, unsigned int txqueue)
901897 {
902898 struct hix5hd2_priv *priv = netdev_priv(dev);
903899
....@@ -1006,8 +1002,8 @@
10061002
10071003 for (i = 0; i < QUEUE_NUMS; i++) {
10081004 size = priv->pool[i].count * sizeof(struct hix5hd2_desc);
1009
- virt_addr = dma_zalloc_coherent(dev, size, &phys_addr,
1010
- GFP_KERNEL);
1005
+ virt_addr = dma_alloc_coherent(dev, size, &phys_addr,
1006
+ GFP_KERNEL);
10111007 if (virt_addr == NULL)
10121008 goto error_free_pool;
10131009
....@@ -1028,9 +1024,9 @@
10281024 struct sg_desc *desc;
10291025 dma_addr_t phys_addr;
10301026
1031
- desc = (struct sg_desc *)dma_alloc_coherent(priv->dev,
1032
- TX_DESC_NUM * sizeof(struct sg_desc),
1033
- &phys_addr, GFP_KERNEL);
1027
+ desc = dma_alloc_coherent(priv->dev,
1028
+ TX_DESC_NUM * sizeof(struct sg_desc),
1029
+ &phys_addr, GFP_KERNEL);
10341030 if (!desc)
10351031 return -ENOMEM;
10361032
....@@ -1101,7 +1097,6 @@
11011097 const struct of_device_id *of_id = NULL;
11021098 struct net_device *ndev;
11031099 struct hix5hd2_priv *priv;
1104
- struct resource *res;
11051100 struct mii_bus *bus;
11061101 const char *mac_addr;
11071102 int ret;
....@@ -1123,15 +1118,13 @@
11231118 }
11241119 priv->hw_cap = (unsigned long)of_id->data;
11251120
1126
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1127
- priv->base = devm_ioremap_resource(dev, res);
1121
+ priv->base = devm_platform_ioremap_resource(pdev, 0);
11281122 if (IS_ERR(priv->base)) {
11291123 ret = PTR_ERR(priv->base);
11301124 goto out_free_netdev;
11311125 }
11321126
1133
- res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1134
- priv->ctrl_base = devm_ioremap_resource(dev, res);
1127
+ priv->ctrl_base = devm_platform_ioremap_resource(pdev, 1);
11351128 if (IS_ERR(priv->ctrl_base)) {
11361129 ret = PTR_ERR(priv->ctrl_base);
11371130 goto out_free_netdev;
....@@ -1200,10 +1193,9 @@
12001193 if (ret)
12011194 goto err_free_mdio;
12021195
1203
- priv->phy_mode = of_get_phy_mode(node);
1204
- if ((int)priv->phy_mode < 0) {
1196
+ ret = of_get_phy_mode(node, &priv->phy_mode);
1197
+ if (ret) {
12051198 netdev_err(ndev, "not find phy-mode\n");
1206
- ret = -EINVAL;
12071199 goto err_mdiobus;
12081200 }
12091201
....@@ -1229,7 +1221,7 @@
12291221 }
12301222
12311223 mac_addr = of_get_mac_address(node);
1232
- if (mac_addr)
1224
+ if (!IS_ERR(mac_addr))
12331225 ether_addr_copy(ndev->dev_addr, mac_addr);
12341226 if (!is_valid_ether_addr(ndev->dev_addr)) {
12351227 eth_hw_addr_random(ndev);