Linux clock framework development
 help / color / mirror / Atom feed
* [PATCH] clk:sophgo:clk-cv18xx-pll
@ 2024-11-12 22:58 Ragavendra
  2024-11-13  0:33 ` Chen Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Ragavendra @ 2024-11-12 22:58 UTC (permalink / raw)
  To: mturquette, sboyd, unicorn_wang, inochiama
  Cc: linux-clk, linux-kernel, Ragavendra

Initializing the val variable of type u32 as it was not initialized.

Signed-off-by: Ragavendra Nagraj <ragavendra.bn@gmail.com>
---
 drivers/clk/sophgo/clk-cv18xx-pll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/sophgo/clk-cv18xx-pll.c b/drivers/clk/sophgo/clk-cv18xx-pll.c
index 29e24098bf5f..04a0419cab4e 100644
--- a/drivers/clk/sophgo/clk-cv18xx-pll.c
+++ b/drivers/clk/sophgo/clk-cv18xx-pll.c
@@ -87,7 +87,7 @@ static int ipll_find_rate(const struct cv1800_clk_pll_limit *limit,
 
 static int ipll_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
 {
-	u32 val;
+	u32 val = 0;
 	struct cv1800_clk_pll *pll = hw_to_cv1800_clk_pll(hw);
 
 	return ipll_find_rate(pll->pll_limit, req->best_parent_rate,
-- 
2.46.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk:sophgo:clk-cv18xx-pll
  2024-11-12 22:58 [PATCH] clk:sophgo:clk-cv18xx-pll Ragavendra
@ 2024-11-13  0:33 ` Chen Wang
  2024-11-13  1:16   ` Inochi Amaoto
  0 siblings, 1 reply; 3+ messages in thread
From: Chen Wang @ 2024-11-13  0:33 UTC (permalink / raw)
  To: Ragavendra, mturquette, sboyd, inochiama; +Cc: linux-clk, linux-kernel

Pleas improve the patch title and just write "fix..." instead of listing 
the file name changed.

On 2024/11/13 6:58, Ragavendra wrote:
> Initializing the val variable of type u32 as it was not initialized.
>
Please add "Fixes" tag here, see 
https://www.kernel.org/doc/html/latest/process/submitting-patches.html.
> Signed-off-by: Ragavendra Nagraj <ragavendra.bn@gmail.com>
> ---
>   drivers/clk/sophgo/clk-cv18xx-pll.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clk/sophgo/clk-cv18xx-pll.c b/drivers/clk/sophgo/clk-cv18xx-pll.c
> index 29e24098bf5f..04a0419cab4e 100644
> --- a/drivers/clk/sophgo/clk-cv18xx-pll.c
> +++ b/drivers/clk/sophgo/clk-cv18xx-pll.c
> @@ -87,7 +87,7 @@ static int ipll_find_rate(const struct cv1800_clk_pll_limit *limit,
>   
>   static int ipll_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
>   {
> -	u32 val;
> +	u32 val = 0;
>   	struct cv1800_clk_pll *pll = hw_to_cv1800_clk_pll(hw);
>   
>   	return ipll_find_rate(pll->pll_limit, req->best_parent_rate,

I looked at ipll_find_rate() and found that the parameters 
"rate"/"value" are both input and output parameters, which is really a 
place that needs to be treated with caution.

Seems this patch change is correct, otherwise the value of "detected" in 
the function will be random after calling ipll_find_rate here.  Actually 
I suggest adding some comments for ipll_find_rate() to emphasize it. 
Otherwise, it is easy to think that "rate" and "value" are only output 
parameters at first glance.

But I raised a question here: In ipll_find_rate(), do we really need to 
make "detected" depend on the value of external input? Inochi, can you 
please comment on this, due to you are the author of this code.

Reviewed-by: Chen Wang <unicorn_wang@outlook.com>

Thanks,

Chen


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk:sophgo:clk-cv18xx-pll
  2024-11-13  0:33 ` Chen Wang
@ 2024-11-13  1:16   ` Inochi Amaoto
  0 siblings, 0 replies; 3+ messages in thread
From: Inochi Amaoto @ 2024-11-13  1:16 UTC (permalink / raw)
  To: Chen Wang, Ragavendra, mturquette, sboyd, inochiama
  Cc: linux-clk, linux-kernel

On Wed, Nov 13, 2024 at 08:33:54AM +0800, Chen Wang wrote:
> Pleas improve the patch title and just write "fix..." instead of listing the
> file name changed.
> 
> On 2024/11/13 6:58, Ragavendra wrote:
> > Initializing the val variable of type u32 as it was not initialized.
> > 
> Please add "Fixes" tag here, see
> https://www.kernel.org/doc/html/latest/process/submitting-patches.html.
> > Signed-off-by: Ragavendra Nagraj <ragavendra.bn@gmail.com>
> > ---
> >   drivers/clk/sophgo/clk-cv18xx-pll.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/clk/sophgo/clk-cv18xx-pll.c b/drivers/clk/sophgo/clk-cv18xx-pll.c
> > index 29e24098bf5f..04a0419cab4e 100644
> > --- a/drivers/clk/sophgo/clk-cv18xx-pll.c
> > +++ b/drivers/clk/sophgo/clk-cv18xx-pll.c
> > @@ -87,7 +87,7 @@ static int ipll_find_rate(const struct cv1800_clk_pll_limit *limit,
> >   static int ipll_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
> >   {
> > -	u32 val;
> > +	u32 val = 0;
> >   	struct cv1800_clk_pll *pll = hw_to_cv1800_clk_pll(hw);
> >   	return ipll_find_rate(pll->pll_limit, req->best_parent_rate,
> 
> I looked at ipll_find_rate() and found that the parameters "rate"/"value"
> are both input and output parameters, which is really a place that needs to
> be treated with caution.
> 
> Seems this patch change is correct, otherwise the value of "detected" in the
> function will be random after calling ipll_find_rate here.  Actually I
> suggest adding some comments for ipll_find_rate() to emphasize it.
> Otherwise, it is easy to think that "rate" and "value" are only output
> parameters at first glance.
> 

Since ipll_determine_rate does not use "val" in later,
it is OK to not init it. 

> But I raised a question here: In ipll_find_rate(), do we really need to make
> "detected" depend on the value of external input? Inochi, can you please
> comment on this, due to you are the author of this code.
> 

As using the detected value, an extra mask is used
to emit unused field. See macro PLL_COPY_REG.
A more suitable fix may init the "detected" to 0 in the 
ipll/fpll_find_rate to make "value" is output only.

Regards,
Inochi

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-13  1:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-12 22:58 [PATCH] clk:sophgo:clk-cv18xx-pll Ragavendra
2024-11-13  0:33 ` Chen Wang
2024-11-13  1:16   ` Inochi Amaoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox