diff options
author | Chen, Gong <gong.chen@linux.intel.com> | 2013-10-18 17:29:07 -0400 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2013-10-21 18:12:01 -0400 |
commit | 10ef6b0dffe404bcc54e94cb2ca1a5b18445a66b (patch) | |
tree | 6450859ffdc4494f2211442dd411b7f189cf326d /include/linux/bitops.h | |
parent | 88f074f4871a8c212b212b725e4dcdcdb09613c1 (diff) |
bitops: Introduce a more generic BITMASK macro
GENMASK is used to create a contiguous bitmask([hi:lo]). It is
implemented twice in current kernel. One is in EDAC driver, the other
is in SiS/XGI FB driver. Move it to a more generic place for other
usage.
Signed-off-by: Chen, Gong <gong.chen@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Thomas Winischhofer <thomas@winischhofer.net>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Acked-by: Borislav Petkov <bp@suse.de>
Acked-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'include/linux/bitops.h')
-rw-r--r-- | include/linux/bitops.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index a3b6b82108b9..bd0c4598d03b 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h | |||
@@ -10,6 +10,14 @@ | |||
10 | #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) | 10 | #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) |
11 | #endif | 11 | #endif |
12 | 12 | ||
13 | /* | ||
14 | * Create a contiguous bitmask starting at bit position @l and ending at | ||
15 | * position @h. For example | ||
16 | * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. | ||
17 | */ | ||
18 | #define GENMASK(h, l) (((U32_C(1) << ((h) - (l) + 1)) - 1) << (l)) | ||
19 | #define GENMASK_ULL(h, l) (((U64_C(1) << ((h) - (l) + 1)) - 1) << (l)) | ||
20 | |||
13 | extern unsigned int __sw_hweight8(unsigned int w); | 21 | extern unsigned int __sw_hweight8(unsigned int w); |
14 | extern unsigned int __sw_hweight16(unsigned int w); | 22 | extern unsigned int __sw_hweight16(unsigned int w); |
15 | extern unsigned int __sw_hweight32(unsigned int w); | 23 | extern unsigned int __sw_hweight32(unsigned int w); |