From 6ec12414164e9d66966909e6da08453be5b6c4cc Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Fri, 19 Jun 2026 13:34:41 +0200 Subject: bitmap: Replace __ASSEMBLY__ with __ASSEMBLER__ in header files While the GCC and Clang compilers already define __ASSEMBLER__ automatically when compiling assembly code, __ASSEMBLY__ is a macro that only gets defined by the Makefiles in the kernel. This can be very confusing when switching between userspace and kernelspace coding, or when dealing with uapi headers that rather should use __ASSEMBLER__ instead. So let's standardize now on the __ASSEMBLER__ macro that is provided by the compilers. This is a completely mechanical patch (done with a simple "sed -i" statement). Signed-off-by: Thomas Huth Signed-off-by: Yury Norov --- include/linux/bitmap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/linux/bitmap.h') diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index b007d54a9036..8854acf77869 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -2,7 +2,7 @@ #ifndef __LINUX_BITMAP_H #define __LINUX_BITMAP_H -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__ #include #include @@ -894,6 +894,6 @@ void bitmap_write(unsigned long *map, unsigned long value, #define bitmap_set_value8(map, value, start) \ bitmap_write(map, value, start, BITS_PER_BYTE) -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ #endif /* __LINUX_BITMAP_H */ -- cgit v1.2.3 From ae44a037ac03d7f8bc8a17da02163c7f5c63bf50 Mon Sep 17 00:00:00 2001 From: Yury Norov Date: Sun, 19 Jul 2026 08:27:27 -0400 Subject: bitmap: drop bitmap_next_set_region() The function is a dead code. Drop it. Signed-off-by: Yury Norov --- include/linux/bitmap.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'include/linux/bitmap.h') diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 8854acf77869..a967e1f7542b 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -697,14 +697,6 @@ void bitmap_gather(unsigned long *dst, const unsigned long *src, __assign_bit(n++, dst, test_bit(bit, src)); } -static __always_inline -void bitmap_next_set_region(unsigned long *bitmap, unsigned int *rs, - unsigned int *re, unsigned int end) -{ - *rs = find_next_bit(bitmap, end, *rs); - *re = find_next_zero_bit(bitmap, end, *rs + 1); -} - /** * bitmap_release_region - release allocated bitmap region * @bitmap: array of unsigned longs corresponding to the bitmap -- cgit v1.2.3 From bf7e3686b708683efe6b7ee79ae4c83a875dbc6f Mon Sep 17 00:00:00 2001 From: Yury Norov Date: Wed, 8 Jul 2026 22:03:11 -0400 Subject: bitmap: Return size when no zero area is found Return the bitmap size, rather than size + 1, when bitmap_find_next_zero_area_off() cannot find a suitable area. This matches the conventional find_bit() failure sentinel and still lets callers detect failure with an out-of-range check. Document the public failure contract as a value greater than or equal to the bitmap size, without requiring callers to depend on the exact sentinel. Signed-off-by: Yury Norov --- include/linux/bitmap.h | 3 +++ lib/bitmap.c | 10 ++++------ 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'include/linux/bitmap.h') diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index a967e1f7542b..7df1573a409c 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -209,6 +209,9 @@ unsigned long bitmap_find_next_zero_area_off(unsigned long *map, * The @align_mask should be one less than a power of 2; the effect is that * the bit offset of all zero areas this function finds is multiples of that * power of 2. A @align_mask of 0 means no alignment is required. + * + * Return: The bit offset of the found area or a value >= @size + * if no area is found. */ static __always_inline unsigned long bitmap_find_next_zero_area(unsigned long *map, diff --git a/lib/bitmap.c b/lib/bitmap.c index b464d843f4eb..ed685127a107 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -424,6 +424,9 @@ EXPORT_SYMBOL(__bitmap_clear); * The @align_mask should be one less than a power of 2; the effect is that * the bit offset of all zero areas this function finds plus @align_offset * is multiple of that power of 2. + * + * Return: The bit offset of the found area or a value greater than or equal + * to @size if no area is found. */ unsigned long bitmap_find_next_zero_area_off(unsigned long *map, unsigned long size, @@ -448,12 +451,7 @@ unsigned long bitmap_find_next_zero_area_off(unsigned long *map, start = i; } - /* - * Here, returning size + 1 is to maintain consistency - * with the old version, where the return value is always - * greater than size when no zero areas are found. - */ - return size + 1; + return size; } EXPORT_SYMBOL(bitmap_find_next_zero_area_off); -- cgit v1.2.3