[PATCH v2 4/9] arm64/sysreg: Provide a helper macro for defining sysreg bitmasks

Mark Brown broonie at kernel.org
Wed Mar 16 10:08:44 PDT 2022


To ease the generation of headers for the bitfields in the system registers
provide a macro for defining bitfields based on the top and bottom bit.

Ideally this should be provided along with the generic BIT() macros however
there are a bunch of existing places with such macros including some that
actually call their macro BITMASK() so rather than create a dependency on
a wider cleanup let's define something local for now, this can be improved
later. This also sidesteps the need to consider types other than u64.

Signed-off-by: Mark Brown <broonie at kernel.org>
---
 arch/arm64/include/asm/sysreg.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h
index abb1e0502e28..fa2ae02de465 100644
--- a/arch/arm64/include/asm/sysreg.h
+++ b/arch/arm64/include/asm/sysreg.h
@@ -15,6 +15,8 @@
 
 #include <asm/gpr-num.h>
 
+#define ARM64_SYSREG_BITMASK(h, l) ((BIT(ULL(h)) - BIT(ULL(l))) | BIT(ULL(h)))
+
 /*
  * ARMv8 ARM reserves the following encoding for system registers:
  * (Ref: ARMv8 ARM, Section: "System instruction class encoding overview",
-- 
2.30.2




More information about the linux-arm-kernel mailing list