The patch titled Subject: bitops: more BITS_TO_* macros has been added to the -mm tree. Its filename is bitops-more-bits_to_-macros.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/bitops-more-bits_to_-macros.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/bitops-more-bits_to_-macros.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Yury Norov <yury.norov@xxxxxxxxx> Subject: bitops: more BITS_TO_* macros Introduce BITS_TO_U64, BITS_TO_U32 and BITS_TO_BYTES as they are handy in the following patches (BITS_TO_U32 specifically). Reimplement tools/ version of the macros according to the kernel implementation. Also fix indentation for BITS_PER_TYPE definition. Link: http://lkml.kernel.org/r/20190501010636.30595-3-ynorov@xxxxxxxxxxx Signed-off-by: Yury Norov <ynorov@xxxxxxxxxxx> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> Cc: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx> Cc: Amritha Nambiar <amritha.nambiar@xxxxxxxxx> Cc: Willem de Bruijn <willemb@xxxxxxxxxx> Cc: Kees Cook <keescook@xxxxxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: "Tobin C . Harding" <tobin@xxxxxxxxxx> Cc: Will Deacon <will.deacon@xxxxxxx> Cc: Steffen Klassert <steffen.klassert@xxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/bitops.h | 5 ++++- tools/include/linux/bitops.h | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) --- a/include/linux/bitops.h~bitops-more-bits_to_-macros +++ a/include/linux/bitops.h @@ -4,8 +4,11 @@ #include <asm/types.h> #include <linux/bits.h> -#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE) +#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE) #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(long)) +#define BITS_TO_U64(nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(u64)) +#define BITS_TO_U32(nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(u32)) +#define BITS_TO_BYTES(nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(char)) extern unsigned int __sw_hweight8(unsigned int w); extern unsigned int __sw_hweight16(unsigned int w); --- a/tools/include/linux/bitops.h~bitops-more-bits_to_-macros +++ a/tools/include/linux/bitops.h @@ -13,10 +13,11 @@ #include <linux/bits.h> #include <linux/compiler.h> -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) -#define BITS_TO_U64(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u64)) -#define BITS_TO_U32(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u32)) -#define BITS_TO_BYTES(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE) +#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE) +#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(long)) +#define BITS_TO_U64(nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(u64)) +#define BITS_TO_U32(nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(u32)) +#define BITS_TO_BYTES(nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(char)) extern unsigned int __sw_hweight8(unsigned int w); extern unsigned int __sw_hweight16(unsigned int w); _ Patches currently in -mm which might be from yury.norov@xxxxxxxxx are mm-slub-avoid-double-string-traverse-in-kmem_cache_flags.patch lib-string-add-strnchrnul.patch bitops-more-bits_to_-macros.patch lib-add-test-for-bitmap_parse.patch lib-make-bitmap_parse_user-a-wrapper-on-bitmap_parse.patch lib-rework-bitmap_parse.patch lib-new-testcases-for-bitmap_parse_user.patch cpumask-dont-calculate-length-of-the-input-string.patch