mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-26 14:17:26 -04:00
bitmap: unify find_bit operations
bitmap_for_each_{set,clear}_region() are similar to for_each_bit() macros in include/linux/find.h, but interface and implementation of them are different. This patch adds for_each_bitrange() macros and drops unused bitmap_*_region() API in sake of unification. Signed-off-by: Yury Norov <yury.norov@gmail.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Acked-by: Dennis Zhou <dennis@kernel.org> Acked-by: Ulf Hansson <ulf.hansson@linaro.org> # For MMC
This commit is contained in:
parent
801a57365f
commit
ec288a2cf7
4 changed files with 65 additions and 46 deletions
|
@ -55,12 +55,6 @@ struct device;
|
|||
* bitmap_clear(dst, pos, nbits) Clear specified bit area
|
||||
* bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area
|
||||
* bitmap_find_next_zero_area_off(buf, len, pos, n, mask, mask_off) as above
|
||||
* bitmap_next_clear_region(map, &start, &end, nbits) Find next clear region
|
||||
* bitmap_next_set_region(map, &start, &end, nbits) Find next set region
|
||||
* bitmap_for_each_clear_region(map, rs, re, start, end)
|
||||
* Iterate over all clear regions
|
||||
* bitmap_for_each_set_region(map, rs, re, start, end)
|
||||
* Iterate over all set regions
|
||||
* bitmap_shift_right(dst, src, n, nbits) *dst = *src >> n
|
||||
* bitmap_shift_left(dst, src, n, nbits) *dst = *src << n
|
||||
* bitmap_cut(dst, src, first, n, nbits) Cut n bits from first, copy rest
|
||||
|
@ -467,14 +461,6 @@ static inline void bitmap_replace(unsigned long *dst,
|
|||
__bitmap_replace(dst, old, new, mask, nbits);
|
||||
}
|
||||
|
||||
static inline void bitmap_next_clear_region(unsigned long *bitmap,
|
||||
unsigned int *rs, unsigned int *re,
|
||||
unsigned int end)
|
||||
{
|
||||
*rs = find_next_zero_bit(bitmap, end, *rs);
|
||||
*re = find_next_bit(bitmap, end, *rs + 1);
|
||||
}
|
||||
|
||||
static inline void bitmap_next_set_region(unsigned long *bitmap,
|
||||
unsigned int *rs, unsigned int *re,
|
||||
unsigned int end)
|
||||
|
@ -483,25 +469,6 @@ static inline void bitmap_next_set_region(unsigned long *bitmap,
|
|||
*re = find_next_zero_bit(bitmap, end, *rs + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Bitmap region iterators. Iterates over the bitmap between [@start, @end).
|
||||
* @rs and @re should be integer variables and will be set to start and end
|
||||
* index of the current clear or set region.
|
||||
*/
|
||||
#define bitmap_for_each_clear_region(bitmap, rs, re, start, end) \
|
||||
for ((rs) = (start), \
|
||||
bitmap_next_clear_region((bitmap), &(rs), &(re), (end)); \
|
||||
(rs) < (re); \
|
||||
(rs) = (re) + 1, \
|
||||
bitmap_next_clear_region((bitmap), &(rs), &(re), (end)))
|
||||
|
||||
#define bitmap_for_each_set_region(bitmap, rs, re, start, end) \
|
||||
for ((rs) = (start), \
|
||||
bitmap_next_set_region((bitmap), &(rs), &(re), (end)); \
|
||||
(rs) < (re); \
|
||||
(rs) = (re) + 1, \
|
||||
bitmap_next_set_region((bitmap), &(rs), &(re), (end)))
|
||||
|
||||
/**
|
||||
* BITMAP_FROM_U64() - Represent u64 value in the format suitable for bitmap.
|
||||
* @n: u64 value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue