Subject: Re: [PATCH net-next v3 7/8] net: ethernet: fs_enet: simplify clock handling with devm accessors

From: Maxime Chevallier <[email-masked]>
Date: Sat, 14 Sep 2024 10:01:03 +0200

Hello Christophe,

On Fri, 13 Sep 2024 22:24:28 +0200
Christophe JAILLET <[email-masked]> wrote:

> Le 04/09/2024 à 19:18, Maxime Chevallier a écrit :
> > devm_clock_get_enabled() can be used to simplify clock handling for the
> > PER register clock.
> > 
> > Reviewed-by: Andrew Lunn <[email-masked]>
> > Signed-off-by: Maxime Chevallier <[email-masked]>
> > ---
> >   .../ethernet/freescale/fs_enet/fs_enet-main.c    | 16 ++++------------
> >   drivers/net/ethernet/freescale/fs_enet/fs_enet.h |  2 --
> >   2 files changed, 4 insertions(+), 14 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
> > index c96a6b9e1445..ec43b71c0eba 100644
> > --- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
> > +++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
> > @@ -900,14 +900,9 @@ static int fs_enet_probe(struct platform_device *ofdev)
> >   	 * but require enable to succeed when a clock was specified/found,
> >   	 * keep a reference to the clock upon successful acquisition
> >   	 */
> > -	clk = devm_clk_get(&ofdev->dev, "per");
> > -	if (!IS_ERR(clk)) {
> > -		ret = clk_prepare_enable(clk);
> > -		if (ret)
> > -			goto out_deregister_fixed_link;
> > -
> > -		fpi->clk_per = clk;
> > -	}
> > +	clk = devm_clk_get_enabled(&ofdev->dev, "per");
> > +	if (IS_ERR(clk))
> > +		goto out_deregister_fixed_link;  
> 
> Hi,
> 
> I don't know if this can lead to the same issue, but a similar change 
> broke a use case in another driver. See the discussion at[1].
> 
> It ended to using devm_clk_get_optional_enabled() to keep the same 
> behavior as before.

After digging around, there appears to be some platforms that don't
have this clock indeed. Thanks for catching this, the optional is the
way to go.

Thanks,

Maxime