.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* Copyright (c) 2014 Linaro Ltd. |
---|
2 | 3 | * 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. |
---|
8 | 4 | */ |
---|
9 | 5 | |
---|
10 | 6 | #include <linux/module.h> |
---|
.. | .. |
---|
554 | 550 | skb->protocol = eth_type_trans(skb, dev); |
---|
555 | 551 | napi_gro_receive(&priv->napi, skb); |
---|
556 | 552 | dev->stats.rx_packets++; |
---|
557 | | - dev->stats.rx_bytes += skb->len; |
---|
| 553 | + dev->stats.rx_bytes += len; |
---|
558 | 554 | next: |
---|
559 | 555 | pos = dma_ring_incr(pos, RX_DESC_NUM); |
---|
560 | 556 | } |
---|
.. | .. |
---|
723 | 719 | |
---|
724 | 720 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
---|
725 | 721 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
---|
726 | | - int len = frag->size; |
---|
| 722 | + int len = skb_frag_size(frag); |
---|
727 | 723 | |
---|
728 | 724 | addr = skb_frag_dma_map(priv->dev, frag, 0, len, DMA_TO_DEVICE); |
---|
729 | 725 | ret = dma_mapping_error(priv->dev, addr); |
---|
.. | .. |
---|
897 | 893 | hix5hd2_net_open(priv->netdev); |
---|
898 | 894 | } |
---|
899 | 895 | |
---|
900 | | -static void hix5hd2_net_timeout(struct net_device *dev) |
---|
| 896 | +static void hix5hd2_net_timeout(struct net_device *dev, unsigned int txqueue) |
---|
901 | 897 | { |
---|
902 | 898 | struct hix5hd2_priv *priv = netdev_priv(dev); |
---|
903 | 899 | |
---|
.. | .. |
---|
1006 | 1002 | |
---|
1007 | 1003 | for (i = 0; i < QUEUE_NUMS; i++) { |
---|
1008 | 1004 | 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); |
---|
1011 | 1007 | if (virt_addr == NULL) |
---|
1012 | 1008 | goto error_free_pool; |
---|
1013 | 1009 | |
---|
.. | .. |
---|
1028 | 1024 | struct sg_desc *desc; |
---|
1029 | 1025 | dma_addr_t phys_addr; |
---|
1030 | 1026 | |
---|
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); |
---|
1034 | 1030 | if (!desc) |
---|
1035 | 1031 | return -ENOMEM; |
---|
1036 | 1032 | |
---|
.. | .. |
---|
1101 | 1097 | const struct of_device_id *of_id = NULL; |
---|
1102 | 1098 | struct net_device *ndev; |
---|
1103 | 1099 | struct hix5hd2_priv *priv; |
---|
1104 | | - struct resource *res; |
---|
1105 | 1100 | struct mii_bus *bus; |
---|
1106 | 1101 | const char *mac_addr; |
---|
1107 | 1102 | int ret; |
---|
.. | .. |
---|
1123 | 1118 | } |
---|
1124 | 1119 | priv->hw_cap = (unsigned long)of_id->data; |
---|
1125 | 1120 | |
---|
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); |
---|
1128 | 1122 | if (IS_ERR(priv->base)) { |
---|
1129 | 1123 | ret = PTR_ERR(priv->base); |
---|
1130 | 1124 | goto out_free_netdev; |
---|
1131 | 1125 | } |
---|
1132 | 1126 | |
---|
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); |
---|
1135 | 1128 | if (IS_ERR(priv->ctrl_base)) { |
---|
1136 | 1129 | ret = PTR_ERR(priv->ctrl_base); |
---|
1137 | 1130 | goto out_free_netdev; |
---|
.. | .. |
---|
1200 | 1193 | if (ret) |
---|
1201 | 1194 | goto err_free_mdio; |
---|
1202 | 1195 | |
---|
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) { |
---|
1205 | 1198 | netdev_err(ndev, "not find phy-mode\n"); |
---|
1206 | | - ret = -EINVAL; |
---|
1207 | 1199 | goto err_mdiobus; |
---|
1208 | 1200 | } |
---|
1209 | 1201 | |
---|
.. | .. |
---|
1229 | 1221 | } |
---|
1230 | 1222 | |
---|
1231 | 1223 | mac_addr = of_get_mac_address(node); |
---|
1232 | | - if (mac_addr) |
---|
| 1224 | + if (!IS_ERR(mac_addr)) |
---|
1233 | 1225 | ether_addr_copy(ndev->dev_addr, mac_addr); |
---|
1234 | 1226 | if (!is_valid_ether_addr(ndev->dev_addr)) { |
---|
1235 | 1227 | eth_hw_addr_random(ndev); |
---|