diff mbox series

[3/5] ACPI: PPTT: Remove acpi_find_cache_levels()

Message ID 20221108110424.166896-4-pierre.gondois@arm.com
State Superseded
Headers show
Series arch_topology: Build cacheinfo from primary CPU | expand

Commit Message

Pierre Gondois Nov. 8, 2022, 11:04 a.m. UTC
acpi_find_cache_levels() is used at a single place and is short
enough to be merged into the calling function. The removal allows
an easier renaming of the calling function in the next patch.

Also reorder the parameters in the 'reversed Christmas tree' order.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/acpi/pptt.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

Comments

Sudeep Holla Nov. 8, 2022, 4:13 p.m. UTC | #1
On Tue, Nov 08, 2022 at 12:04:19PM +0100, Pierre Gondois wrote:
> acpi_find_cache_levels() is used at a single place and is short
> enough to be merged into the calling function. The removal allows
> an easier renaming of the calling function in the next patch.
>
> Also reorder the parameters in the 'reversed Christmas tree' order.

Not sure if the above is worth mentioning explicitly. Even if you do,
'parameters' sounds very confusing to at-least me. I was searching for
the changes is some function parameters to understand what it was and
finally realised you meant the stack variable declaration order here.
Right ?


Other than that, it looks good.

Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Pierre Gondois Nov. 8, 2022, 4:56 p.m. UTC | #2
On 11/8/22 17:13, Sudeep Holla wrote:
> On Tue, Nov 08, 2022 at 12:04:19PM +0100, Pierre Gondois wrote:
>> acpi_find_cache_levels() is used at a single place and is short
>> enough to be merged into the calling function. The removal allows
>> an easier renaming of the calling function in the next patch.
>>
>> Also reorder the parameters in the 'reversed Christmas tree' order.
> 
> Not sure if the above is worth mentioning explicitly. Even if you do,
> 'parameters' sounds very confusing to at-least me. I was searching for
> the changes is some function parameters to understand what it was and
> finally realised you meant the stack variable declaration order here.
> Right ?

Yes right, I will use another word.

> 
> 
> Other than that, it looks good.
> 
> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
> 

Regards,
Pierre
Jeremy Linton Nov. 10, 2022, 11:17 p.m. UTC | #3
On 11/8/22 05:04, Pierre Gondois wrote:
> acpi_find_cache_levels() is used at a single place and is short
> enough to be merged into the calling function. The removal allows
> an easier renaming of the calling function in the next patch.
> 
> Also reorder the parameters in the 'reversed Christmas tree' order.
> 
> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>

This bit looks fine too:

Reviewed-by: Jeremy Linton <jeremy.linton@arm.com>


> ---
>   drivers/acpi/pptt.c | 21 ++++++---------------
>   1 file changed, 6 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
> index c91342dcbcd6..97c1d33822d1 100644
> --- a/drivers/acpi/pptt.c
> +++ b/drivers/acpi/pptt.c
> @@ -281,19 +281,6 @@ static struct acpi_pptt_processor *acpi_find_processor_node(struct acpi_table_he
>   	return NULL;
>   }
>   
> -static int acpi_find_cache_levels(struct acpi_table_header *table_hdr,
> -				  u32 acpi_cpu_id)
> -{
> -	int number_of_levels = 0;
> -	struct acpi_pptt_processor *cpu;
> -
> -	cpu = acpi_find_processor_node(table_hdr, acpi_cpu_id);
> -	if (cpu)
> -		number_of_levels = acpi_count_levels(table_hdr, cpu);
> -
> -	return number_of_levels;
> -}
> -
>   static u8 acpi_cache_type(enum cache_type type)
>   {
>   	switch (type) {
> @@ -613,9 +600,10 @@ static int check_acpi_cpu_flag(unsigned int cpu, int rev, u32 flag)
>    */
>   int acpi_find_last_cache_level(unsigned int cpu)
>   {
> -	u32 acpi_cpu_id;
> +	struct acpi_pptt_processor *cpu_node;
>   	struct acpi_table_header *table;
>   	int number_of_levels = 0;
> +	u32 acpi_cpu_id;
>   
>   	table = acpi_get_pptt();
>   	if (!table)
> @@ -624,7 +612,10 @@ int acpi_find_last_cache_level(unsigned int cpu)
>   	pr_debug("Cache Setup find last level CPU=%d\n", cpu);
>   
>   	acpi_cpu_id = get_acpi_id_for_cpu(cpu);
> -	number_of_levels = acpi_find_cache_levels(table, acpi_cpu_id);
> +	cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
> +	if (cpu_node)
> +		number_of_levels = acpi_count_levels(table, cpu_node);
> +
>   	pr_debug("Cache Setup find last level level=%d\n", number_of_levels);
>   
>   	return number_of_levels;
diff mbox series

Patch

diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
index c91342dcbcd6..97c1d33822d1 100644
--- a/drivers/acpi/pptt.c
+++ b/drivers/acpi/pptt.c
@@ -281,19 +281,6 @@  static struct acpi_pptt_processor *acpi_find_processor_node(struct acpi_table_he
 	return NULL;
 }
 
-static int acpi_find_cache_levels(struct acpi_table_header *table_hdr,
-				  u32 acpi_cpu_id)
-{
-	int number_of_levels = 0;
-	struct acpi_pptt_processor *cpu;
-
-	cpu = acpi_find_processor_node(table_hdr, acpi_cpu_id);
-	if (cpu)
-		number_of_levels = acpi_count_levels(table_hdr, cpu);
-
-	return number_of_levels;
-}
-
 static u8 acpi_cache_type(enum cache_type type)
 {
 	switch (type) {
@@ -613,9 +600,10 @@  static int check_acpi_cpu_flag(unsigned int cpu, int rev, u32 flag)
  */
 int acpi_find_last_cache_level(unsigned int cpu)
 {
-	u32 acpi_cpu_id;
+	struct acpi_pptt_processor *cpu_node;
 	struct acpi_table_header *table;
 	int number_of_levels = 0;
+	u32 acpi_cpu_id;
 
 	table = acpi_get_pptt();
 	if (!table)
@@ -624,7 +612,10 @@  int acpi_find_last_cache_level(unsigned int cpu)
 	pr_debug("Cache Setup find last level CPU=%d\n", cpu);
 
 	acpi_cpu_id = get_acpi_id_for_cpu(cpu);
-	number_of_levels = acpi_find_cache_levels(table, acpi_cpu_id);
+	cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
+	if (cpu_node)
+		number_of_levels = acpi_count_levels(table, cpu_node);
+
 	pr_debug("Cache Setup find last level level=%d\n", number_of_levels);
 
 	return number_of_levels;