mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-09 03:21:51 +00:00
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>
This commit is contained in:
parent
b071a07743
commit
8a92603a34
1 changed files with 26 additions and 0 deletions
|
@ -159,6 +159,32 @@ static inline unsigned long find_first_bit(const unsigned long *addr, unsigned l
|
||||||
(bit) < (size); \
|
(bit) < (size); \
|
||||||
(bit) = find_next_bit((addr), (size), (bit) + 1))
|
(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)
|
static inline void bitmap_fill(unsigned long *dst, unsigned int nbits)
|
||||||
{
|
{
|
||||||
if (small_const_nbits(nbits)) {
|
if (small_const_nbits(nbits)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue