Lines Matching defs: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);
448 * @pos: a bit position in @buf (0 <= @pos < @nbits)
449 * @nbits: number of valid bit positions in @buf
451 * Map the bit at position @pos in @buf (of length @nbits) to the
463 static int bitmap_pos_to_ord(const unsigned long *buf, unsigned int pos, unsigned int nbits)
465 if (pos >= nbits || !test_bit(pos, buf))
477 * @nbits: number of bits in each of these bitmaps
505 unsigned int nbits)
511 bitmap_zero(dst, nbits);
513 w = bitmap_weight(new, nbits);
514 for_each_set_bit(oldbit, src, nbits) {
515 int n = bitmap_pos_to_ord(old, oldbit, nbits);
520 set_bit(find_nth_bit(new, nbits, n % w), dst);
703 * @nbits: number of bits in each of these bitmaps
710 unsigned int sz, unsigned int nbits)
716 bitmap_zero(dst, nbits);
718 for_each_set_bit(oldbit, orig, nbits)
723 unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags)
725 return kmalloc_array(BITS_TO_LONGS(nbits), sizeof(unsigned long),
730 unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags)
732 return bitmap_alloc(nbits, flags | __GFP_ZERO);
736 unsigned long *bitmap_alloc_node(unsigned int nbits, gfp_t flags, int node)
738 return kmalloc_array_node(BITS_TO_LONGS(nbits), sizeof(unsigned long),
743 unsigned long *bitmap_zalloc_node(unsigned int nbits, gfp_t flags, int node)
745 return bitmap_alloc_node(nbits, flags | __GFP_ZERO, node);
763 unsigned int nbits, gfp_t flags)
768 bitmap = bitmap_alloc(nbits, flags);
781 unsigned int nbits, gfp_t flags)
783 return devm_bitmap_alloc(dev, nbits, flags | __GFP_ZERO);
792 * @nbits: number of bits in @bitmap
794 void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf, unsigned int nbits)
798 halfwords = DIV_ROUND_UP(nbits, 32);
805 /* Clear tail bits in last word beyond nbits. */
806 if (nbits % BITS_PER_LONG)
807 bitmap[(halfwords - 1) / 2] &= BITMAP_LAST_WORD_MASK(nbits);
815 * @nbits: number of bits in @bitmap
817 void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int nbits)
821 halfwords = DIV_ROUND_UP(nbits, 32);
828 /* Clear tail bits in last element of array beyond nbits. */
829 if (nbits % BITS_PER_LONG)
830 buf[halfwords - 1] &= (u32) (UINT_MAX >> ((-nbits) & 31));
840 * @nbits: number of bits in @bitmap
842 void bitmap_from_arr64(unsigned long *bitmap, const u64 *buf, unsigned int nbits)
846 for (n = nbits; n > 0; n -= 64) {
855 * Clear tail bits in the last word beyond nbits.
858 * to the last word of the bitmap, except for nbits == 0, which
861 if (nbits % BITS_PER_LONG)
862 bitmap[-1] &= BITMAP_LAST_WORD_MASK(nbits);
870 * @nbits: number of bits in @bitmap
872 void bitmap_to_arr64(u64 *buf, const unsigned long *bitmap, unsigned int nbits)
874 const unsigned long *end = bitmap + BITS_TO_LONGS(nbits);
883 /* Clear tail bits in the last element of array beyond nbits. */
884 if (nbits % 64)
885 buf[-1] &= GENMASK_ULL((nbits - 1) % 64, 0);