aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/bitmap.h12
-rw-r--r--lib/bitmap.c11
2 files changed, 12 insertions, 11 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index c168a807ab9a..5e7f75a6d7d0 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -98,8 +98,8 @@ extern void __bitmap_complement(unsigned long *dst, const unsigned long *src,
98 unsigned int nbits); 98 unsigned int nbits);
99extern void __bitmap_shift_right(unsigned long *dst, const unsigned long *src, 99extern void __bitmap_shift_right(unsigned long *dst, const unsigned long *src,
100 unsigned int shift, unsigned int nbits); 100 unsigned int shift, unsigned int nbits);
101extern void __bitmap_shift_left(unsigned long *dst, 101extern void __bitmap_shift_left(unsigned long *dst, const unsigned long *src,
102 const unsigned long *src, int shift, int bits); 102 unsigned int shift, unsigned int nbits);
103extern int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, 103extern int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
104 const unsigned long *bitmap2, unsigned int nbits); 104 const unsigned long *bitmap2, unsigned int nbits);
105extern void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1, 105extern void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
@@ -322,13 +322,13 @@ static inline void bitmap_shift_right(unsigned long *dst, const unsigned long *s
322 __bitmap_shift_right(dst, src, shift, nbits); 322 __bitmap_shift_right(dst, src, shift, nbits);
323} 323}
324 324
325static inline void bitmap_shift_left(unsigned long *dst, 325static inline void bitmap_shift_left(unsigned long *dst, const unsigned long *src,
326 const unsigned long *src, int n, int nbits) 326 unsigned int shift, unsigned int nbits)
327{ 327{
328 if (small_const_nbits(nbits)) 328 if (small_const_nbits(nbits))
329 *dst = (*src << n) & BITMAP_LAST_WORD_MASK(nbits); 329 *dst = (*src << shift) & BITMAP_LAST_WORD_MASK(nbits);
330 else 330 else
331 __bitmap_shift_left(dst, src, n, nbits); 331 __bitmap_shift_left(dst, src, shift, nbits);
332} 332}
333 333
334static inline int bitmap_parse(const char *buf, unsigned int buflen, 334static inline int bitmap_parse(const char *buf, unsigned int buflen,
diff --git a/lib/bitmap.c b/lib/bitmap.c
index db88512c3451..74bdf3601245 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -148,18 +148,19 @@ EXPORT_SYMBOL(__bitmap_shift_right);
148 * @dst : destination bitmap 148 * @dst : destination bitmap
149 * @src : source bitmap 149 * @src : source bitmap
150 * @shift : shift by this many bits 150 * @shift : shift by this many bits
151 * @bits : bitmap size, in bits 151 * @nbits : bitmap size, in bits
152 * 152 *
153 * Shifting left (multiplying) means moving bits in the LS -> MS 153 * Shifting left (multiplying) means moving bits in the LS -> MS
154 * direction. Zeros are fed into the vacated LS bit positions 154 * direction. Zeros are fed into the vacated LS bit positions
155 * and those MS bits shifted off the top are lost. 155 * and those MS bits shifted off the top are lost.
156 */ 156 */
157 157
158void __bitmap_shift_left(unsigned long *dst, 158void __bitmap_shift_left(unsigned long *dst, const unsigned long *src,
159 const unsigned long *src, int shift, int bits) 159 unsigned int shift, unsigned int nbits)
160{ 160{
161 int k, lim = BITS_TO_LONGS(bits), left = bits % BITS_PER_LONG; 161 int k;
162 int off = shift/BITS_PER_LONG, rem = shift % BITS_PER_LONG; 162 unsigned int lim = BITS_TO_LONGS(nbits), left = nbits % BITS_PER_LONG;
163 unsigned int off = shift/BITS_PER_LONG, rem = shift % BITS_PER_LONG;
163 for (k = lim - off - 1; k >= 0; --k) { 164 for (k = lim - off - 1; k >= 0; --k) {
164 unsigned long upper, lower; 165 unsigned long upper, lower;
165 166