diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/bitmap.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index 761d2d4989ee..db88512c3451 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
| @@ -113,9 +113,9 @@ EXPORT_SYMBOL(__bitmap_complement); | |||
| 113 | void __bitmap_shift_right(unsigned long *dst, const unsigned long *src, | 113 | void __bitmap_shift_right(unsigned long *dst, const unsigned long *src, |
| 114 | unsigned shift, unsigned nbits) | 114 | unsigned shift, unsigned nbits) |
| 115 | { | 115 | { |
| 116 | unsigned k, lim = BITS_TO_LONGS(nbits), left = nbits % BITS_PER_LONG; | 116 | unsigned k, lim = BITS_TO_LONGS(nbits); |
| 117 | unsigned off = shift/BITS_PER_LONG, rem = shift % BITS_PER_LONG; | 117 | unsigned off = shift/BITS_PER_LONG, rem = shift % BITS_PER_LONG; |
| 118 | unsigned long mask = (1UL << left) - 1; | 118 | unsigned long mask = BITMAP_LAST_WORD_MASK(nbits); |
| 119 | for (k = 0; off + k < lim; ++k) { | 119 | for (k = 0; off + k < lim; ++k) { |
| 120 | unsigned long upper, lower; | 120 | unsigned long upper, lower; |
| 121 | 121 | ||
| @@ -127,12 +127,12 @@ void __bitmap_shift_right(unsigned long *dst, const unsigned long *src, | |||
| 127 | upper = 0; | 127 | upper = 0; |
| 128 | else { | 128 | else { |
| 129 | upper = src[off + k + 1]; | 129 | upper = src[off + k + 1]; |
| 130 | if (off + k + 1 == lim - 1 && left) | 130 | if (off + k + 1 == lim - 1) |
| 131 | upper &= mask; | 131 | upper &= mask; |
| 132 | upper <<= (BITS_PER_LONG - rem); | 132 | upper <<= (BITS_PER_LONG - rem); |
| 133 | } | 133 | } |
| 134 | lower = src[off + k]; | 134 | lower = src[off + k]; |
| 135 | if (left && off + k == lim - 1) | 135 | if (off + k == lim - 1) |
| 136 | lower &= mask; | 136 | lower &= mask; |
| 137 | lower >>= rem; | 137 | lower >>= rem; |
| 138 | dst[k] = lower | upper; | 138 | dst[k] = lower | upper; |
