[PATCH 2/3 net-next] net: mdio: mscc-miim: Use devm_clk_get_optional_enabled()

Christophe JAILLET <[email protected]>
Newsgroups gmane.linux.kernel.janitors,gmane.linux.network,gmane.linux.kernel
Message-ID <542f88aee5de2ac24fca58001eab24ac817abee9.1778856199.git.christophe.jaillet@wanadoo.fr>
Use devm_clk_get_optional_enabled() instead of clk_prepare_enable() and
clk_disable_unprepare().

This saves some lines of code and simplifies error handling in the probe.

Signed-off-by: Christophe JAILLET <[email protected]>
---
Compile tested only.

In the remove sequence, clk_disable_unprepare() and mdiobus_unregister()
are not called with the same order anymore. I don't think that it matters.
---
 drivers/net/mdio/mdio-mscc-miim.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/net/mdio/mdio-mscc-miim.c b/drivers/net/mdio/mdio-mscc-miim.c
index 03878bd9091d..4d8f60d458b8 100644
--- a/drivers/net/mdio/mdio-mscc-miim.c
+++ b/drivers/net/mdio/mdio-mscc-miim.c
@@ -307,7 +307,7 @@ static int mscc_miim_probe(struct platform_device *pdev)
 	if (!miim->info)
 		return -EINVAL;
 
-	miim->clk = devm_clk_get_optional(dev, NULL);
+	miim->clk = devm_clk_get_optional_enabled(dev, NULL);
 	if (IS_ERR(miim->clk))
 		return PTR_ERR(miim->clk);
 
@@ -318,35 +318,23 @@ static int mscc_miim_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	ret = clk_prepare_enable(miim->clk);
-	if (ret)
-		return ret;
-
 	ret = mscc_miim_clk_set(bus);
 	if (ret)
-		goto out_disable_clk;
+		return ret;
 
 	ret = of_mdiobus_register(bus, np);
-	if (ret < 0) {
-		dev_err_probe(dev, ret, "Cannot register MDIO bus\n");
-		goto out_disable_clk;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Cannot register MDIO bus\n");
 
 	platform_set_drvdata(pdev, bus);
 
 	return 0;
-
-out_disable_clk:
-	clk_disable_unprepare(miim->clk);
-	return ret;
 }
 
 static void mscc_miim_remove(struct platform_device *pdev)
 {
 	struct mii_bus *bus = platform_get_drvdata(pdev);
-	struct mscc_miim_dev *miim = bus->priv;
 
-	clk_disable_unprepare(miim->clk);
 	mdiobus_unregister(bus);
 }
 
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.