Netdev List
 help / color / mirror / Atom feed
From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 2/3 net-next] net: mdio: mscc-miim: Use devm_clk_get_optional_enabled()
Date: Fri, 15 May 2026 17:53:11 +0200	[thread overview]
Message-ID: <15543e63-5c95-4558-9a95-3e9d051d67bc@bootlin.com> (raw)
In-Reply-To: <542f88aee5de2ac24fca58001eab24ac817abee9.1778856199.git.christophe.jaillet@wanadoo.fr>

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@wanadoo.fr>
> ---
> 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@bootlin.com>

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);
>   }
>   


  reply	other threads:[~2026-05-15 15:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15 14:50 [PATCH 0/3] net: phy: micrel: Code clean-up Christophe JAILLET
2026-05-15 14:50 ` [PATCH 1/3 net-next] net: mdio: mscc-miim: Remove some redundant code Christophe JAILLET
2026-05-15 15:45   ` Maxime Chevallier
2026-05-15 14:50 ` [PATCH 2/3 net-next] net: mdio: mscc-miim: Use devm_clk_get_optional_enabled() Christophe JAILLET
2026-05-15 15:53   ` Maxime Chevallier [this message]
2026-05-15 14:50 ` [PATCH 3/3 net-next] net: mdio: mscc-miim: Use devm_of_mdiobus_register() Christophe JAILLET
2026-05-15 15:54   ` Maxime Chevallier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15543e63-5c95-4558-9a95-3e9d051d67bc@bootlin.com \
    --to=maxime.chevallier@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox