Lines Matching refs:nbits
97 * @nbits : bitmap size, in bits
104 unsigned shift, unsigned nbits)
106 unsigned k, lim = BITS_TO_LONGS(nbits);
108 unsigned long mask = BITMAP_LAST_WORD_MASK(nbits);
141 * @nbits : bitmap size, in bits
149 unsigned int shift, unsigned int nbits)
152 unsigned int lim = BITS_TO_LONGS(nbits);
179 * @nbits: bitmap size, in bits
183 * m such that @first <= n < nbits, and m = n + @cut.
211 unsigned int first, unsigned int cut, unsigned int nbits)
213 unsigned int len = BITS_TO_LONGS(nbits);
296 const unsigned long *mask, unsigned int nbits)
299 unsigned int nr = BITS_TO_LONGS(nbits);
505 unsigned long *bitmap, int nbits)
509 if (r->end >= nbits)
783 * @pos: a bit position in @buf (0 <= @pos < @nbits)
784 * @nbits: number of valid bit positions in @buf
786 * Map the bit at position @pos in @buf (of length @nbits) to the
798 static int bitmap_pos_to_ord(const unsigned long *buf, unsigned int pos, unsigned int nbits)
800 if (pos >= nbits || !test_bit(pos, buf))
810 * @nbits: number of valid bit positions in @buf
814 * >= weight(buf), returns @nbits.
818 * and all other @ord values returns @nbits. When @ord value 3
822 * The bit positions 0 through @nbits-1 are valid positions in @buf.
824 unsigned int bitmap_ord_to_pos(const unsigned long *buf, unsigned int ord, unsigned int nbits)
828 for (pos = find_first_bit(buf, nbits);
829 pos < nbits && ord;
830 pos = find_next_bit(buf, nbits, pos + 1))
842 * @nbits: number of bits in each of these bitmaps
870 unsigned int nbits)
876 bitmap_zero(dst, nbits);
878 w = bitmap_weight(new, nbits);
879 for_each_set_bit(oldbit, src, nbits) {
880 int n = bitmap_pos_to_ord(old, oldbit, nbits);
885 set_bit(bitmap_ord_to_pos(new, n % w, nbits), dst);
1065 * @nbits: number of bits in each of these bitmaps
1072 unsigned int sz, unsigned int nbits)
1078 bitmap_zero(dst, nbits);
1080 for_each_set_bit(oldbit, orig, nbits)
1229 * @nbits: number of bits in the bitmap
1231 * Require nbits % BITS_PER_LONG == 0.
1234 void bitmap_copy_le(unsigned long *dst, const unsigned long *src, unsigned int nbits)
1238 for (i = 0; i < nbits/BITS_PER_LONG; i++) {
1248 unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags)
1250 return kmalloc_array(BITS_TO_LONGS(nbits), sizeof(unsigned long),
1255 unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags)
1257 return bitmap_alloc(nbits, flags | __GFP_ZERO);
1275 unsigned int nbits, gfp_t flags)
1280 bitmap = bitmap_alloc(nbits, flags);
1293 unsigned int nbits, gfp_t flags)
1295 return devm_bitmap_alloc(dev, nbits, flags | __GFP_ZERO);
1304 * @nbits: number of bits in @bitmap
1306 void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf, unsigned int nbits)
1310 halfwords = DIV_ROUND_UP(nbits, 32);
1317 /* Clear tail bits in last word beyond nbits. */
1318 if (nbits % BITS_PER_LONG)
1319 bitmap[(halfwords - 1) / 2] &= BITMAP_LAST_WORD_MASK(nbits);
1327 * @nbits: number of bits in @bitmap
1329 void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int nbits)
1333 halfwords = DIV_ROUND_UP(nbits, 32);
1340 /* Clear tail bits in last element of array beyond nbits. */
1341 if (nbits % BITS_PER_LONG)
1342 buf[halfwords - 1] &= (u32) (UINT_MAX >> ((-nbits) & 31));