Commit df37fcf5 authored by Rosen Penev's avatar Rosen Penev Committed by Jakub Kicinski

net: ag71xx: devm_clk_get_enabled

Allows removal of clk_prepare_enable to simplify the code slightly.

Tested on a TP-LINK Archer C7v2.
Signed-off-by: default avatarRosen Penev <rosenp@gmail.com>
Link: https://patch.msgid.link/20240813170516.7301-2-rosenp@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7a4e0801
...@@ -699,29 +699,20 @@ static int ag71xx_mdio_probe(struct ag71xx *ag) ...@@ -699,29 +699,20 @@ static int ag71xx_mdio_probe(struct ag71xx *ag)
np = dev->of_node; np = dev->of_node;
ag->mii_bus = NULL; ag->mii_bus = NULL;
ag->clk_mdio = devm_clk_get(dev, "mdio"); ag->clk_mdio = devm_clk_get_enabled(dev, "mdio");
if (IS_ERR(ag->clk_mdio)) { if (IS_ERR(ag->clk_mdio)) {
netif_err(ag, probe, ndev, "Failed to get mdio clk.\n"); netif_err(ag, probe, ndev, "Failed to get mdio clk.\n");
return PTR_ERR(ag->clk_mdio); return PTR_ERR(ag->clk_mdio);
} }
err = clk_prepare_enable(ag->clk_mdio);
if (err) {
netif_err(ag, probe, ndev, "Failed to enable mdio clk.\n");
return err;
}
mii_bus = devm_mdiobus_alloc(dev); mii_bus = devm_mdiobus_alloc(dev);
if (!mii_bus) { if (!mii_bus)
err = -ENOMEM; return -ENOMEM;
goto mdio_err_put_clk;
}
ag->mdio_reset = of_reset_control_get_exclusive(np, "mdio"); ag->mdio_reset = of_reset_control_get_exclusive(np, "mdio");
if (IS_ERR(ag->mdio_reset)) { if (IS_ERR(ag->mdio_reset)) {
netif_err(ag, probe, ndev, "Failed to get reset mdio.\n"); netif_err(ag, probe, ndev, "Failed to get reset mdio.\n");
err = PTR_ERR(ag->mdio_reset); return PTR_ERR(ag->mdio_reset);
goto mdio_err_put_clk;
} }
mii_bus->name = "ag71xx_mdio"; mii_bus->name = "ag71xx_mdio";
...@@ -743,22 +734,17 @@ static int ag71xx_mdio_probe(struct ag71xx *ag) ...@@ -743,22 +734,17 @@ static int ag71xx_mdio_probe(struct ag71xx *ag)
err = of_mdiobus_register(mii_bus, mnp); err = of_mdiobus_register(mii_bus, mnp);
of_node_put(mnp); of_node_put(mnp);
if (err) if (err)
goto mdio_err_put_clk; return err;
ag->mii_bus = mii_bus; ag->mii_bus = mii_bus;
return 0; return 0;
mdio_err_put_clk:
clk_disable_unprepare(ag->clk_mdio);
return err;
} }
static void ag71xx_mdio_remove(struct ag71xx *ag) static void ag71xx_mdio_remove(struct ag71xx *ag)
{ {
if (ag->mii_bus) if (ag->mii_bus)
mdiobus_unregister(ag->mii_bus); mdiobus_unregister(ag->mii_bus);
clk_disable_unprepare(ag->clk_mdio);
} }
static void ag71xx_hw_stop(struct ag71xx *ag) static void ag71xx_hw_stop(struct ag71xx *ag)
...@@ -1853,7 +1839,7 @@ static int ag71xx_probe(struct platform_device *pdev) ...@@ -1853,7 +1839,7 @@ static int ag71xx_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
ag->clk_eth = devm_clk_get(&pdev->dev, "eth"); ag->clk_eth = devm_clk_get_enabled(&pdev->dev, "eth");
if (IS_ERR(ag->clk_eth)) { if (IS_ERR(ag->clk_eth)) {
netif_err(ag, probe, ndev, "Failed to get eth clk.\n"); netif_err(ag, probe, ndev, "Failed to get eth clk.\n");
return PTR_ERR(ag->clk_eth); return PTR_ERR(ag->clk_eth);
...@@ -1933,19 +1919,13 @@ static int ag71xx_probe(struct platform_device *pdev) ...@@ -1933,19 +1919,13 @@ static int ag71xx_probe(struct platform_device *pdev)
netif_napi_add_weight(ndev, &ag->napi, ag71xx_poll, netif_napi_add_weight(ndev, &ag->napi, ag71xx_poll,
AG71XX_NAPI_WEIGHT); AG71XX_NAPI_WEIGHT);
err = clk_prepare_enable(ag->clk_eth);
if (err) {
netif_err(ag, probe, ndev, "Failed to enable eth clk.\n");
return err;
}
ag71xx_wr(ag, AG71XX_REG_MAC_CFG1, 0); ag71xx_wr(ag, AG71XX_REG_MAC_CFG1, 0);
ag71xx_hw_init(ag); ag71xx_hw_init(ag);
err = ag71xx_mdio_probe(ag); err = ag71xx_mdio_probe(ag);
if (err) if (err)
goto err_put_clk; return err;
platform_set_drvdata(pdev, ndev); platform_set_drvdata(pdev, ndev);
...@@ -1970,8 +1950,6 @@ static int ag71xx_probe(struct platform_device *pdev) ...@@ -1970,8 +1950,6 @@ static int ag71xx_probe(struct platform_device *pdev)
err_mdio_remove: err_mdio_remove:
ag71xx_mdio_remove(ag); ag71xx_mdio_remove(ag);
err_put_clk:
clk_disable_unprepare(ag->clk_eth);
return err; return err;
} }
...@@ -1986,7 +1964,6 @@ static void ag71xx_remove(struct platform_device *pdev) ...@@ -1986,7 +1964,6 @@ static void ag71xx_remove(struct platform_device *pdev)
ag = netdev_priv(ndev); ag = netdev_priv(ndev);
unregister_netdev(ndev); unregister_netdev(ndev);
ag71xx_mdio_remove(ag); ag71xx_mdio_remove(ag);
clk_disable_unprepare(ag->clk_eth);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment