mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] ACPI /amba: Fix meaningless code for amba_register_dummy_clk()
@ 2024-06-16 10:00 Youwan Wang
  2024-06-16 13:05 ` Christophe JAILLET
  0 siblings, 1 reply; 3+ messages in thread
From: Youwan Wang @ 2024-06-16 10:00 UTC (permalink / raw)
  To: lpieralisi; +Cc: guohanjun, linux-kernel, linux-arm-kernel, lenb, Youwan Wang

Defining `amba_dummy_clk` as static is meaningless.

The conditional check `if (amba_dummy_clk)` is intended to
determine whether the clock has already been registered.
However,in this function, the variable `amba_dummy_clk`
will always be NULL.

Signed-off-by: Youwan Wang <youwan@nfschina.com>
---
 drivers/acpi/arm64/amba.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c
index 60be8ee1dbdc..ef438417cc80 100644
--- a/drivers/acpi/arm64/amba.c
+++ b/drivers/acpi/arm64/amba.c
@@ -35,11 +35,7 @@ static const struct acpi_device_id amba_id_list[] = {
 
 static void amba_register_dummy_clk(void)
 {
-	static struct clk *amba_dummy_clk;
-
-	/* If clock already registered */
-	if (amba_dummy_clk)
-		return;
+	struct clk *amba_dummy_clk;
 
 	amba_dummy_clk = clk_register_fixed_rate(NULL, "apb_pclk", NULL, 0, 0);
 	clk_register_clkdev(amba_dummy_clk, "apb_pclk", NULL);
-- 
2.25.1


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

* Re: [PATCH v1] ACPI /amba: Fix meaningless code for amba_register_dummy_clk()
  2024-06-16 10:00 [PATCH v1] ACPI /amba: Fix meaningless code for amba_register_dummy_clk() Youwan Wang
@ 2024-06-16 13:05 ` Christophe JAILLET
  2024-06-18  6:47   ` Hanjun Guo
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2024-06-16 13:05 UTC (permalink / raw)
  To: Youwan Wang, lpieralisi; +Cc: guohanjun, linux-kernel, linux-arm-kernel, lenb

Le 16/06/2024 à 12:00, Youwan Wang a écrit :
> Defining `amba_dummy_clk` as static is meaningless.
> 
> The conditional check `if (amba_dummy_clk)` is intended to
> determine whether the clock has already been registered.
> However,in this function, the variable `amba_dummy_clk`
> will always be NULL.

Hi,

  can you elaborate on this "will always be NULL"?

I think that it is NULL on the first call of amba_register_dummy_clk(), 
but if it is called again, it will have the value of 
clk_register_fixed_rate() just a few lines after, doing exactly what the 
comment says.

CJ

> 
> Signed-off-by: Youwan Wang <youwan@nfschina.com>
> ---
>   drivers/acpi/arm64/amba.c | 6 +-----
>   1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c
> index 60be8ee1dbdc..ef438417cc80 100644
> --- a/drivers/acpi/arm64/amba.c
> +++ b/drivers/acpi/arm64/amba.c
> @@ -35,11 +35,7 @@ static const struct acpi_device_id amba_id_list[] = {
>   
>   static void amba_register_dummy_clk(void)
>   {
> -	static struct clk *amba_dummy_clk;
> -
> -	/* If clock already registered */
> -	if (amba_dummy_clk)
> -		return;
> +	struct clk *amba_dummy_clk;
>   
>   	amba_dummy_clk = clk_register_fixed_rate(NULL, "apb_pclk", NULL, 0, 0);
>   	clk_register_clkdev(amba_dummy_clk, "apb_pclk", NULL);


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

* Re: [PATCH v1] ACPI /amba: Fix meaningless code for amba_register_dummy_clk()
  2024-06-16 13:05 ` Christophe JAILLET
@ 2024-06-18  6:47   ` Hanjun Guo
  0 siblings, 0 replies; 3+ messages in thread
From: Hanjun Guo @ 2024-06-18  6:47 UTC (permalink / raw)
  To: Christophe JAILLET, Youwan Wang, lpieralisi
  Cc: linux-kernel, linux-arm-kernel, lenb

On 2024/6/16 21:05, Christophe JAILLET wrote:
> Le 16/06/2024 à 12:00, Youwan Wang a écrit :
>> Defining `amba_dummy_clk` as static is meaningless.
>>
>> The conditional check `if (amba_dummy_clk)` is intended to
>> determine whether the clock has already been registered.
>> However,in this function, the variable `amba_dummy_clk`
>> will always be NULL.
> 
> Hi,
> 
>   can you elaborate on this "will always be NULL"?
> 
> I think that it is NULL on the first call of amba_register_dummy_clk(), 
> but if it is called again, it will have the value of 
> clk_register_fixed_rate() just a few lines after, doing exactly what the 
> comment says.

I think Youwan is arguing that amba_register_dummy_clk() will
never be called more than once, so the static define and check is
redundant.

Thanks
Hanjun

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

end of thread, other threads:[~2024-06-18  6:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-16 10:00 [PATCH v1] ACPI /amba: Fix meaningless code for amba_register_dummy_clk() Youwan Wang
2024-06-16 13:05 ` Christophe JAILLET
2024-06-18  6:47   ` Hanjun Guo

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

all inboxes | Powered by JetHome®