diff mbox series

[net-next,1/3] net: ag71xx: use devm_clk_get_enabled

Message ID 20240812190700.14270-2-rosenp@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series use more devm | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 7 this patch: 7
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: chris.snook@gmail.com
netdev/build_clang success Errors and warnings before: 7 this patch: 7
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 93 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-08-12--21-00 (tests: 707)

Commit Message

Rosen Penev Aug. 12, 2024, 7:06 p.m. UTC
Allows removal of clk_prepare_enable to simplify the code slightly.

Tested on a TP-LINK Archer C7v2.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/net/ethernet/atheros/ag71xx.c | 31 ++++++---------------------
 1 file changed, 7 insertions(+), 24 deletions(-)

Comments

Daniel Golle Aug. 12, 2024, 8:48 p.m. UTC | #1
On Mon, Aug 12, 2024 at 12:06:51PM -0700, Rosen Penev wrote:
> Allows removal of clk_prepare_enable to simplify the code slightly.
> 
> Tested on a TP-LINK Archer C7v2.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>

Reviewed-by: Daniel Golle <daniel@makrotopia.org>
Rosen Penev Aug. 12, 2024, 9:08 p.m. UTC | #2
On Mon, Aug 12, 2024 at 12:07 PM Rosen Penev <rosenp@gmail.com> wrote:
>
> Allows removal of clk_prepare_enable to simplify the code slightly.
>
> Tested on a TP-LINK Archer C7v2.
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  drivers/net/ethernet/atheros/ag71xx.c | 31 ++++++---------------------
>  1 file changed, 7 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/net/ethernet/atheros/ag71xx.c b/drivers/net/ethernet/atheros/ag71xx.c
> index 6fc4996c8131..c22ebd3c1f46 100644
> --- a/drivers/net/ethernet/atheros/ag71xx.c
> +++ b/drivers/net/ethernet/atheros/ag71xx.c
> @@ -691,7 +691,7 @@ static int ag71xx_mdio_probe(struct ag71xx *ag)
>         np = dev->of_node;
>         ag->mii_bus = NULL;
>
> -       ag->clk_mdio = devm_clk_get(dev, "mdio");
> +       ag->clk_mdio = devm_clk_get_enabled(dev, "mdio");
I forgot to remove the following section. Will do this in v2. I'll
send tomorrow as rules seem to be no new patches for 24 hours.
>         if (IS_ERR(ag->clk_mdio)) {
>                 netif_err(ag, probe, ndev, "Failed to get mdio clk.\n");
>                 return PTR_ERR(ag->clk_mdio);
> @@ -704,16 +704,13 @@ static int ag71xx_mdio_probe(struct ag71xx *ag)
>         }
>
>         mii_bus = devm_mdiobus_alloc(dev);
> -       if (!mii_bus) {
> -               err = -ENOMEM;
> -               goto mdio_err_put_clk;
> -       }
> +       if (!mii_bus)
> +               return -ENOMEM;
>
>         ag->mdio_reset = of_reset_control_get_exclusive(np, "mdio");
>         if (IS_ERR(ag->mdio_reset)) {
>                 netif_err(ag, probe, ndev, "Failed to get reset mdio.\n");
> -               err = PTR_ERR(ag->mdio_reset);
> -               goto mdio_err_put_clk;
> +               return PTR_ERR(ag->mdio_reset);
>         }
>
>         mii_bus->name = "ag71xx_mdio";
> @@ -735,22 +732,17 @@ static int ag71xx_mdio_probe(struct ag71xx *ag)
>         err = of_mdiobus_register(mii_bus, mnp);
>         of_node_put(mnp);
>         if (err)
> -               goto mdio_err_put_clk;
> +               return err;
>
>         ag->mii_bus = mii_bus;
>
>         return 0;
> -
> -mdio_err_put_clk:
> -       clk_disable_unprepare(ag->clk_mdio);
> -       return err;
>  }
>
>  static void ag71xx_mdio_remove(struct ag71xx *ag)
>  {
>         if (ag->mii_bus)
>                 mdiobus_unregister(ag->mii_bus);
> -       clk_disable_unprepare(ag->clk_mdio);
>  }
>
>  static void ag71xx_hw_stop(struct ag71xx *ag)
> @@ -1845,7 +1837,7 @@ static int ag71xx_probe(struct platform_device *pdev)
>                 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)) {
>                 netif_err(ag, probe, ndev, "Failed to get eth clk.\n");
>                 return PTR_ERR(ag->clk_eth);
> @@ -1925,19 +1917,13 @@ static int ag71xx_probe(struct platform_device *pdev)
>         netif_napi_add_weight(ndev, &ag->napi, ag71xx_poll,
>                               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_hw_init(ag);
>
>         err = ag71xx_mdio_probe(ag);
>         if (err)
> -               goto err_put_clk;
> +               return err;
>
>         platform_set_drvdata(pdev, ndev);
>
> @@ -1962,8 +1948,6 @@ static int ag71xx_probe(struct platform_device *pdev)
>
>  err_mdio_remove:
>         ag71xx_mdio_remove(ag);
> -err_put_clk:
> -       clk_disable_unprepare(ag->clk_eth);
>         return err;
>  }
>
> @@ -1978,7 +1962,6 @@ static void ag71xx_remove(struct platform_device *pdev)
>         ag = netdev_priv(ndev);
>         unregister_netdev(ndev);
>         ag71xx_mdio_remove(ag);
> -       clk_disable_unprepare(ag->clk_eth);
>         platform_set_drvdata(pdev, NULL);
>  }
>
> --
> 2.46.0
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/atheros/ag71xx.c b/drivers/net/ethernet/atheros/ag71xx.c
index 6fc4996c8131..c22ebd3c1f46 100644
--- a/drivers/net/ethernet/atheros/ag71xx.c
+++ b/drivers/net/ethernet/atheros/ag71xx.c
@@ -691,7 +691,7 @@  static int ag71xx_mdio_probe(struct ag71xx *ag)
 	np = dev->of_node;
 	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)) {
 		netif_err(ag, probe, ndev, "Failed to get mdio clk.\n");
 		return PTR_ERR(ag->clk_mdio);
@@ -704,16 +704,13 @@  static int ag71xx_mdio_probe(struct ag71xx *ag)
 	}
 
 	mii_bus = devm_mdiobus_alloc(dev);
