hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/net/ethernet/altera/altera_tse_main.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /* Altera Triple-Speed Ethernet MAC driver
23 * Copyright (C) 2008-2014 Altera Corporation. All rights reserved
34 *
....@@ -14,18 +15,6 @@
1415 *
1516 * Original driver contributed by SLS.
1617 * 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/>.
2918 */
3019
3120 #include <linux/atomic.h>
....@@ -174,7 +163,8 @@
174163 mdio = mdiobus_alloc();
175164 if (mdio == NULL) {
176165 netdev_err(dev, "Error allocating MDIO bus\n");
177
- return -ENOMEM;
166
+ ret = -ENOMEM;
167
+ goto put_node;
178168 }
179169
180170 mdio->name = ALTERA_TSE_RESOURCE_NAME;
....@@ -191,6 +181,7 @@
191181 mdio->id);
192182 goto out_free_mdio;
193183 }
184
+ of_node_put(mdio_node);
194185
195186 if (netif_msg_drv(priv))
196187 netdev_info(dev, "MDIO bus %s: created\n", mdio->id);
....@@ -200,6 +191,8 @@
200191 out_free_mdio:
201192 mdiobus_free(mdio);
202193 mdio = NULL;
194
+put_node:
195
+ of_node_put(mdio_node);
203196 return ret;
204197 }
205198
....@@ -565,7 +558,7 @@
565558 * physically contiguous fragment starting at
566559 * skb->data, for length of skb_headlen(skb).
567560 */
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)
569562 {
570563 struct altera_tse_private *priv = netdev_priv(dev);
571564 unsigned int txsize = priv->tx_ring_size;
....@@ -573,7 +566,7 @@
573566 struct tse_buffer *buffer = NULL;
574567 int nfrags = skb_shinfo(skb)->nr_frags;
575568 unsigned int nopaged_len = skb_headlen(skb);
576
- enum netdev_tx ret = NETDEV_TX_OK;
569
+ netdev_tx_t ret = NETDEV_TX_OK;
577570 dma_addr_t dma_addr;
578571
579572 spin_lock_bh(&priv->tx_lock);
....@@ -741,12 +734,12 @@
741734 {
742735 struct altera_tse_private *priv = netdev_priv(dev);
743736 struct device_node *np = priv->device->of_node;
744
- int ret = 0;
737
+ int ret;
745738
746
- priv->phy_iface = of_get_phy_mode(np);
739
+ ret = of_get_phy_mode(np, &priv->phy_iface);
747740
748741 /* Avoid get phy addr and create mdio if no phy is present */
749
- if (!priv->phy_iface)
742
+ if (ret)
750743 return 0;
751744
752745 /* try to get PHY address from device tree, use PHY autodetection if
....@@ -837,13 +830,10 @@
837830 }
838831
839832 /* 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.
842833 */
843834 if ((priv->phy_iface == PHY_INTERFACE_MODE_MII) ||
844835 (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);
847837
848838 /* Broken HW is sometimes missing the pull-up resistor on the
849839 * MDIO line, which results in reads to non-existent devices returning
....@@ -1346,10 +1336,10 @@
13461336 return -EBUSY;
13471337 }
13481338
1349
- *ptr = devm_ioremap_nocache(device, region->start,
1339
+ *ptr = devm_ioremap(device, region->start,
13501340 resource_size(region));
13511341 if (*ptr == NULL) {
1352
- dev_err(device, "ioremap_nocache of %s failed!", name);
1342
+ dev_err(device, "ioremap of %s failed!", name);
13531343 return -ENOMEM;
13541344 }
13551345
....@@ -1543,7 +1533,7 @@
15431533
15441534 /* get default MAC address from device tree */
15451535 macaddr = of_get_mac_address(pdev->dev.of_node);
1546
- if (macaddr)
1536
+ if (!IS_ERR(macaddr))
15471537 ether_addr_copy(ndev->dev_addr, macaddr);
15481538 else
15491539 eth_hw_addr_random(ndev);