summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZong Li <[email protected]>2024-08-30 11:16:10 +0800
committerAnup Patel <[email protected]>2024-09-23 18:33:02 +0530
commit570b9ae89a23ac80a21cd2240b0dd667246a2d4d (patch)
tree14a934f6ce881f716a2ff0f19f0723428a9fa600
parent040fcf49ab9d428018eb3e04640df123594d2165 (diff)
include: sbi_bitops: add ULL version for BIT and GENMASK
Add BIT_ULL and GENMASK_ULL for dealing with 64-bits data on 32-bits CPU, then we don't need to separate the operation to low part and high part. For instance, the MMIO register is 64 bits wide. Signed-off-by: Zong Li <[email protected]> Reviewed-by: Anup Patel <[email protected]>
-rw-r--r--include/sbi/sbi_bitops.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/sbi/sbi_bitops.h b/include/sbi/sbi_bitops.h
index 7d90334d..3ddac777 100644
--- a/include/sbi/sbi_bitops.h
+++ b/include/sbi/sbi_bitops.h
@@ -14,6 +14,8 @@
#define BITS_PER_LONG (8 * __SIZEOF_LONG__)
+#define BITS_PER_LONG_LONG 64
+
#define EXTRACT_FIELD(val, which) \
(((val) & (which)) / ((which) & ~((which)-1)))
#define INSERT_FIELD(val, which, fieldval) \
@@ -28,9 +30,13 @@
#define BIT_WORD_OFFSET(bit) ((bit) & (BITS_PER_LONG - 1))
#define BIT_ALIGN(bit, align) (((bit) + ((align) - 1)) & ~((align) - 1))
+#define BIT_ULL(nr) (1ULL << (nr))
+
#define GENMASK(h, l) \
(((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+#define GENMASK_ULL(h, l) \
+ (((~0ULL) - (1ULL << (l)) + 1) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
/**
* sbi_ffs - find first (less-significant) set bit in a long word.
* @word: The word to search