···5757 * bitmap_weight(src, nbits) Hamming Weight: number set bits5858 * bitmap_weight_and(src1, src2, nbits) Hamming Weight of and'ed bitmap5959 * bitmap_weight_andnot(src1, src2, nbits) Hamming Weight of andnot'ed bitmap6060+ * bitmap_weight_from(src, start, end) Hamming Weight starting from @start6061 * bitmap_set(dst, pos, nbits) Set specified bit area6162 * bitmap_clear(dst, pos, nbits) Clear specified bit area6263 * bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area···478477 if (small_const_nbits(nbits))479478 return hweight_long(*src1 & ~(*src2) & BITMAP_LAST_WORD_MASK(nbits));480479 return __bitmap_weight_andnot(src1, src2, nbits);480480+}481481+482482+/**483483+ * bitmap_weight_from - Hamming weight for a memory region484484+ * @bitmap: The base address485485+ * @start: The bitnumber to starts weighting486486+ * @end: the bitmap size in bits487487+ *488488+ * Returns the number of set bits in the region. If @start >= @end,489489+ * return >= end.490490+ */491491+static __always_inline492492+unsigned long bitmap_weight_from(const unsigned long *bitmap,493493+ unsigned int start, unsigned int end)494494+{495495+ unsigned long w;496496+497497+ if (unlikely(start >= end))498498+ return end;499499+500500+ if (small_const_nbits(end))501501+ return hweight_long(*bitmap & GENMASK(end - 1, start));502502+503503+ bitmap += start / BITS_PER_LONG;504504+ /* Opencode round_down() to not include math.h */505505+ end -= start & ~(BITS_PER_LONG - 1);506506+ start %= BITS_PER_LONG;507507+ w = bitmap_weight(bitmap, end);508508+ if (start)509509+ w -= hweight_long(*bitmap & BITMAP_LAST_WORD_MASK(start));510510+511511+ return w;481512}482513483514static __always_inline