Lines Matching defs:bitmap
3 * lib/bitmap.c
4 * Helper functions for bitmap.h.
7 #include <linux/bitmap.h>
26 * DOC: bitmap introduction
30 * given bitmap does _not_ need to be an exact multiple of
34 * of a bitmap are 'don't care'. The implementation makes
37 * The bitmap operations that return Boolean (bitmap_empty,
93 * __bitmap_shift_right - logical right shift of the bits in a bitmap
94 * @dst : destination bitmap
95 * @src : source bitmap
97 * @nbits : bitmap size, in bits
137 * __bitmap_shift_left - logical left shift of the bits in a bitmap
138 * @dst : destination bitmap
139 * @src : source bitmap
141 * @nbits : bitmap size, in bits
174 * bitmap_cut() - remove bit region from bitmap and right shift remaining bits
175 * @dst: destination bitmap, might overlap with src
176 * @src: source bitmap
179 * @nbits: bitmap size, in bits
187 * The @src bitmap is::
336 int __bitmap_weight(const unsigned long *bitmap, unsigned int bits)
342 w += hweight_long(bitmap[k]);
345 w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits));
396 * @size: The bitmap size in bits
438 * bitmap_parse_user - convert an ASCII hex string in a user buffer into a bitmap
443 * @maskp: pointer to bitmap array that will contain result.
444 * @nmaskbits: size of bitmap, in bits.
465 * bitmap_print_to_pagebuf - convert bitmap to list or hex format ASCII string
466 * @list: indicates whether the bitmap must be list
468 * @maskp: pointer to bitmap to convert
469 * @nmaskbits: size of bitmap, in bits
491 * Region 9-38:4/10 describes the following bitmap structure:
505 unsigned long *bitmap, int nbits)
513 bitmap_set(bitmap, start, min(r->end - start + 1, r->off));
617 * bitmap_parselist - convert list format ASCII string to bitmap
676 * @maskp: pointer to bitmap array that will contain result.
677 * @nmaskbits: size of bitmap, in bits.
724 * bitmap_parse - convert an ASCII hex string into a bitmap.
729 * @maskp: pointer to bitmap array that will contain result.
730 * @nmaskbits: size of bitmap, in bits.
744 u32 *bitmap = (u32 *)maskp;
757 end = bitmap_get_x32_reverse(start, end, &bitmap[chunk ^ 1]);
759 end = bitmap_get_x32_reverse(start, end, &bitmap[chunk]);
781 * bitmap_pos_to_ord - find ordinal of set bit at given position in bitmap
782 * @buf: pointer to a bitmap
807 * bitmap_ord_to_pos - find position of n-th set bit in bitmap
808 * @buf: pointer to bitmap
837 * bitmap_remap - Apply map defined by a pair of bitmaps to another bitmap
927 * bitmap_onto - translate one bitmap relative to another
928 * @dst: resulting translated bitmap
929 * @orig: original untranslated bitmap
930 * @relmap: bitmap relative to which translated
949 * @orig bitmap over itself so that all its set bits x are in the
992 * unsigned long *tmp; // a temporary bitmap's bits
1000 * using bitmap_fold() to fold the @orig bitmap modulo ten
1061 * bitmap_fold - fold larger bitmap into smaller, modulo specified size
1062 * @dst: resulting smaller bitmap
1063 * @orig: original larger bitmap
1087 * bitmap: array of unsigned longs corresponding to the bitmap
1090 * reg_op: operation(s) to perform on that region of bitmap
1092 * Can set, verify and/or release a region of bits in a bitmap,
1095 * A region of a bitmap is a sequence of bits in the bitmap, of
1109 static int __reg_op(unsigned long *bitmap, unsigned int pos, int order, int reg_op)
1112 int index; /* index first long of region in bitmap */
1113 int offset; /* bit offset region in bitmap[index] */
1114 int nlongs_reg; /* num longs spanned by region in bitmap */
1117 int i; /* scans bitmap by longs */
1141 if (bitmap[index + i] & mask)
1149 bitmap[index + i] |= mask;
1154 bitmap[index + i] &= ~mask;
1163 * @bitmap: array of unsigned longs corresponding to the bitmap
1164 * @bits: number of bits in the bitmap
1167 * Find a region of free (zero) bits in a @bitmap of @bits bits and
1172 * Return the bit offset in bitmap of the allocated region,
1175 int bitmap_find_free_region(unsigned long *bitmap, unsigned int bits, int order)
1177 unsigned int pos, end; /* scans bitmap by regions of size order */
1180 if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
1182 __reg_op(bitmap, pos, order, REG_OP_ALLOC);
1190 * bitmap_release_region - release allocated bitmap region
1191 * @bitmap: array of unsigned longs corresponding to the bitmap
1196 * the found region (by clearing it in the bitmap).
1200 void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int order)
1202 __reg_op(bitmap, pos, order, REG_OP_RELEASE);
1207 * bitmap_allocate_region - allocate bitmap region
1208 * @bitmap: array of unsigned longs corresponding to the bitmap
1212 * Allocate (set bits in) a specified region of a bitmap.
1217 int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order)
1219 if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
1221 return __reg_op(bitmap, pos, order, REG_OP_ALLOC);
1226 * bitmap_copy_le - copy a bitmap, putting the bits into little-endian order.
1228 * @src: bitmap to copy
1229 * @nbits: number of bits in the bitmap
1261 void bitmap_free(const unsigned long *bitmap)
1263 kfree(bitmap);
1269 unsigned long *bitmap = data;
1271 bitmap_free(bitmap);
1277 unsigned long *bitmap;
1280 bitmap = bitmap_alloc(nbits, flags);
1281 if (!bitmap)
1284 ret = devm_add_action_or_reset(dev, devm_bitmap_free, bitmap);
1288 return bitmap;
1301 * bitmap_from_arr32 - copy the contents of u32 array of bits to bitmap
1302 * @bitmap: array of unsigned longs, the destination bitmap
1303 * @buf: array of u32 (in host byte order), the source bitmap
1304 * @nbits: number of bits in @bitmap
1306 void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf, unsigned int nbits)
1312 bitmap[i/2] = (unsigned long) buf[i];
1314 bitmap[i/2] |= ((unsigned long) buf[i]) << 32;
1319 bitmap[(halfwords - 1) / 2] &= BITMAP_LAST_WORD_MASK(nbits);
1324 * bitmap_to_arr32 - copy the contents of bitmap to a u32 array of bits
1325 * @buf: array of u32 (in host byte order), the dest bitmap
1326 * @bitmap: array of unsigned longs, the source bitmap
1327 * @nbits: number of bits in @bitmap
1329 void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int nbits)
1335 buf[i] = (u32) (bitmap[i/2] & UINT_MAX);
1337 buf[i] = (u32) (bitmap[i/2] >> 32);