[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKxU2N_nk_H9bHnofqYquSzVfQboayM3ELbPZy4=C=RNvM7Kkg@mail.gmail.com>
Date: Mon, 12 Aug 2024 14:08:11 -0700
From: Rosen Penev <rosenp@...il.com>
To: netdev@...r.kernel.org
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, linux@...linux.org.uk, linux-kernel@...r.kernel.org,
o.rempel@...gutronix.de
Subject: Re: [PATCH net-next 1/3] net: ag71xx: use devm_clk_get_enabled
On Mon, Aug 12, 2024 at 12:07 PM Rosen Penev <rosenp@...il.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@...il.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
>
Powered by blists - more mailing lists