.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2015 Mans Rullgard <mans@mansr.com> |
---|
3 | 4 | * |
---|
4 | 5 | * Mostly rewritten, based on driver from Sigma Designs. Original |
---|
5 | 6 | * copyright notice below. |
---|
6 | 7 | * |
---|
7 | | - * |
---|
8 | 8 | * Driver for tangox SMP864x/SMP865x/SMP867x/SMP868x builtin Ethernet Mac. |
---|
9 | 9 | * |
---|
10 | 10 | * 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. |
---|
21 | 11 | */ |
---|
22 | 12 | |
---|
23 | 13 | #include <linux/module.h> |
---|
.. | .. |
---|
394 | 384 | spin_unlock(&priv->tx_lock); |
---|
395 | 385 | } |
---|
396 | 386 | |
---|
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) |
---|
398 | 388 | { |
---|
399 | 389 | struct nb8800_priv *priv = netdev_priv(dev); |
---|
400 | 390 | struct nb8800_tx_desc *txd; |
---|
.. | .. |
---|
404 | 394 | unsigned int dma_len; |
---|
405 | 395 | unsigned int align; |
---|
406 | 396 | unsigned int next; |
---|
| 397 | + bool xmit_more; |
---|
407 | 398 | |
---|
408 | 399 | if (atomic_read(&priv->tx_free) <= NB8800_DESC_LOW) { |
---|
409 | 400 | netif_stop_queue(dev); |
---|
.. | .. |
---|
423 | 414 | return NETDEV_TX_OK; |
---|
424 | 415 | } |
---|
425 | 416 | |
---|
| 417 | + xmit_more = netdev_xmit_more(); |
---|
426 | 418 | if (atomic_dec_return(&priv->tx_free) <= NB8800_DESC_LOW) { |
---|
427 | 419 | netif_stop_queue(dev); |
---|
428 | | - skb->xmit_more = 0; |
---|
| 420 | + xmit_more = false; |
---|
429 | 421 | } |
---|
430 | 422 | |
---|
431 | 423 | next = priv->tx_next; |
---|
.. | .. |
---|
450 | 442 | desc->n_addr = priv->tx_bufs[next].dma_desc; |
---|
451 | 443 | desc->config = DESC_BTS(2) | DESC_DS | DESC_EOF | dma_len; |
---|
452 | 444 | |
---|
453 | | - if (!skb->xmit_more) |
---|
| 445 | + if (!xmit_more) |
---|
454 | 446 | desc->config |= DESC_EOC; |
---|
455 | 447 | |
---|
456 | 448 | txb->skb = skb; |
---|
.. | .. |
---|
468 | 460 | |
---|
469 | 461 | priv->tx_next = next; |
---|
470 | 462 | |
---|
471 | | - if (!skb->xmit_more) { |
---|
| 463 | + if (!xmit_more) { |
---|
472 | 464 | smp_wmb(); |
---|
473 | 465 | priv->tx_chain->ready = true; |
---|
474 | 466 | priv->tx_chain = NULL; |
---|
.. | .. |
---|
935 | 927 | { |
---|
936 | 928 | struct nb8800_priv *priv = netdev_priv(dev); |
---|
937 | 929 | struct phy_device *phydev = dev->phydev; |
---|
938 | | - u32 adv = 0; |
---|
939 | 930 | |
---|
940 | 931 | if (!phydev) |
---|
941 | 932 | return; |
---|
942 | 933 | |
---|
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); |
---|
950 | 935 | } |
---|
951 | 936 | |
---|
952 | 937 | static int nb8800_open(struct net_device *dev) |
---|
.. | .. |
---|
1020 | 1005 | return 0; |
---|
1021 | 1006 | } |
---|
1022 | 1007 | |
---|
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 | | - |
---|
1028 | 1008 | static const struct net_device_ops nb8800_netdev_ops = { |
---|
1029 | 1009 | .ndo_open = nb8800_open, |
---|
1030 | 1010 | .ndo_stop = nb8800_stop, |
---|
1031 | 1011 | .ndo_start_xmit = nb8800_xmit, |
---|
1032 | 1012 | .ndo_set_mac_address = nb8800_set_mac_address, |
---|
1033 | 1013 | .ndo_set_rx_mode = nb8800_set_rx_mode, |
---|
1034 | | - .ndo_do_ioctl = nb8800_ioctl, |
---|
| 1014 | + .ndo_do_ioctl = phy_do_ioctl, |
---|
1035 | 1015 | .ndo_validate_addr = eth_validate_addr, |
---|
1036 | 1016 | }; |
---|
1037 | 1017 | |
---|
.. | .. |
---|
1366 | 1346 | ops = match->data; |
---|
1367 | 1347 | |
---|
1368 | 1348 | irq = platform_get_irq(pdev, 0); |
---|
1369 | | - if (irq <= 0) { |
---|
1370 | | - dev_err(&pdev->dev, "No IRQ\n"); |
---|
| 1349 | + if (irq <= 0) |
---|
1371 | 1350 | return -EINVAL; |
---|
1372 | | - } |
---|
1373 | 1351 | |
---|
1374 | 1352 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
---|
1375 | 1353 | base = devm_ioremap_resource(&pdev->dev, res); |
---|
.. | .. |
---|
1388 | 1366 | priv = netdev_priv(dev); |
---|
1389 | 1367 | priv->base = base; |
---|
1390 | 1368 | |
---|
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) |
---|
1393 | 1371 | priv->phy_mode = PHY_INTERFACE_MODE_RGMII; |
---|
1394 | 1372 | |
---|
1395 | 1373 | priv->clk = devm_clk_get(&pdev->dev, NULL); |
---|
.. | .. |
---|
1468 | 1446 | dev->irq = irq; |
---|
1469 | 1447 | |
---|
1470 | 1448 | mac = of_get_mac_address(pdev->dev.of_node); |
---|
1471 | | - if (mac) |
---|
| 1449 | + if (!IS_ERR(mac)) |
---|
1472 | 1450 | ether_addr_copy(dev->dev_addr, mac); |
---|
1473 | 1451 | |
---|
1474 | 1452 | if (!is_valid_ether_addr(dev->dev_addr)) |
---|