diff options
-rw-r--r-- | include/linux/bitmap.h | 23 | ||||
-rw-r--r-- | lib/bitmap.c | 8 | ||||
-rw-r--r-- | lib/test_bitmap.c | 3 |
3 files changed, 24 insertions, 10 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 3b77588a9360..4e0f0c8167af 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h | |||
@@ -112,9 +112,8 @@ extern int __bitmap_intersects(const unsigned long *bitmap1, | |||
112 | extern int __bitmap_subset(const unsigned long *bitmap1, | 112 | extern int __bitmap_subset(const unsigned long *bitmap1, |
113 | const unsigned long *bitmap2, unsigned int nbits); | 113 | const unsigned long *bitmap2, unsigned int nbits); |
114 | extern int __bitmap_weight(const unsigned long *bitmap, unsigned int nbits); | 114 | extern int __bitmap_weight(const unsigned long *bitmap, unsigned int nbits); |
115 | 115 | extern void __bitmap_set(unsigned long *map, unsigned int start, int len); | |
116 | extern void bitmap_set(unsigned long *map, unsigned int start, int len); | 116 | extern void __bitmap_clear(unsigned long *map, unsigned int start, int len); |
117 | extern void bitmap_clear(unsigned long *map, unsigned int start, int len); | ||
118 | 117 | ||
119 | extern unsigned long bitmap_find_next_zero_area_off(unsigned long *map, | 118 | extern unsigned long bitmap_find_next_zero_area_off(unsigned long *map, |
120 | unsigned long size, | 119 | unsigned long size, |
@@ -315,6 +314,24 @@ static __always_inline int bitmap_weight(const unsigned long *src, unsigned int | |||
315 | return __bitmap_weight(src, nbits); | 314 | return __bitmap_weight(src, nbits); |
316 | } | 315 | } |
317 | 316 | ||
317 | static __always_inline void bitmap_set(unsigned long *map, unsigned int start, | ||
318 | unsigned int nbits) | ||
319 | { | ||
320 | if (__builtin_constant_p(nbits) && nbits == 1) | ||
321 | __set_bit(start, map); | ||
322 | else | ||
323 | __bitmap_set(map, start, nbits); | ||
324 | } | ||
325 | |||
326 | static __always_inline void bitmap_clear(unsigned long *map, unsigned int start, | ||
327 | unsigned int nbits) | ||
328 | { | ||
329 | if (__builtin_constant_p(nbits) && nbits == 1) | ||
330 | __clear_bit(start, map); | ||
331 | else | ||
332 | __bitmap_clear(map, start, nbits); | ||
333 | } | ||
334 | |||
318 | static inline void bitmap_shift_right(unsigned long *dst, const unsigned long *src, | 335 | static inline void bitmap_shift_right(unsigned long *dst, const unsigned long *src, |
319 | unsigned int shift, int nbits) | 336 | unsigned int shift, int nbits) |
320 | { | 337 | { |
diff --git a/lib/bitmap.c b/lib/bitmap.c index 08c6ef3a2b6f..9a532805364b 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
@@ -251,7 +251,7 @@ int __bitmap_weight(const unsigned long *bitmap, unsigned int bits) | |||
251 | } | 251 | } |
252 | EXPORT_SYMBOL(__bitmap_weight); | 252 | EXPORT_SYMBOL(__bitmap_weight); |
253 | 253 | ||
254 | void bitmap_set(unsigned long *map, unsigned int start, int len) | 254 | void __bitmap_set(unsigned long *map, unsigned int start, int len) |
255 | { | 255 | { |
256 | unsigned long *p = map + BIT_WORD(start); | 256 | unsigned long *p = map + BIT_WORD(start); |
257 | const unsigned int size = start + len; | 257 | const unsigned int size = start + len; |
@@ -270,9 +270,9 @@ void bitmap_set(unsigned long *map, unsigned int start, int len) | |||
270 | *p |= mask_to_set; | 270 | *p |= mask_to_set; |
271 | } | 271 | } |
272 | } | 272 | } |
273 | EXPORT_SYMBOL(bitmap_set); | 273 | EXPORT_SYMBOL(__bitmap_set); |
274 | 274 | ||
275 | void bitmap_clear(unsigned long *map, unsigned int start, int len) | 275 | void __bitmap_clear(unsigned long *map, unsigned int start, int len) |
276 | { | 276 | { |
277 | unsigned long *p = map + BIT_WORD(start); | 277 | unsigned long *p = map + BIT_WORD(start); |
278 | const unsigned int size = start + len; | 278 | const unsigned int size = start + len; |
@@ -291,7 +291,7 @@ void bitmap_clear(unsigned long *map, unsigned int start, int len) | |||
291 | *p &= ~mask_to_clear; | 291 | *p &= ~mask_to_clear; |
292 | } | 292 | } |
293 | } | 293 | } |
294 | EXPORT_SYMBOL(bitmap_clear); | 294 | EXPORT_SYMBOL(__bitmap_clear); |
295 | 295 | ||
296 | /** | 296 | /** |
297 | * bitmap_find_next_zero_area_off - find a contiguous aligned zero area | 297 | * bitmap_find_next_zero_area_off - find a contiguous aligned zero area |
diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c index 252d3bddbe7d..2526a2975c51 100644 --- a/lib/test_bitmap.c +++ b/lib/test_bitmap.c | |||
@@ -333,9 +333,6 @@ static void __init test_bitmap_u32_array_conversions(void) | |||
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | #define __bitmap_set(a, b, c) bitmap_set(a, b, c) | ||
337 | #define __bitmap_clear(a, b, c) bitmap_clear(a, b, c) | ||
338 | |||
339 | static void noinline __init test_mem_optimisations(void) | 336 | static void noinline __init test_mem_optimisations(void) |
340 | { | 337 | { |
341 | DECLARE_BITMAP(bmap1, 1024); | 338 | DECLARE_BITMAP(bmap1, 1024); |