diff options
author | Keerthy | 2022-01-27 13:16:54 +0100 |
---|---|---|
committer | Tom Rini | 2022-02-08 11:00:03 -0500 |
commit | 8a92603a3489f789f8e3a36a1e073bc1c237d73e (patch) | |
tree | a3ee21606895a74751830c899f79374ec71e39f9 /include | |
parent | b071a07743d44e58046ee5f52df9b6fab7733654 (diff) |
linux: bitmap.h: Add find_next_zero_area function
Add find_next_zero_area to fetch the next zero area in the map.
Signed-off-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Amjad Ouled-Ameur <aouledameur@baylibre.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/bitmap.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index dae4225be54..0a8503af9f1 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -159,6 +159,32 @@ static inline unsigned long find_first_bit(const unsigned long *addr, unsigned l (bit) < (size); \ (bit) = find_next_bit((addr), (size), (bit) + 1)) +static inline unsigned long +bitmap_find_next_zero_area(unsigned long *map, + unsigned long size, + unsigned long start, + unsigned int nr, unsigned long align_mask) +{ + unsigned long index, end, i; +again: + index = find_next_zero_bit(map, size, start); + + /* + * Align allocation + */ + index = (index + align_mask) & ~align_mask; + + end = index + nr; + if (end > size) + return end; + i = find_next_bit(map, end, index); + if (i < end) { + start = i + 1; + goto again; + } + return index; +} + static inline void bitmap_fill(unsigned long *dst, unsigned int nbits) { if (small_const_nbits(nbits)) { |