[PATCH] arm64: cpufeature: Use defined macro instead of magic numbers

Subsystems: arm64 port (aarch64 architecture), the rest

STALE1847d

3 messages, 2 authors, 2021-07-16 · open the first message on its own page

[PATCH] arm64: cpufeature: Use defined macro instead of magic numbers

From: Shaokun Zhang <hidden>
Date: 2021-07-14 06:16:27

Macro 'CLIDR_LOUU_SHIFT' and 'CLIDR_LOUIS_SHIFT' are defined, so use
these to replace the magic numbers.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>
Signed-off-by: Shaokun Zhang <redacted>
---
 arch/arm64/kernel/cpufeature.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 125d5c9471ac..4ee3496bcff8 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1733,7 +1733,7 @@ static void cpu_has_fwb(const struct arm64_cpu_capabilities *__unused)
 	u64 val = read_sysreg_s(SYS_CLIDR_EL1);
 
 	/* Check that CLIDR_EL1.LOU{U,IS} are both 0 */
-	WARN_ON(val & (7 << 27 | 7 << 21));
+	WARN_ON(val & (7 << CLIDR_LOUU_SHIFT | 7 << CLIDR_LOUIS_SHIFT));
 }
 
 #ifdef CONFIG_ARM64_PAN
-- 
2.7.4


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

Re: [PATCH] arm64: cpufeature: Use defined macro instead of magic numbers

From: Will Deacon <will@kernel.org>
Date: 2021-07-15 16:33:20

On Wed, Jul 14, 2021 at 02:13:03PM +0800, Shaokun Zhang wrote:
quoted hunk
Macro 'CLIDR_LOUU_SHIFT' and 'CLIDR_LOUIS_SHIFT' are defined, so use
these to replace the magic numbers.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>
Signed-off-by: Shaokun Zhang <redacted>
---
 arch/arm64/kernel/cpufeature.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 125d5c9471ac..4ee3496bcff8 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1733,7 +1733,7 @@ static void cpu_has_fwb(const struct arm64_cpu_capabilities *__unused)
 	u64 val = read_sysreg_s(SYS_CLIDR_EL1);
 
 	/* Check that CLIDR_EL1.LOU{U,IS} are both 0 */
-	WARN_ON(val & (7 << 27 | 7 << 21));
+	WARN_ON(val & (7 << CLIDR_LOUU_SHIFT | 7 << CLIDR_LOUIS_SHIFT));
 }
I think this would be even better as:

	WARN_ON(CLIDR_LOUU(val) || CLIDR_LOUIS(val));

Will

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

Re: [PATCH] arm64: cpufeature: Use defined macro instead of magic numbers

From: Shaokun Zhang <hidden>
Date: 2021-07-16 01:11:56

Hi Will,

On 2021/7/16 0:31, Will Deacon wrote:
On Wed, Jul 14, 2021 at 02:13:03PM +0800, Shaokun Zhang wrote:
quoted
Macro 'CLIDR_LOUU_SHIFT' and 'CLIDR_LOUIS_SHIFT' are defined, so use
these to replace the magic numbers.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>
Signed-off-by: Shaokun Zhang <redacted>
---
 arch/arm64/kernel/cpufeature.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 125d5c9471ac..4ee3496bcff8 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1733,7 +1733,7 @@ static void cpu_has_fwb(const struct arm64_cpu_capabilities *__unused)
 	u64 val = read_sysreg_s(SYS_CLIDR_EL1);
 
 	/* Check that CLIDR_EL1.LOU{U,IS} are both 0 */
-	WARN_ON(val & (7 << 27 | 7 << 21));
+	WARN_ON(val & (7 << CLIDR_LOUU_SHIFT | 7 << CLIDR_LOUIS_SHIFT));
 }
I think this would be even better as:

	WARN_ON(CLIDR_LOUU(val) || CLIDR_LOUIS(val));
Good catch, will follow it in next version.

Thanks,
Shaokun
Will
.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help