From 016e6d6a4f9b2b29d9b7f65cbb44874182e277b8 Mon Sep 17 00:00:00 2001 From: Vignesh Raghavendra Date: Mon, 9 Dec 2019 10:25:31 +0530 Subject: lib: Import few bitmap functions from Linux Import few basic bitmap functions (bitmap_{weight,fill,set,clear,or}()) and their dependencies from Linux. These are required for upcoming DMA resource allocation support for TI's K3 SoCs. Signed-off-by: Vignesh Raghavendra Reviewed-by: Grygorii Strashko Signed-off-by: Lokesh Vutla --- include/linux/bitops.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/linux/bitops.h') diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 259df43fb00..a07c70fd485 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -4,6 +4,7 @@ #include #include #include +#include #ifdef __KERNEL__ #define BIT(nr) (1UL << (nr)) @@ -133,6 +134,17 @@ static inline unsigned int generic_hweight8(unsigned int w) return (res & 0x0F) + ((res >> 4) & 0x0F); } +static inline unsigned long generic_hweight64(__u64 w) +{ + return generic_hweight32((unsigned int)(w >> 32)) + + generic_hweight32((unsigned int)w); +} + +static inline unsigned long hweight_long(unsigned long w) +{ + return sizeof(w) == 4 ? generic_hweight32(w) : generic_hweight64(w); +} + #include /* linux/include/asm-generic/bitops/non-atomic.h */ -- cgit v1.2.3