diff options
| author | Tony Lindgren <tony@atomide.com> | 2018-08-28 12:58:03 -0400 |
|---|---|---|
| committer | Tony Lindgren <tony@atomide.com> | 2018-08-28 12:58:03 -0400 |
| commit | ea4d65f14f6aaa53e379b93c5544245ef081b3e7 (patch) | |
| tree | a15485f4f1cf547a52b31fa8e16e14b9579b7200 /include/linux/bits.h | |
| parent | ce32d59ee2cd036f6e8a6ed17a06a0b0bec5c67c (diff) | |
| parent | 496f3347d834aec91c38b45d6249ed00f58ad233 (diff) | |
Merge branch 'perm-fix' into omap-for-v4.19/fixes-v2
Diffstat (limited to 'include/linux/bits.h')
| -rw-r--r-- | include/linux/bits.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/linux/bits.h b/include/linux/bits.h new file mode 100644 index 000000000000..2b7b532c1d51 --- /dev/null +++ b/include/linux/bits.h | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | #ifndef __LINUX_BITS_H | ||
| 3 | #define __LINUX_BITS_H | ||
| 4 | #include <asm/bitsperlong.h> | ||
| 5 | |||
| 6 | #define BIT(nr) (1UL << (nr)) | ||
| 7 | #define BIT_ULL(nr) (1ULL << (nr)) | ||
| 8 | #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) | ||
| 9 | #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) | ||
| 10 | #define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) | ||
| 11 | #define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG) | ||
| 12 | #define BITS_PER_BYTE 8 | ||
| 13 | |||
| 14 | /* | ||
| 15 | * Create a contiguous bitmask starting at bit position @l and ending at | ||
| 16 | * position @h. For example | ||
| 17 | * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. | ||
| 18 | */ | ||
| 19 | #define GENMASK(h, l) \ | ||
| 20 | (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) | ||
| 21 | |||
| 22 | #define GENMASK_ULL(h, l) \ | ||
| 23 | (((~0ULL) - (1ULL << (l)) + 1) & \ | ||
| 24 | (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) | ||
| 25 | |||
| 26 | #endif /* __LINUX_BITS_H */ | ||
