Lines Matching full:bitmap
3 * lib/bitmap.c
4 * Helper functions for bitmap.h.
7 #include <linux/bitmap.h>
15 * DOC: bitmap introduction
19 * given bitmap does _not_ need to be an exact multiple of
23 * of a bitmap are 'don't care'. The implementation makes
26 * The bitmap operations that return Boolean (bitmap_empty,
82 * __bitmap_shift_right - logical right shift of the bits in a bitmap
83 * @dst : destination bitmap
84 * @src : source bitmap
86 * @nbits : bitmap size, in bits
126 * __bitmap_shift_left - logical left shift of the bits in a bitmap
127 * @dst : destination bitmap
128 * @src : source bitmap
130 * @nbits : bitmap size, in bits
163 * bitmap_cut() - remove bit region from bitmap and right shift remaining bits
164 * @dst: destination bitmap, might overlap with src
165 * @src: source bitmap
168 * @nbits: bitmap size, in bits
176 * The @src bitmap is::
338 unsigned int __bitmap_weight(const unsigned long *bitmap, unsigned int bits) in __bitmap_weight() argument
340 return BITMAP_WEIGHT(bitmap[idx], bits); in __bitmap_weight()
403 * @size: The bitmap size in bits
440 * bitmap_pos_to_ord - find ordinal of set bit at given position in bitmap
441 * @buf: pointer to a bitmap
466 * bitmap_remap - Apply map defined by a pair of bitmaps to another bitmap
559 * bitmap_onto - translate one bitmap relative to another
560 * @dst: resulting translated bitmap
561 * @orig: original untranslated bitmap
562 * @relmap: bitmap relative to which translated
581 * @orig bitmap over itself so that all its set bits x are in the
624 * unsigned long *tmp; // a temporary bitmap's bits
632 * using bitmap_fold() to fold the @orig bitmap modulo ten
693 * bitmap_fold - fold larger bitmap into smaller, modulo specified size
694 * @dst: resulting smaller bitmap
695 * @orig: original larger bitmap
743 void bitmap_free(const unsigned long *bitmap) in bitmap_free() argument
745 kfree(bitmap); in bitmap_free()
751 unsigned long *bitmap = data; in devm_bitmap_free() local
753 bitmap_free(bitmap); in devm_bitmap_free()
759 unsigned long *bitmap; in devm_bitmap_alloc() local
762 bitmap = bitmap_alloc(nbits, flags); in devm_bitmap_alloc()
763 if (!bitmap) in devm_bitmap_alloc()
766 ret = devm_add_action_or_reset(dev, devm_bitmap_free, bitmap); in devm_bitmap_alloc()
770 return bitmap; in devm_bitmap_alloc()
783 * bitmap_from_arr32 - copy the contents of u32 array of bits to bitmap
784 * @bitmap: array of unsigned longs, the destination bitmap
785 * @buf: array of u32 (in host byte order), the source bitmap
786 * @nbits: number of bits in @bitmap
788 void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf, unsigned int nbits) in bitmap_from_arr32() argument
794 bitmap[i/2] = (unsigned long) buf[i]; in bitmap_from_arr32()
796 bitmap[i/2] |= ((unsigned long) buf[i]) << 32; in bitmap_from_arr32()
801 bitmap[(halfwords - 1) / 2] &= BITMAP_LAST_WORD_MASK(nbits); in bitmap_from_arr32()
806 * bitmap_to_arr32 - copy the contents of bitmap to a u32 array of bits
807 * @buf: array of u32 (in host byte order), the dest bitmap
808 * @bitmap: array of unsigned longs, the source bitmap
809 * @nbits: number of bits in @bitmap
811 void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int nbits) in bitmap_to_arr32() argument
817 buf[i] = (u32) (bitmap[i/2] & UINT_MAX); in bitmap_to_arr32()
819 buf[i] = (u32) (bitmap[i/2] >> 32); in bitmap_to_arr32()
831 * bitmap_from_arr64 - copy the contents of u64 array of bits to bitmap
832 * @bitmap: array of unsigned longs, the destination bitmap
833 * @buf: array of u64 (in host byte order), the source bitmap
834 * @nbits: number of bits in @bitmap
836 void bitmap_from_arr64(unsigned long *bitmap, const u64 *buf, unsigned int nbits) in bitmap_from_arr64() argument
843 *bitmap++ = val; in bitmap_from_arr64()
845 *bitmap++ = val >> 32; in bitmap_from_arr64()
852 * to the last word of the bitmap, except for nbits == 0, which in bitmap_from_arr64()
856 bitmap[-1] &= BITMAP_LAST_WORD_MASK(nbits); in bitmap_from_arr64()
861 * bitmap_to_arr64 - copy the contents of bitmap to a u64 array of bits
862 * @buf: array of u64 (in host byte order), the dest bitmap
863 * @bitmap: array of unsigned longs, the source bitmap
864 * @nbits: number of bits in @bitmap
866 void bitmap_to_arr64(u64 *buf, const unsigned long *bitmap, unsigned int nbits) in bitmap_to_arr64() argument
868 const unsigned long *end = bitmap + BITS_TO_LONGS(nbits); in bitmap_to_arr64()
870 while (bitmap < end) { in bitmap_to_arr64()
871 *buf = *bitmap++; in bitmap_to_arr64()
872 if (bitmap < end) in bitmap_to_arr64()
873 *buf |= (u64)(*bitmap++) << 32; in bitmap_to_arr64()