diff options
Diffstat (limited to 'include/linux/bitmap.h')
-rw-r--r-- | include/linux/bitmap.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index e43533ec7660..d9bf699e0e7a 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h | |||
@@ -67,6 +67,11 @@ | |||
67 | * bitmap_from_arr32(dst, buf, nbits) Copy nbits from u32[] buf to dst | 67 | * bitmap_from_arr32(dst, buf, nbits) Copy nbits from u32[] buf to dst |
68 | * bitmap_to_arr32(buf, src, nbits) Copy nbits from buf to u32[] dst | 68 | * bitmap_to_arr32(buf, src, nbits) Copy nbits from buf to u32[] dst |
69 | * | 69 | * |
70 | * Note, bitmap_zero() and bitmap_fill() operate over the region of | ||
71 | * unsigned longs, that is, bits behind bitmap till the unsigned long | ||
72 | * boundary will be zeroed or filled as well. Consider to use | ||
73 | * bitmap_clear() or bitmap_set() to make explicit zeroing or filling | ||
74 | * respectively. | ||
70 | */ | 75 | */ |
71 | 76 | ||
72 | /** | 77 | /** |
@@ -202,12 +207,12 @@ static inline void bitmap_zero(unsigned long *dst, unsigned int nbits) | |||
202 | 207 | ||
203 | static inline void bitmap_fill(unsigned long *dst, unsigned int nbits) | 208 | static inline void bitmap_fill(unsigned long *dst, unsigned int nbits) |
204 | { | 209 | { |
205 | unsigned int nlongs = BITS_TO_LONGS(nbits); | 210 | if (small_const_nbits(nbits)) |
206 | if (!small_const_nbits(nbits)) { | 211 | *dst = ~0UL; |
207 | unsigned int len = (nlongs - 1) * sizeof(unsigned long); | 212 | else { |
208 | memset(dst, 0xff, len); | 213 | unsigned int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); |
214 | memset(dst, 0xff, len); | ||
209 | } | 215 | } |
210 | dst[nlongs - 1] = BITMAP_LAST_WORD_MASK(nbits); | ||
211 | } | 216 | } |
212 | 217 | ||
213 | static inline void bitmap_copy(unsigned long *dst, const unsigned long *src, | 218 | static inline void bitmap_copy(unsigned long *dst, const unsigned long *src, |