linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: qcom: clk-rpmh: Fix if statement to match comment
@ 2022-05-31  9:45 Li Zhengyu
  2022-06-10 19:58 ` Stephen Boyd
  0 siblings, 1 reply; 3+ messages in thread
From: Li Zhengyu @ 2022-05-31  9:45 UTC (permalink / raw)
  To: quic_tdas
  Cc: agross, bjorn.andersson, sboyd, linux-arm-msm, linux-clk,
	linux-kernel

(c->state) is u32, (enable) is bool. It returns false when
(c->state) > 1 and (enable) is true. Convert (c->state) to bool.

Signed-off-by: Li Zhengyu <lizhengyu3@huawei.com>
---
 drivers/clk/qcom/clk-rpmh.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
index aed907982344..851e127432a9 100644
--- a/drivers/clk/qcom/clk-rpmh.c
+++ b/drivers/clk/qcom/clk-rpmh.c
@@ -196,7 +196,7 @@ static int clk_rpmh_aggregate_state_send_command(struct clk_rpmh *c,
 	int ret;
 
 	/* Nothing required to be done if already off or on */
-	if (enable == c->state)
+	if (enable == !!c->state)
 		return 0;
 
 	c->state = enable ? c->valid_state_mask : 0;
-- 
2.17.1


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

* Re: [PATCH] clk: qcom: clk-rpmh: Fix if statement to match comment
  2022-05-31  9:45 [PATCH] clk: qcom: clk-rpmh: Fix if statement to match comment Li Zhengyu
@ 2022-06-10 19:58 ` Stephen Boyd
  2022-06-13  3:50   ` lizhengyu (E)
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Boyd @ 2022-06-10 19:58 UTC (permalink / raw)
  To: Li Zhengyu, quic_tdas
  Cc: agross, bjorn.andersson, linux-arm-msm, linux-clk, linux-kernel

Quoting Li Zhengyu (2022-05-31 02:45:39)
> (c->state) is u32, (enable) is bool. It returns false when
> (c->state) > 1 and (enable) is true. Convert (c->state) to bool.
> 
> Signed-off-by: Li Zhengyu <lizhengyu3@huawei.com>

Nice catch! It looks like it fixes an optimization, where we don't want
to run through and check has_state_changed() if this clk is already
enabled or disabled. But how does this ever happen? The clk framework
already reference counts prepare/unprepare, so how can we get into this
function when the condition would be true, after this patch?

I think we can simply remove the if condition entirely. Do you agree?

> ---
>  drivers/clk/qcom/clk-rpmh.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
> index aed907982344..851e127432a9 100644
> --- a/drivers/clk/qcom/clk-rpmh.c
> +++ b/drivers/clk/qcom/clk-rpmh.c
> @@ -196,7 +196,7 @@ static int clk_rpmh_aggregate_state_send_command(struct clk_rpmh *c,
>         int ret;
>  
>         /* Nothing required to be done if already off or on */
> -       if (enable == c->state)
> +       if (enable == !!c->state)
>                 return 0;
>  
>         c->state = enable ? c->valid_state_mask : 0;

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

* Re: [PATCH] clk: qcom: clk-rpmh: Fix if statement to match comment
  2022-06-10 19:58 ` Stephen Boyd
@ 2022-06-13  3:50   ` lizhengyu (E)
  0 siblings, 0 replies; 3+ messages in thread
From: lizhengyu (E) @ 2022-06-13  3:50 UTC (permalink / raw)
  To: Stephen Boyd, quic_tdas
  Cc: agross, bjorn.andersson, linux-arm-msm, linux-clk, linux-kernel


On Fri, 10 Jun 2022 12:58:54 -0700, Stephen Boyd <sboyd@kernel.org> wrote:
> Quoting Li Zhengyu (2022-05-31 02:45:39)
>> (c->state) is u32, (enable) is bool. It returns false when
>> (c->state) > 1 and (enable) is true. Convert (c->state) to bool.
>>
>> Signed-off-by: Li Zhengyu <lizhengyu3@huawei.com>
> Nice catch! It looks like it fixes an optimization, where we don't want
> to run through and check has_state_changed() if this clk is already
> enabled or disabled. But how does this ever happen? The clk framework
> already reference counts prepare/unprepare, so how can we get into this
> function when the condition would be true, after this patch?
>
> I think we can simply remove the if condition entirely. Do you agree?

Sure. It seems Taniya Das (also I) hasn't mind the prepare/unprepare

of clk framework. As the result,  this if condition should be never true.

I will send a patch to remove it.

>> ---
>>   drivers/clk/qcom/clk-rpmh.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
>> index aed907982344..851e127432a9 100644
>> --- a/drivers/clk/qcom/clk-rpmh.c
>> +++ b/drivers/clk/qcom/clk-rpmh.c
>> @@ -196,7 +196,7 @@ static int clk_rpmh_aggregate_state_send_command(struct clk_rpmh *c,
>>          int ret;
>>   
>>          /* Nothing required to be done if already off or on */
>> -       if (enable == c->state)
>> +       if (enable == !!c->state)
>>                  return 0;
>>   
>>          c->state = enable ? c->valid_state_mask : 0;
> .

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

end of thread, other threads:[~2022-06-13  3:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-31  9:45 [PATCH] clk: qcom: clk-rpmh: Fix if statement to match comment Li Zhengyu
2022-06-10 19:58 ` Stephen Boyd
2022-06-13  3:50   ` lizhengyu (E)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).