hc
2024-09-20 a36159eec6ca17402b0e146b86efaf76568dc353
kernel/drivers/net/ethernet/aurora/nb8800.c
....@@ -1,23 +1,13 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) 2015 Mans Rullgard <mans@mansr.com>
34 *
45 * Mostly rewritten, based on driver from Sigma Designs. Original
56 * copyright notice below.
67 *
7
- *
88 * Driver for tangox SMP864x/SMP865x/SMP867x/SMP868x builtin Ethernet Mac.
99 *
1010 * Copyright (C) 2005 Maxime Bizon <mbizon@freebox.fr>
11
- *
12
- * This program is free software; you can redistribute it and/or modify
13
- * it under the terms of the GNU General Public License as published by
14
- * the Free Software Foundation; either version 2 of the License, or
15
- * (at your option) any later version.
16
- *
17
- * This program is distributed in the hope that it will be useful,
18
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- * GNU General Public License for more details.
2111 */
2212
2313 #include <linux/module.h>
....@@ -394,7 +384,7 @@
394384 spin_unlock(&priv->tx_lock);
395385 }
396386
397
-static int nb8800_xmit(struct sk_buff *skb, struct net_device *dev)
387
+static netdev_tx_t nb8800_xmit(struct sk_buff *skb, struct net_device *dev)
398388 {
399389 struct nb8800_priv *priv = netdev_priv(dev);
400390 struct nb8800_tx_desc *txd;
....@@ -404,6 +394,7 @@
404394 unsigned int dma_len;
405395 unsigned int align;
406396 unsigned int next;
397
+ bool xmit_more;
407398
408399 if (atomic_read(&priv->tx_free) <= NB8800_DESC_LOW) {
409400 netif_stop_queue(dev);
....@@ -423,9 +414,10 @@
423414 return NETDEV_TX_OK;
424415 }
425416
417
+ xmit_more = netdev_xmit_more();
426418 if (atomic_dec_return(&priv->tx_free) <= NB8800_DESC_LOW) {
427419 netif_stop_queue(dev);
428
- skb->xmit_more = 0;
420
+ xmit_more = false;
429421 }
430422
431423 next = priv->tx_next;
....@@ -450,7 +442,7 @@
450442 desc->n_addr = priv->tx_bufs[next].dma_desc;
451443 desc->config = DESC_BTS(2) | DESC_DS | DESC_EOF | dma_len;
452444
453
- if (!skb->xmit_more)
445
+ if (!xmit_more)
454446 desc->config |= DESC_EOC;
455447
456448 txb->skb = skb;
....@@ -468,7 +460,7 @@
468460
469461 priv->tx_next = next;
470462
471
- if (!skb->xmit_more) {
463
+ if (!xmit_more) {
472464 smp_wmb();
473465 priv->tx_chain->ready = true;
474466 priv->tx_chain = NULL;
....@@ -935,18 +927,11 @@
935927 {
936928 struct nb8800_priv *priv = netdev_priv(dev);
937929 struct phy_device *phydev = dev->phydev;
938
- u32 adv = 0;
939930
940931 if (!phydev)
941932 return;
942933
943
- if (priv->pause_rx)
944
- adv |= ADVERTISED_Pause | ADVERTISED_Asym_Pause;
945
- if (priv->pause_tx)
946
- adv ^= ADVERTISED_Asym_Pause;
947
-
948
- phydev->supported |= adv;
949
- phydev->advertising |= adv;
934
+ phy_set_asym_pause(phydev, priv->pause_rx, priv->pause_tx);
950935 }
951936
952937 static int nb8800_open(struct net_device *dev)
....@@ -1020,18 +1005,13 @@
10201005 return 0;
10211006 }
10221007
1023
-static int nb8800_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1024
-{
1025
- return phy_mii_ioctl(dev->phydev, rq, cmd);
1026
-}
1027
-
10281008 static const struct net_device_ops nb8800_netdev_ops = {
10291009 .ndo_open = nb8800_open,
10301010 .ndo_stop = nb8800_stop,
10311011 .ndo_start_xmit = nb8800_xmit,
10321012 .ndo_set_mac_address = nb8800_set_mac_address,
10331013 .ndo_set_rx_mode = nb8800_set_rx_mode,
1034
- .ndo_do_ioctl = nb8800_ioctl,
1014
+ .ndo_do_ioctl = phy_do_ioctl,
10351015 .ndo_validate_addr = eth_validate_addr,
10361016 };
10371017
....@@ -1366,10 +1346,8 @@
13661346 ops = match->data;
13671347
13681348 irq = platform_get_irq(pdev, 0);
1369
- if (irq <= 0) {
1370
- dev_err(&pdev->dev, "No IRQ\n");
1349
+ if (irq <= 0)
13711350 return -EINVAL;
1372
- }
13731351
13741352 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
13751353 base = devm_ioremap_resource(&pdev->dev, res);
....@@ -1388,8 +1366,8 @@
13881366 priv = netdev_priv(dev);
13891367 priv->base = base;
13901368
1391
- priv->phy_mode = of_get_phy_mode(pdev->dev.of_node);
1392
- if (priv->phy_mode < 0)
1369
+ ret = of_get_phy_mode(pdev->dev.of_node, &priv->phy_mode);
1370
+ if (ret)
13931371 priv->phy_mode = PHY_INTERFACE_MODE_RGMII;
13941372
13951373 priv->clk = devm_clk_get(&pdev->dev, NULL);
....@@ -1468,7 +1446,7 @@
14681446 dev->irq = irq;
14691447
14701448 mac = of_get_mac_address(pdev->dev.of_node);
1471
- if (mac)
1449
+ if (!IS_ERR(mac))
14721450 ether_addr_copy(dev->dev_addr, mac);
14731451
14741452 if (!is_valid_ether_addr(dev->dev_addr))