summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYury Norov <ynorov@nvidia.com>2026-07-08 22:03:11 -0400
committerYury Norov <ynorov@nvidia.com>2026-07-22 15:38:38 -0400
commitbf7e3686b708683efe6b7ee79ae4c83a875dbc6f (patch)
tree3109fa4d1b1175d76a4846c6fa3295917f8eff98 /lib
parente46185c13953500ed868751b944a96974eaca923 (diff)
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 <ynorov@nvidia.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/bitmap.c10
1 files changed, 4 insertions, 6 deletions
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);