[RESEND PATCH net 02/10] net: ethernet: mediatek: fix incorrect return value of devm_clk_get with EPROBE_DEFER

Subsystems: mediatek ethernet driver, networking drivers, the rest

STALE3647d

2 messages, 2 authors, 2016-08-25 · open the first message on its own page

[RESEND PATCH net 02/10] net: ethernet: mediatek: fix incorrect return value of devm_clk_get with EPROBE_DEFER

From: Sean Wang <hidden>
Date: 2016-08-25 10:44:53

If the return value of devm_clk_get is EPROBE_DEFER, we should
defer probing the driver. The change is verified and works based
on 4.8-rc1 staying with the latest clk-next code for MT7623.

Signed-off-by: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 6e4a6ca..02b048f 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -1851,8 +1851,15 @@ static int mtk_probe(struct platform_device *pdev)
 	eth->clk_gp1 = devm_clk_get(&pdev->dev, "gp1");
 	eth->clk_gp2 = devm_clk_get(&pdev->dev, "gp2");
 	if (IS_ERR(eth->clk_esw) || IS_ERR(eth->clk_gp1) ||
-	    IS_ERR(eth->clk_gp2) || IS_ERR(eth->clk_ethif))
-		return -ENODEV;
+	    IS_ERR(eth->clk_gp2) || IS_ERR(eth->clk_ethif)) {
+		if (PTR_ERR(eth->clk_esw) == -EPROBE_DEFER ||
+		    PTR_ERR(eth->clk_gp1) == -EPROBE_DEFER ||
+		    PTR_ERR(eth->clk_gp1) == -EPROBE_DEFER ||
+		    PTR_ERR(eth->clk_gp2) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+		else
+			return -ENODEV;
+	}
 
 	clk_prepare_enable(eth->clk_ethif);
 	clk_prepare_enable(eth->clk_esw);
-- 
1.9.1

Re: [RESEND PATCH net 02/10] net: ethernet: mediatek: fix incorrect return value of devm_clk_get with EPROBE_DEFER

From: John Crispin <john@phrozen.org>
Date: 2016-08-25 13:49:16


On 25/08/2016 12:44, Sean Wang wrote:
quoted hunk
If the return value of devm_clk_get is EPROBE_DEFER, we should
defer probing the driver. The change is verified and works based
on 4.8-rc1 staying with the latest clk-next code for MT7623.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 6e4a6ca..02b048f 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -1851,8 +1851,15 @@ static int mtk_probe(struct platform_device *pdev)
 	eth->clk_gp1 = devm_clk_get(&pdev->dev, "gp1");
 	eth->clk_gp2 = devm_clk_get(&pdev->dev, "gp2");
 	if (IS_ERR(eth->clk_esw) || IS_ERR(eth->clk_gp1) ||
-	    IS_ERR(eth->clk_gp2) || IS_ERR(eth->clk_ethif))
-		return -ENODEV;
+	    IS_ERR(eth->clk_gp2) || IS_ERR(eth->clk_ethif)) {
+		if (PTR_ERR(eth->clk_esw) == -EPROBE_DEFER ||
+		    PTR_ERR(eth->clk_gp1) == -EPROBE_DEFER ||
+		    PTR_ERR(eth->clk_gp1) == -EPROBE_DEFER ||
+		    PTR_ERR(eth->clk_gp2) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+		else
+			return -ENODEV;
+	}
Hi Sean,

this looks a bit tedious. maybe a better solution would be to add an
array to struct mtk_eth for the clocks and an enum for the index
mapping. that would allow the usage of loops to work out if all clocks
are fine. the following code calling clk_prepare_enable() could then
also be turned into a loop

	John
 
 	clk_prepare_enable(eth->clk_ethif);
 	clk_prepare_enable(eth->clk_esw);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help