-	if (!mii_bus) {
-		err = -ENOMEM;
-		goto mdio_err_put_clk;
-	}
+	if (!mii_bus)
+		return -ENOMEM;
 
 	ag->mdio_reset = of_reset_control_get_exclusive(np, "mdio");
 	if (IS_ERR(ag->mdio_reset)) {
 		netif_err(ag, probe, ndev, "Failed to get reset mdio.\n");
-		err = PTR_ERR(ag->mdio_reset);
-		goto mdio_err_put_clk;
+		return PTR_ERR(ag->mdio_reset);
 	}
 
 	mii_bus->name = "ag71xx_mdio";
@@ -735,22 +732,17 @@  static int ag71xx_mdio_probe(struct ag71xx *ag)
 	err = of_mdiobus_register(mii_bus, mnp);
 	of_node_put(mnp);
 	if (err)
-		goto mdio_err_put_clk;
+		return err;
 
 	ag->mii_bus = mii_bus;
 
 	return 0;
-
-mdio_err_put_clk:
-	clk_disable_unprepare(ag->clk_mdio);
-	return err;
 }
 
 static void ag71xx_mdio_remove(struct ag71xx *ag)
 {
 	if (ag->mii_bus)
 		mdiobus_unregister(ag->mii_bus);
-	clk_disable_unprepare(ag->clk_mdio);
 }
 
 static void ag71xx_hw_stop(struct ag71xx *ag)
@@ -1845,7 +1837,7 @@  static int ag71xx_probe(struct platform_device *pdev)
 		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)) {
 		netif_err(ag, probe, ndev, "Failed to get eth clk.\n");
 		return PTR_ERR(ag->clk_eth);
@@ -1925,19 +1917,13 @@  static int ag71xx_probe(struct platform_device *pdev)
 	netif_napi_add_weight(ndev, &ag->napi, ag71xx_poll,
 			      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_hw_init(ag);
 
 	err = ag71xx_mdio_probe(ag);
 	if (err)
-		goto err_put_clk;
+		return err;
 
 	platform_set_drvdata(pdev, ndev);
 
@@ -1962,8 +1948,6 @@  static int ag71xx_probe(struct platform_device *pdev)
 
 err_mdio_remove:
 	ag71xx_mdio_remove(ag);
-err_put_clk:
-	clk_disable_unprepare(ag->clk_eth);
 	return err;
 }
 
@@ -1978,7 +1962,6 @@  static void ag71xx_remove(struct platform_device *pdev)
 	ag = netdev_priv(ndev);
 	unregister_netdev(ndev);
 	ag71xx_mdio_remove(ag);
-	clk_disable_unprepare(ag->clk_eth);
 	platform_set_drvdata(pdev, NULL);
 }