
GENMASK is used to create a contiguous bitmask([hi:lo]).
Signed-off-by: Jagan Teki jteki@openedev.com Cc: Tom Rini trini@konsulko.com Cc: Simon Glass sjg@chromium.org Cc: Masahiro Yamada yamada.m@jp.panasonic.com --- include/linux/bitops.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index c098c9a..08db119 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -108,6 +108,17 @@ static inline unsigned int generic_hweight8(unsigned int w) #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) #define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
+/* + * Create a contiguous bitmask starting at bit position @l and ending at + * position @h. For example + * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. + */ +#define GENMASK(h, l) \ + (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) + +#define GENMASK_ULL(h, l) \ + (((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) + #include <asm/bitops.h>
/* linux/include/asm-generic/bitops/non-atomic.h */