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

Youwan Wang posted 1 patch 1 year, 6 months ago
drivers/acpi/arm64/amba.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
[PATCH v3] ACPI /amba: Fix meaningless code for amba_register_dummy_clk()
Posted by Youwan Wang 1 year, 6 months ago
Defining `amba_dummy_clk` as static is meaningless.

The amba_register_dummy_clk() function is static and
is called during initialization. I think 'amba_dummy_clk'
should be NULL each time when initializing

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
Re: [PATCH v3] ACPI /amba: Fix meaningless code for amba_register_dummy_clk()
Posted by Sudeep Holla 1 year, 5 months ago
On Tue, Jun 18, 2024 at 07:58:45PM +0800, Youwan Wang wrote:
> Defining `amba_dummy_clk` as static is meaningless.
> 
> The amba_register_dummy_clk() function is static and
> is called during initialization. I think 'amba_dummy_clk'
> should be NULL each time when initializing
>

Also I missed to read the commit message, please update it as follows:

"
ACPI / amba: Drop unnecessary check for registered amba_dummy_clk

amba_register_dummy_clk() is called only once from acpi_amba_init()
and acpi_amba_init() itself is called once during the initialisation.
amba_dummy_clk cann't be initialised before this in any other code
path and hence the check for already registered amba_dummy_clk is
not necessary. Drop the same.
"

Also few other things to note:
1. You missed to add my Acked-by which I gave to your v2
2. This is v3 and new reviewers of this patch have absolutely no idea
   what got changed from v1->v2->v3. It is always good to add change log
   across versions
3. I asked you to add ARM64 maintainers as we would request them to pick
   this up via ARM64 tree.
	Catalin Marinas <catalin.marinas@arm.com
	Will Deacon <will@kernel.org>

--
Regards,
Sudeep
[PATCH] ACPI / amba: Drop unnecessary check for registered amba_dummy_clk
Posted by Youwan Wang 1 year, 5 months ago
amba_register_dummy_clk() is called only once from acpi_amba_init()
and acpi_amba_init() itself is called once during the initialisation.
amba_dummy_clk can't be initialised before this in any other code
path and hence the check for already registered amba_dummy_clk is
not necessary. Drop the same.

Signed-off-by: Youwan Wang <youwan@nfschina.com>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
---
v1->v2->v3: Modify the commit log description
---
 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
Re: [PATCH] ACPI / amba: Drop unnecessary check for registered amba_dummy_clk
Posted by Hanjun Guo 1 year, 5 months ago
Hi Youwan,

Please use v4 for your patch subject which was suggested by Sudeep:

[PATCH v4] ACPI / amba: Drop unnecessary check for registered amba_dummy_clk

On 2024/6/20 21:37, Youwan Wang wrote:
> amba_register_dummy_clk() is called only once from acpi_amba_init()
> and acpi_amba_init() itself is called once during the initialisation.
> amba_dummy_clk can't be initialised before this in any other code
> path and hence the check for already registered amba_dummy_clk is
> not necessary. Drop the same.
> 
> Signed-off-by: Youwan Wang <youwan@nfschina.com>
> Acked-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> v1->v2->v3: Modify the commit log description

Please update it as follows:

Changes from v3:
- Update the commit message suggested by Sudeep;
- Add Acked-by from Sudeep;
- +Cc ARM64 maintainers Catalin and Will.

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

With that updated,

Acked-by: Hanjun Guo <guohanjun@huawei.com>

Thanks
Hanjun
[PATCH v4] ACPI / amba: Drop unnecessary check for registered amba_dummy_clk
Posted by Youwan Wang 1 year, 5 months ago
amba_register_dummy_clk() is called only once from acpi_amba_init()
and acpi_amba_init() itself is called once during the initialisation.
amba_dummy_clk can't be initialised before this in any other code
path and hence the check for already registered amba_dummy_clk is
not necessary. Drop the same.

Signed-off-by: Youwan Wang <youwan@nfschina.com>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Hanjun Guo <guohanjun@huawei.com>
---
v1->v2->v3: Modify the commit log description
v3->v4: Update the commit message suggested by Sudeep;
        Add Acked-by from Sudeep;
        +Cc ARM64 maintainers Catalin and Will.
---
 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
Re: [PATCH v4] ACPI / amba: Drop unnecessary check for registered amba_dummy_clk
Posted by Catalin Marinas 1 year, 5 months ago
On Mon, 24 Jun 2024 10:31:01 +0800, Youwan Wang wrote:
> amba_register_dummy_clk() is called only once from acpi_amba_init()
> and acpi_amba_init() itself is called once during the initialisation.
> amba_dummy_clk can't be initialised before this in any other code
> path and hence the check for already registered amba_dummy_clk is
> not necessary. Drop the same.
> 
> 
> [...]

Applied to arm64 (for-next/acpi), thanks!

[1/1] ACPI / amba: Drop unnecessary check for registered amba_dummy_clk
      https://git.kernel.org/arm64/c/bfe3f0df3e3c

-- 
Catalin
Re: [PATCH v4] ACPI / amba: Drop unnecessary check for registered amba_dummy_clk
Posted by Sudeep Holla 1 year, 5 months ago
On Mon, Jun 24, 2024 at 10:31:01AM +0800, Youwan Wang wrote:
> amba_register_dummy_clk() is called only once from acpi_amba_init()
> and acpi_amba_init() itself is called once during the initialisation.
> amba_dummy_clk can't be initialised before this in any other code
> path and hence the check for already registered amba_dummy_clk is
> not necessary. Drop the same.
> 
> Signed-off-by: Youwan Wang <youwan@nfschina.com>
> Acked-by: Sudeep Holla <sudeep.holla@arm.com>
> Acked-by: Hanjun Guo <guohanjun@huawei.com>
> ---

Hi Catalin,

Can you please pick up this simple cleanup patch under ACPI changes ?
It is very hard to follow the versions as it is messed up, but this
version is good to take though.

--
Regards,
Sudeep
Re: [PATCH v4] ACPI / amba: Drop unnecessary check for registered amba_dummy_clk
Posted by Sudeep Holla 1 year, 5 months ago
On Mon, Jun 24, 2024 at 10:31:01AM +0800, Youwan Wang wrote:
> amba_register_dummy_clk() is called only once from acpi_amba_init()
> and acpi_amba_init() itself is called once during the initialisation.
> amba_dummy_clk can't be initialised before this in any other code
> path and hence the check for already registered amba_dummy_clk is
> not necessary. Drop the same.
> 
> Signed-off-by: Youwan Wang <youwan@nfschina.com>
> Acked-by: Sudeep Holla <sudeep.holla@arm.com>
> Acked-by: Hanjun Guo <guohanjun@huawei.com>
> ---
> v1->v2->v3: Modify the commit log description
> v3->v4: Update the commit message suggested by Sudeep;
>         Add Acked-by from Sudeep;
>         +Cc ARM64 maintainers Catalin and Will.


I think I have told you many time now and you are missing to understand
few basic stuff. So I suggest to give
`Documentation/process/submitting-patches.rst`
under the kernel source a read and especially the section
`The canonical patch format`

Ideally this patch should have been v5 as you added Hanjun's Ack
Also "v1->v2->v3: Modify the commit log description" makes no sense.

The changelog should list all the deltas like:
v4->v5:
	- <blah3 blah3>
v3->v4:
	- <blah2 blah2>
v2->v3:
	- <blah1 blah1>
v1->v2:
	- <blah blah>

Anyways, it is only for your learning and future references.

--
Regards,
Sudeep