diff mbox series

[v1] ACPI /amba: Fix meaningless code for amba_register_dummy_clk()

Message ID 20240616100054.241482-1-youwan@nfschina.com (mailing list archive)
State New, archived
Headers show
Series [v1] ACPI /amba: Fix meaningless code for amba_register_dummy_clk() | expand

Commit Message

Youwan Wang June 16, 2024, 10 a.m. UTC
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(-)

Comments

Christophe JAILLET June 16, 2024, 1:05 p.m. UTC | #1
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);
Hanjun Guo June 18, 2024, 6:47 a.m. UTC | #2
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
diff mbox series

Patch

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);