forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/net/ethernet/qualcomm/emac/emac.c
....@@ -1,13 +1,5 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
2
- *
3
- * This program is free software; you can redistribute it and/or modify
4
- * it under the terms of the GNU General Public License version 2 and
5
- * only version 2 as published by the Free Software Foundation.
6
- *
7
- * This program is distributed in the hope that it will be useful,
8
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
- * GNU General Public License for more details.
113 */
124
135 /* Qualcomm Technologies, Inc. EMAC Gigabit Ethernet Driver */
....@@ -123,7 +115,8 @@
123115 }
124116
125117 /* Transmit the packet */
126
-static int emac_start_xmit(struct sk_buff *skb, struct net_device *netdev)
118
+static netdev_tx_t emac_start_xmit(struct sk_buff *skb,
119
+ struct net_device *netdev)
127120 {
128121 struct emac_adapter *adpt = netdev_priv(netdev);
129122
....@@ -221,9 +214,9 @@
221214 {
222215 struct emac_adapter *adpt = netdev_priv(netdev);
223216
224
- netif_info(adpt, hw, adpt->netdev,
225
- "changing MTU from %d to %d\n", netdev->mtu,
226
- new_mtu);
217
+ netif_dbg(adpt, hw, adpt->netdev,
218
+ "changing MTU from %d to %d\n", netdev->mtu,
219
+ new_mtu);
227220 netdev->mtu = new_mtu;
228221
229222 if (netif_running(netdev))
....@@ -290,27 +283,16 @@
290283 }
291284
292285 /* Respond to a TX hang */
293
-static void emac_tx_timeout(struct net_device *netdev)
286
+static void emac_tx_timeout(struct net_device *netdev, unsigned int txqueue)
294287 {
295288 struct emac_adapter *adpt = netdev_priv(netdev);
296289
297290 schedule_work(&adpt->work_thread);
298291 }
299292
300
-/* IOCTL support for the interface */
301
-static int emac_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
302
-{
303
- if (!netif_running(netdev))
304
- return -EINVAL;
305
-
306
- if (!netdev->phydev)
307
- return -ENODEV;
308
-
309
- return phy_mii_ioctl(netdev->phydev, ifr, cmd);
310
-}
311
-
312293 /**
313294 * emac_update_hw_stats - read the EMAC stat registers
295
+ * @adpt: pointer to adapter struct
314296 *
315297 * Reads the stats registers and write the values to adpt->stats.
316298 *
....@@ -395,7 +377,7 @@
395377 .ndo_start_xmit = emac_start_xmit,
396378 .ndo_set_mac_address = eth_mac_addr,
397379 .ndo_change_mtu = emac_change_mtu,
398
- .ndo_do_ioctl = emac_ioctl,
380
+ .ndo_do_ioctl = phy_do_ioctl_running,
399381 .ndo_tx_timeout = emac_tx_timeout,
400382 .ndo_get_stats64 = emac_get_stats64,
401383 .ndo_set_features = emac_set_features,
....@@ -563,7 +545,6 @@
563545 struct emac_adapter *adpt)
564546 {
565547 struct net_device *netdev = adpt->netdev;
566
- struct resource *res;
567548 char maddr[ETH_ALEN];
568549 int ret = 0;
569550
....@@ -575,22 +556,17 @@
575556
576557 /* Core 0 interrupt */
577558 ret = platform_get_irq(pdev, 0);
578
- if (ret < 0) {
579
- dev_err(&pdev->dev,
580
- "error: missing core0 irq resource (error=%i)\n", ret);
559
+ if (ret < 0)
581560 return ret;
582
- }
583561 adpt->irq.irq = ret;
584562
585563 /* base register address */
586
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
587
- adpt->base = devm_ioremap_resource(&pdev->dev, res);
564
+ adpt->base = devm_platform_ioremap_resource(pdev, 0);
588565 if (IS_ERR(adpt->base))
589566 return PTR_ERR(adpt->base);
590567
591568 /* CSR register address */
592
- res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
593
- adpt->csr = devm_ioremap_resource(&pdev->dev, res);
569
+ adpt->csr = devm_platform_ioremap_resource(pdev, 1);
594570 if (IS_ERR(adpt->csr))
595571 return PTR_ERR(adpt->csr);
596572
....@@ -752,9 +728,15 @@
752728 struct net_device *netdev = dev_get_drvdata(&pdev->dev);
753729 struct emac_adapter *adpt = netdev_priv(netdev);
754730
731
+ netif_carrier_off(netdev);
732
+ netif_tx_disable(netdev);
733
+
755734 unregister_netdev(netdev);
756735 netif_napi_del(&adpt->rx_q.napi);
757736
737
+ free_irq(adpt->irq.irq, &adpt->irq);
738
+ cancel_work_sync(&adpt->work_thread);
739
+
758740 emac_clks_teardown(adpt);
759741
760742 put_device(&adpt->phydev->mdio.dev);