clk: imx: DRY cleanup of imx_obtain_fixed_clock_hw()

Message ID 20221113180945.1626061-1-dario.binacchi@amarulasolutions.com
State New
Headers
Series clk: imx: DRY cleanup of imx_obtain_fixed_clock_hw() |

Commit Message

Dario Binacchi Nov. 13, 2022, 6:09 p.m. UTC
  The imx_obtain_fixed_clock() and imx_obtain_fixed_clock_hw() functions
behave pretty similarly, DRY and call one from another.

No functional changes intended.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>

---

 drivers/clk/imx/clk.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
  

Comments

Abel Vesa Nov. 21, 2022, 7:19 p.m. UTC | #1
On 22-11-13 19:09:44, Dario Binacchi wrote:
> The imx_obtain_fixed_clock() and imx_obtain_fixed_clock_hw() functions
> behave pretty similarly, DRY and call one from another.
> 
> No functional changes intended.
> 
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> 
> ---
> 
>  drivers/clk/imx/clk.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
> index 5582f18dd632..573b1a6ca1dc 100644
> --- a/drivers/clk/imx/clk.c
> +++ b/drivers/clk/imx/clk.c
> @@ -104,9 +104,7 @@ struct clk_hw *imx_obtain_fixed_clock_hw(
>  {
>  	struct clk *clk;
>  
> -	clk = imx_obtain_fixed_clock_from_dt(name);
> -	if (IS_ERR(clk))
> -		clk = imx_clk_fixed(name, rate);
> +	clk = imx_obtain_fixed_clock(name, rate);

NACK here. You're switching to a non "clk_hw" based variant that
should/would be removed in the near future.

In the future, we want the clock providers to not used "clk" based APIs.

Rule is, AFAIR, to use "clk" based APIs in clock consumer drivers only,
while using "clk_hw" based APIs in clock provider drivers only.

Right now, only the imx5 and vf610 clock provider drivers still use the
'clk' based API. Once those are switched to 'clk_hw' based, all the 'clk'
i.MX specific APIs will be removed for good.

>  	return __clk_get_hw(clk);
>  }
>  
> -- 
> 2.32.0
>
  
Dario Binacchi Nov. 23, 2022, 7:47 a.m. UTC | #2
Hi Abel,

On Mon, Nov 21, 2022 at 8:19 PM Abel Vesa <abel.vesa@linaro.org> wrote:
>
> On 22-11-13 19:09:44, Dario Binacchi wrote:
> > The imx_obtain_fixed_clock() and imx_obtain_fixed_clock_hw() functions
> > behave pretty similarly, DRY and call one from another.
> >
> > No functional changes intended.
> >
> > Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> >
> > ---
> >
> >  drivers/clk/imx/clk.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
> > index 5582f18dd632..573b1a6ca1dc 100644
> > --- a/drivers/clk/imx/clk.c
> > +++ b/drivers/clk/imx/clk.c
> > @@ -104,9 +104,7 @@ struct clk_hw *imx_obtain_fixed_clock_hw(
> >  {
> >       struct clk *clk;
> >
> > -     clk = imx_obtain_fixed_clock_from_dt(name);
> > -     if (IS_ERR(clk))
> > -             clk = imx_clk_fixed(name, rate);
> > +     clk = imx_obtain_fixed_clock(name, rate);
>
> NACK here. You're switching to a non "clk_hw" based variant that
> should/would be removed in the near future.
>
> In the future, we want the clock providers to not used "clk" based APIs.
>
> Rule is, AFAIR, to use "clk" based APIs in clock consumer drivers only,
> while using "clk_hw" based APIs in clock provider drivers only.
>
> Right now, only the imx5 and vf610 clock provider drivers still use the
> 'clk' based API. Once those are switched to 'clk_hw' based, all the 'clk'
> i.MX specific APIs will be removed for good.

Thanks for your explanations.

Best regards,

Dario

>
> >       return __clk_get_hw(clk);
> >  }
> >
> > --
> > 2.32.0
> >
  

Patch

diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
index 5582f18dd632..573b1a6ca1dc 100644
--- a/drivers/clk/imx/clk.c
+++ b/drivers/clk/imx/clk.c
@@ -104,9 +104,7 @@  struct clk_hw *imx_obtain_fixed_clock_hw(
 {
 	struct clk *clk;
 
-	clk = imx_obtain_fixed_clock_from_dt(name);
-	if (IS_ERR(clk))
-		clk = imx_clk_fixed(name, rate);
+	clk = imx_obtain_fixed_clock(name, rate);
 	return __clk_get_hw(clk);
 }