Lines Matching refs:nbits

86  *   @nbits : bitmap size, in bits
93 unsigned shift, unsigned nbits)
95 unsigned k, lim = BITS_TO_LONGS(nbits);
97 unsigned long mask = BITMAP_LAST_WORD_MASK(nbits);
130 * @nbits : bitmap size, in bits
138 unsigned int shift, unsigned int nbits)
141 unsigned int lim = BITS_TO_LONGS(nbits);
168 * @nbits: bitmap size, in bits
172 * m such that @first <= n < nbits, and m = n + @cut.
200 unsigned int first, unsigned int cut, unsigned int nbits)
202 unsigned int len = BITS_TO_LONGS(nbits);
285 const unsigned long *mask, unsigned int nbits)
288 unsigned int nr = BITS_TO_LONGS(nbits);
442 * @pos: a bit position in @buf (0 <= @pos < @nbits)
443 * @nbits: number of valid bit positions in @buf
445 * Map the bit at position @pos in @buf (of length @nbits) to the
457 static int bitmap_pos_to_ord(const unsigned long *buf, unsigned int pos, unsigned int nbits)
459 if (pos >= nbits || !test_bit(pos, buf))
471 * @nbits: number of bits in each of these bitmaps
499 unsigned int nbits)
505 bitmap_zero(dst, nbits);
507 w = bitmap_weight(new, nbits);
508 for_each_set_bit(oldbit, src, nbits) {
509 int n = bitmap_pos_to_ord(old, oldbit, nbits);
514 set_bit(find_nth_bit(new, nbits, n % w), dst);
697 * @nbits: number of bits in each of these bitmaps
704 unsigned int sz, unsigned int nbits)
710 bitmap_zero(dst, nbits);
712 for_each_set_bit(oldbit, orig, nbits)
717 unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags)
719 return kmalloc_array(BITS_TO_LONGS(nbits), sizeof(unsigned long),
724 unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags)
726 return bitmap_alloc(nbits, flags | __GFP_ZERO);
730 unsigned long *bitmap_alloc_node(unsigned int nbits, gfp_t flags, int node)
732 return kmalloc_array_node(BITS_TO_LONGS(nbits), sizeof(unsigned long),
737 unsigned long *bitmap_zalloc_node(unsigned int nbits, gfp_t flags, int node)
739 return bitmap_alloc_node(nbits, flags | __GFP_ZERO, node);
757 unsigned int nbits, gfp_t flags)
762 bitmap = bitmap_alloc(nbits, flags);
775 unsigned int nbits, gfp_t flags)
777 return devm_bitmap_alloc(dev, nbits, flags | __GFP_ZERO);
786 * @nbits: number of bits in @bitmap
788 void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf, unsigned int nbits)
792 halfwords = DIV_ROUND_UP(nbits, 32);
799 /* Clear tail bits in last word beyond nbits. */
800 if (nbits % BITS_PER_LONG)
801 bitmap[(halfwords - 1) / 2] &= BITMAP_LAST_WORD_MASK(nbits);
809 * @nbits: number of bits in @bitmap
811 void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int nbits)
815 halfwords = DIV_ROUND_UP(nbits, 32);
822 /* Clear tail bits in last element of array beyond nbits. */
823 if (nbits % BITS_PER_LONG)
824 buf[halfwords - 1] &= (u32) (UINT_MAX >> ((-nbits) & 31));
834 * @nbits: number of bits in @bitmap
836 void bitmap_from_arr64(unsigned long *bitmap, const u64 *buf, unsigned int nbits)
840 for (n = nbits; n > 0; n -= 64) {
849 * Clear tail bits in the last word beyond nbits.
852 * to the last word of the bitmap, except for nbits == 0, which
855 if (nbits % BITS_PER_LONG)
856 bitmap[-1] &= BITMAP_LAST_WORD_MASK(nbits);
864 * @nbits: number of bits in @bitmap
866 void bitmap_to_arr64(u64 *buf, const unsigned long *bitmap, unsigned int nbits)
868 const unsigned long *end = bitmap + BITS_TO_LONGS(nbits);
877 /* Clear tail bits in the last element of array beyond nbits. */
878 if (nbits % 64)
879 buf[-1] &= GENMASK_ULL((nbits - 1) % 64, 0);