linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: cpufeatures: Clean up temporary variable to simplify code
@ 2024-02-29 10:52 Liao Chang
  2024-02-29 11:10 ` Mark Rutland
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Liao Chang @ 2024-02-29 10:52 UTC (permalink / raw)
  To: catalin.marinas, will, broonie, mark.rutland, maz, joey.gouly,
	kristina.martsenko, liaochang1, ryan.roberts, jeremy.linton
  Cc: linux-arm-kernel, linux-kernel

Clean up one temporary variable to simplifiy code in capability
detection.

Signed-off-by: Liao Chang <liaochang1@huawei.com>
---
 arch/arm64/kernel/cpufeature.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 8d1a634a403e..0e900b23f7ab 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -3052,13 +3052,9 @@ static void __init enable_cpu_capabilities(u16 scope_mask)
 	boot_scope = !!(scope_mask & SCOPE_BOOT_CPU);
 
 	for (i = 0; i < ARM64_NCAPS; i++) {
-		unsigned int num;
-
 		caps = cpucap_ptrs[i];
-		if (!caps || !(caps->type & scope_mask))
-			continue;
-		num = caps->capability;
-		if (!cpus_have_cap(num))
+		if (!caps || !(caps->type & scope_mask) ||
+		    !cpus_have_cap(caps->capability))
 			continue;
 
 		if (boot_scope && caps->cpu_enable)
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] arm64: cpufeatures: Clean up temporary variable to simplify code
  2024-02-29 10:52 [PATCH] arm64: cpufeatures: Clean up temporary variable to simplify code Liao Chang
@ 2024-02-29 11:10 ` Mark Rutland
  2024-03-01 18:29 ` Catalin Marinas
  2024-03-01 19:46 ` Jeremy Linton
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Rutland @ 2024-02-29 11:10 UTC (permalink / raw)
  To: Liao Chang
  Cc: catalin.marinas, will, broonie, maz, joey.gouly,
	kristina.martsenko, ryan.roberts, jeremy.linton, linux-arm-kernel,
	linux-kernel

On Thu, Feb 29, 2024 at 10:52:08AM +0000, Liao Chang wrote:
> Clean up one temporary variable to simplifiy code in capability
> detection.
> 
> Signed-off-by: Liao Chang <liaochang1@huawei.com>

This looks line a nice cleanup, so:

Acked-by: Mark Rutland <mark.rutland@arm.com>

For context, we removed the last other user of 'num' in commit:

  21fb26bfb01ffe0d ("arm64: alternatives: add alternative_has_feature_*()")

Mark.

> ---
>  arch/arm64/kernel/cpufeature.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> index 8d1a634a403e..0e900b23f7ab 100644
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@ -3052,13 +3052,9 @@ static void __init enable_cpu_capabilities(u16 scope_mask)
>  	boot_scope = !!(scope_mask & SCOPE_BOOT_CPU);
>  
>  	for (i = 0; i < ARM64_NCAPS; i++) {
> -		unsigned int num;
> -
>  		caps = cpucap_ptrs[i];
> -		if (!caps || !(caps->type & scope_mask))
> -			continue;
> -		num = caps->capability;
> -		if (!cpus_have_cap(num))
> +		if (!caps || !(caps->type & scope_mask) ||
> +		    !cpus_have_cap(caps->capability))
>  			continue;
>  
>  		if (boot_scope && caps->cpu_enable)
> -- 
> 2.34.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] arm64: cpufeatures: Clean up temporary variable to simplify code
  2024-02-29 10:52 [PATCH] arm64: cpufeatures: Clean up temporary variable to simplify code Liao Chang
  2024-02-29 11:10 ` Mark Rutland
@ 2024-03-01 18:29 ` Catalin Marinas
  2024-03-01 19:46 ` Jeremy Linton
  2 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2024-03-01 18:29 UTC (permalink / raw)
  To: will, broonie, mark.rutland, maz, joey.gouly, kristina.martsenko,
	ryan.roberts, jeremy.linton, Liao Chang
  Cc: linux-arm-kernel, linux-kernel

On Thu, 29 Feb 2024 10:52:08 +0000, Liao Chang wrote:
> Clean up one temporary variable to simplifiy code in capability
> detection.
> 
> 

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

[1/1] arm64: cpufeatures: Clean up temporary variable to simplify code
      https://git.kernel.org/arm64/c/622442666dcc

-- 
Catalin


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] arm64: cpufeatures: Clean up temporary variable to simplify code
  2024-02-29 10:52 [PATCH] arm64: cpufeatures: Clean up temporary variable to simplify code Liao Chang
  2024-02-29 11:10 ` Mark Rutland
  2024-03-01 18:29 ` Catalin Marinas
@ 2024-03-01 19:46 ` Jeremy Linton
  2 siblings, 0 replies; 4+ messages in thread
From: Jeremy Linton @ 2024-03-01 19:46 UTC (permalink / raw)
  To: Liao Chang, catalin.marinas, will, broonie, mark.rutland, maz,
	joey.gouly, kristina.martsenko, ryan.roberts
  Cc: linux-arm-kernel, linux-kernel

Hi,

On 2/29/24 04:52, Liao Chang wrote:
> Clean up one temporary variable to simplifiy code in capability
> detection.
> 
> Signed-off-by: Liao Chang <liaochang1@huawei.com>
> ---
>   arch/arm64/kernel/cpufeature.c | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> index 8d1a634a403e..0e900b23f7ab 100644
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@ -3052,13 +3052,9 @@ static void __init enable_cpu_capabilities(u16 scope_mask)
>   	boot_scope = !!(scope_mask & SCOPE_BOOT_CPU);
>   
>   	for (i = 0; i < ARM64_NCAPS; i++) {
> -		unsigned int num;
> -
>   		caps = cpucap_ptrs[i];
> -		if (!caps || !(caps->type & scope_mask))
> -			continue;
> -		num = caps->capability;
> -		if (!cpus_have_cap(num))
> +		if (!caps || !(caps->type & scope_mask) ||
> +		    !cpus_have_cap(caps->capability))
>   			continue;
>   
>   		if (boot_scope && caps->cpu_enable)

Looks functionality equivalent to me, and just to see if it makes a 
binary difference I compiled both variations (gcc 14.0.1) and they do 
result in the same instruction sequence. Meaning gcc is smart enough to 
drop the tmp, its also smart enough equate/apply de Morgan's law. The 
latter might make it more readable too, but I guess its all a matter of 
taste.


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



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2024-03-01 19:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-29 10:52 [PATCH] arm64: cpufeatures: Clean up temporary variable to simplify code Liao Chang
2024-02-29 11:10 ` Mark Rutland
2024-03-01 18:29 ` Catalin Marinas
2024-03-01 19:46 ` Jeremy Linton

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