Re: [PATCH 2/3 net-next] net: mdio: mscc-miim: Use devm_clk_get_optional_enabled()
From: Maxime Chevallier
Date: Fri May 15 2026 - 12:01:56 EST
Hi,
On 5/15/26 16:50, Christophe JAILLET wrote:
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 <christophe.jaillet@xxxxxxxxxx>
---
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.
If anything, I'd say this is better as the original ordering, as the remove path now mirrors the probe one.
Reviewed-by: Maxime Chevallier <maxime.chevallier@xxxxxxxxxxx>
Maxime
---
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);
}