From 673452876fe988048764e3c9fc1c42b9f51d3255 Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Wed, 21 Oct 2015 17:30:34 +0530 Subject: linux/bitops: Move BIT definitions at top Since it's a copy from Linux, this patch moved all BIT definitions to top so-that it looks same as Linux file. Cc: Tom Rini Cc: Albert ARIBAUD Signed-off-by: Jagan Teki --- include/linux/bitops.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'include/linux') diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 7d30ace..e9bb827 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -3,7 +3,9 @@ #include -#define BIT(nr) (1UL << (nr)) +#define BIT(nr) (1UL << (nr)) +#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) +#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) /* * ffs: find first bit set. This is defined the same way as @@ -106,9 +108,6 @@ static inline unsigned int generic_hweight8(unsigned int w) return (res & 0x0F) + ((res >> 4) & 0x0F); } -#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) -#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) - #include /* linux/include/asm-generic/bitops/non-atomic.h */ -- cgit v1.1 From 89b5c81b75658b7ff66dea6c38a51dfecc9dd508 Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Wed, 21 Oct 2015 16:46:51 +0530 Subject: linux/bitops.h: GENMASK copy from linux GENMASK is used to create a contiguous bitmask([hi:lo]). This patch is a copy from Linux, with below commit details "bitops: Fix shift overflow in GENMASK macros" (sha1: 00b4d9a14125f1e51874def2b9de6092e007412d) Cc: Tom Rini Cc: Masahiro Yamada Signed-off-by: Jagan Teki --- include/linux/bitops.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include/linux') diff --git a/include/linux/bitops.h b/include/linux/bitops.h index e9bb827..7b4011f 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -8,6 +8,17 @@ #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)))) + +/* * ffs: find first bit set. This is defined the same way as * the libc and compiler builtin ffs routines, therefore * differs in spirit from the above ffz (man ffs). -- cgit v1.1