netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net,stable 1/1] net: fec: match the dev_id between probe and remove
@ 2019-11-29  6:40 Andy Duan
  2019-11-30 20:27 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Duan @ 2019-11-29  6:40 UTC (permalink / raw)
  To: davem; +Cc: netdev, Andy Duan

Test device bind/unbind on i.MX8QM platform:
echo 5b040000.ethernet > /sys/bus/platform/drivers/fec/unbind
echo 5b040000.ethernet > /sys/bus/platform/drivers/fec/bind

error log:
pps pps0: new PPS source ptp0 /sys/bus/platform/drivers/fec/bind
fec: probe of 5b040000.ethernet failed with error -2

It should decrease the dev_id when device is unbinded. So let
the fec_dev_id as global variable and let the count match in
.probe() and .remvoe().

Reported-by: shivani.patel <shivani.patel@volansystech.com>
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
---
 drivers/net/ethernet/freescale/fec_main.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 05c1899..348fd8a 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -243,6 +243,7 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address");
 	(addr < txq->tso_hdrs_dma + txq->bd.ring_size * TSO_HEADER_SIZE))
 
 static int mii_cnt;
+static int fec_dev_id;
 
 static struct bufdesc *fec_enet_get_nextdesc(struct bufdesc *bdp,
 					     struct bufdesc_prop *bd)
@@ -3397,7 +3398,6 @@ fec_probe(struct platform_device *pdev)
 	struct net_device *ndev;
 	int i, irq, ret = 0;
 	const struct of_device_id *of_id;
-	static int dev_id;
 	struct device_node *np = pdev->dev.of_node, *phy_node;
 	int num_tx_qs;
 	int num_rx_qs;
@@ -3442,7 +3442,7 @@ fec_probe(struct platform_device *pdev)
 	}
 
 	fep->pdev = pdev;
-	fep->dev_id = dev_id++;
+	fep->dev_id = fec_dev_id++;
 
 	platform_set_drvdata(pdev, ndev);
 
@@ -3623,7 +3623,7 @@ fec_probe(struct platform_device *pdev)
 		of_phy_deregister_fixed_link(np);
 	of_node_put(phy_node);
 failed_phy:
-	dev_id--;
+	fec_dev_id--;
 failed_ioremap:
 	free_netdev(ndev);
 
@@ -3653,6 +3653,7 @@ fec_drv_remove(struct platform_device *pdev)
 		of_phy_deregister_fixed_link(np);
 	of_node_put(fep->phy_node);
 	free_netdev(ndev);
+	fec_dev_id--;
 
 	clk_disable_unprepare(fep->clk_ahb);
 	clk_disable_unprepare(fep->clk_ipg);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-12-02  3:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-29  6:40 [PATCH net,stable 1/1] net: fec: match the dev_id between probe and remove Andy Duan
2019-11-30 20:27 ` David Miller
2019-12-02  3:04   ` [EXT] " Andy Duan
2019-12-02  3:18     ` Florian Fainelli
2019-12-02  3:42       ` Andy Duan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).