| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* Altera Triple-Speed Ethernet MAC driver |
|---|
| 2 | 3 | * Copyright (C) 2008-2014 Altera Corporation. All rights reserved |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 14 | 15 | * |
|---|
| 15 | 16 | * Original driver contributed by SLS. |
|---|
| 16 | 17 | * Major updates contributed by GlobalLogic |
|---|
| 17 | | - * |
|---|
| 18 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 19 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 20 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 21 | | - * |
|---|
| 22 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 23 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 24 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 25 | | - * more details. |
|---|
| 26 | | - * |
|---|
| 27 | | - * You should have received a copy of the GNU General Public License along with |
|---|
| 28 | | - * this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 29 | 18 | */ |
|---|
| 30 | 19 | |
|---|
| 31 | 20 | #include <linux/atomic.h> |
|---|
| .. | .. |
|---|
| 174 | 163 | mdio = mdiobus_alloc(); |
|---|
| 175 | 164 | if (mdio == NULL) { |
|---|
| 176 | 165 | netdev_err(dev, "Error allocating MDIO bus\n"); |
|---|
| 177 | | - return -ENOMEM; |
|---|
| 166 | + ret = -ENOMEM; |
|---|
| 167 | + goto put_node; |
|---|
| 178 | 168 | } |
|---|
| 179 | 169 | |
|---|
| 180 | 170 | mdio->name = ALTERA_TSE_RESOURCE_NAME; |
|---|
| .. | .. |
|---|
| 191 | 181 | mdio->id); |
|---|
| 192 | 182 | goto out_free_mdio; |
|---|
| 193 | 183 | } |
|---|
| 184 | + of_node_put(mdio_node); |
|---|
| 194 | 185 | |
|---|
| 195 | 186 | if (netif_msg_drv(priv)) |
|---|
| 196 | 187 | netdev_info(dev, "MDIO bus %s: created\n", mdio->id); |
|---|
| .. | .. |
|---|
| 200 | 191 | out_free_mdio: |
|---|
| 201 | 192 | mdiobus_free(mdio); |
|---|
| 202 | 193 | mdio = NULL; |
|---|
| 194 | +put_node: |
|---|
| 195 | + of_node_put(mdio_node); |
|---|
| 203 | 196 | return ret; |
|---|
| 204 | 197 | } |
|---|
| 205 | 198 | |
|---|
| .. | .. |
|---|
| 565 | 558 | * physically contiguous fragment starting at |
|---|
| 566 | 559 | * skb->data, for length of skb_headlen(skb). |
|---|
| 567 | 560 | */ |
|---|
| 568 | | -static int tse_start_xmit(struct sk_buff *skb, struct net_device *dev) |
|---|
| 561 | +static netdev_tx_t tse_start_xmit(struct sk_buff *skb, struct net_device *dev) |
|---|
| 569 | 562 | { |
|---|
| 570 | 563 | struct altera_tse_private *priv = netdev_priv(dev); |
|---|
| 571 | 564 | unsigned int txsize = priv->tx_ring_size; |
|---|
| .. | .. |
|---|
| 573 | 566 | struct tse_buffer *buffer = NULL; |
|---|
| 574 | 567 | int nfrags = skb_shinfo(skb)->nr_frags; |
|---|
| 575 | 568 | unsigned int nopaged_len = skb_headlen(skb); |
|---|
| 576 | | - enum netdev_tx ret = NETDEV_TX_OK; |
|---|
| 569 | + netdev_tx_t ret = NETDEV_TX_OK; |
|---|
| 577 | 570 | dma_addr_t dma_addr; |
|---|
| 578 | 571 | |
|---|
| 579 | 572 | spin_lock_bh(&priv->tx_lock); |
|---|
| .. | .. |
|---|
| 741 | 734 | { |
|---|
| 742 | 735 | struct altera_tse_private *priv = netdev_priv(dev); |
|---|
| 743 | 736 | struct device_node *np = priv->device->of_node; |
|---|
| 744 | | - int ret = 0; |
|---|
| 737 | + int ret; |
|---|
| 745 | 738 | |
|---|
| 746 | | - priv->phy_iface = of_get_phy_mode(np); |
|---|
| 739 | + ret = of_get_phy_mode(np, &priv->phy_iface); |
|---|
| 747 | 740 | |
|---|
| 748 | 741 | /* Avoid get phy addr and create mdio if no phy is present */ |
|---|
| 749 | | - if (!priv->phy_iface) |
|---|
| 742 | + if (ret) |
|---|
| 750 | 743 | return 0; |
|---|
| 751 | 744 | |
|---|
| 752 | 745 | /* try to get PHY address from device tree, use PHY autodetection if |
|---|
| .. | .. |
|---|
| 837 | 830 | } |
|---|
| 838 | 831 | |
|---|
| 839 | 832 | /* Stop Advertising 1000BASE Capability if interface is not GMII |
|---|
| 840 | | - * Note: Checkpatch throws CHECKs for the camel case defines below, |
|---|
| 841 | | - * it's ok to ignore. |
|---|
| 842 | 833 | */ |
|---|
| 843 | 834 | if ((priv->phy_iface == PHY_INTERFACE_MODE_MII) || |
|---|
| 844 | 835 | (priv->phy_iface == PHY_INTERFACE_MODE_RMII)) |
|---|
| 845 | | - phydev->advertising &= ~(SUPPORTED_1000baseT_Half | |
|---|
| 846 | | - SUPPORTED_1000baseT_Full); |
|---|
| 836 | + phy_set_max_speed(phydev, SPEED_100); |
|---|
| 847 | 837 | |
|---|
| 848 | 838 | /* Broken HW is sometimes missing the pull-up resistor on the |
|---|
| 849 | 839 | * MDIO line, which results in reads to non-existent devices returning |
|---|
| .. | .. |
|---|
| 1346 | 1336 | return -EBUSY; |
|---|
| 1347 | 1337 | } |
|---|
| 1348 | 1338 | |
|---|
| 1349 | | - *ptr = devm_ioremap_nocache(device, region->start, |
|---|
| 1339 | + *ptr = devm_ioremap(device, region->start, |
|---|
| 1350 | 1340 | resource_size(region)); |
|---|
| 1351 | 1341 | if (*ptr == NULL) { |
|---|
| 1352 | | - dev_err(device, "ioremap_nocache of %s failed!", name); |
|---|
| 1342 | + dev_err(device, "ioremap of %s failed!", name); |
|---|
| 1353 | 1343 | return -ENOMEM; |
|---|
| 1354 | 1344 | } |
|---|
| 1355 | 1345 | |
|---|
| .. | .. |
|---|
| 1543 | 1533 | |
|---|
| 1544 | 1534 | /* get default MAC address from device tree */ |
|---|
| 1545 | 1535 | macaddr = of_get_mac_address(pdev->dev.of_node); |
|---|
| 1546 | | - if (macaddr) |
|---|
| 1536 | + if (!IS_ERR(macaddr)) |
|---|
| 1547 | 1537 | ether_addr_copy(ndev->dev_addr, macaddr); |
|---|
| 1548 | 1538 | else |
|---|
| 1549 | 1539 | eth_hw_addr_random(ndev); |
|---|