diff options
author | Yury Norov <ynorov@caviumnetworks.com> | 2018-02-06 18:38:06 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-02-06 21:32:44 -0500 |
commit | 3aa56885e51683a19c8aa71739fd279b3f501cd7 (patch) | |
tree | e93c59c6988e8b35299381ef1ee47a584478058a /lib/bitmap.c | |
parent | c724f193619c896621bf5818d71ce77437f49a06 (diff) |
bitmap: replace bitmap_{from,to}_u32array
with bitmap_{from,to}_arr32 over the kernel. Additionally to it:
* __check_eq_bitmap() now takes single nbits argument.
* __check_eq_u32_array is not used in new test but may be used in
future. So I don't remove it here, but annotate as __used.
Tested on arm64 and 32-bit BE mips.
[arnd@arndb.de: perf: arm_dsu_pmu: convert to bitmap_from_arr32]
Link: http://lkml.kernel.org/r/20180201172508.5739-2-ynorov@caviumnetworks.com
[ynorov@caviumnetworks.com: fix net/core/ethtool.c]
Link: http://lkml.kernel.org/r/20180205071747.4ekxtsbgxkj5b2fz@yury-thinkpad
Link: http://lkml.kernel.org/r/20171228150019.27953-2-ynorov@caviumnetworks.com
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: David Decotigny <decot@googlers.com>,
Cc: David S. Miller <davem@davemloft.net>,
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Matthew Wilcox <mawilcox@microsoft.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/bitmap.c')
-rw-r--r-- | lib/bitmap.c | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index 47fe6441562c..9e498c77ed0e 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
@@ -1106,93 +1106,6 @@ int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order) | |||
1106 | EXPORT_SYMBOL(bitmap_allocate_region); | 1106 | EXPORT_SYMBOL(bitmap_allocate_region); |
1107 | 1107 | ||
1108 | /** | 1108 | /** |
1109 | * bitmap_from_u32array - copy the contents of a u32 array of bits to bitmap | ||
1110 | * @bitmap: array of unsigned longs, the destination bitmap, non NULL | ||
1111 | * @nbits: number of bits in @bitmap | ||
1112 | * @buf: array of u32 (in host byte order), the source bitmap, non NULL | ||
1113 | * @nwords: number of u32 words in @buf | ||
1114 | * | ||
1115 | * copy min(nbits, 32*nwords) bits from @buf to @bitmap, remaining | ||
1116 | * bits between nword and nbits in @bitmap (if any) are cleared. In | ||
1117 | * last word of @bitmap, the bits beyond nbits (if any) are kept | ||
1118 | * unchanged. | ||
1119 | * | ||
1120 | * Return the number of bits effectively copied. | ||
1121 | */ | ||
1122 | unsigned int | ||
1123 | bitmap_from_u32array(unsigned long *bitmap, unsigned int nbits, | ||
1124 | const u32 *buf, unsigned int nwords) | ||
1125 | { | ||
1126 | unsigned int dst_idx, src_idx; | ||
1127 | |||
1128 | for (src_idx = dst_idx = 0; dst_idx < BITS_TO_LONGS(nbits); ++dst_idx) { | ||
1129 | unsigned long part = 0; | ||
1130 | |||
1131 | if (src_idx < nwords) | ||
1132 | part = buf[src_idx++]; | ||
1133 | |||
1134 | #if BITS_PER_LONG == 64 | ||
1135 | if (src_idx < nwords) | ||
1136 | part |= ((unsigned long) buf[src_idx++]) << 32; | ||
1137 | #endif | ||
1138 | |||
1139 | if (dst_idx < nbits/BITS_PER_LONG) | ||
1140 | bitmap[dst_idx] = part; | ||
1141 | else { | ||
1142 | unsigned long mask = BITMAP_LAST_WORD_MASK(nbits); | ||
1143 | |||
1144 | bitmap[dst_idx] = (bitmap[dst_idx] & ~mask) | ||
1145 | | (part & mask); | ||
1146 | } | ||
1147 | } | ||
1148 | |||
1149 | return min_t(unsigned int, nbits, 32*nwords); | ||
1150 | } | ||
1151 | EXPORT_SYMBOL(bitmap_from_u32array); | ||
1152 | |||
1153 | /** | ||
1154 | * bitmap_to_u32array - copy the contents of bitmap to a u32 array of bits | ||
1155 | * @buf: array of u32 (in host byte order), the dest bitmap, non NULL | ||
1156 | * @nwords: number of u32 words in @buf | ||
1157 | * @bitmap: array of unsigned longs, the source bitmap, non NULL | ||
1158 | * @nbits: number of bits in @bitmap | ||
1159 | * | ||
1160 | * copy min(nbits, 32*nwords) bits from @bitmap to @buf. Remaining | ||
1161 | * bits after nbits in @buf (if any) are cleared. | ||
1162 | * | ||
1163 | * Return the number of bits effectively copied. | ||
1164 | */ | ||
1165 | unsigned int | ||
1166 | bitmap_to_u32array(u32 *buf, unsigned int nwords, | ||
1167 | const unsigned long *bitmap, unsigned int nbits) | ||
1168 | { | ||
1169 | unsigned int dst_idx = 0, src_idx = 0; | ||
1170 | |||
1171 | while (dst_idx < nwords) { | ||
1172 | unsigned long part = 0; | ||
1173 | |||
1174 | if (src_idx < BITS_TO_LONGS(nbits)) { | ||
1175 | part = bitmap[src_idx]; | ||
1176 | if (src_idx >= nbits/BITS_PER_LONG) | ||
1177 | part &= BITMAP_LAST_WORD_MASK(nbits); | ||
1178 | src_idx++; | ||
1179 | } | ||
1180 | |||
1181 | buf[dst_idx++] = part & 0xffffffffUL; | ||
1182 | |||
1183 | #if BITS_PER_LONG == 64 | ||
1184 | if (dst_idx < nwords) { | ||
1185 | part >>= 32; | ||
1186 | buf[dst_idx++] = part & 0xffffffffUL; | ||
1187 | } | ||
1188 | #endif | ||
1189 | } | ||
1190 | |||
1191 | return min_t(unsigned int, nbits, 32*nwords); | ||
1192 | } | ||
1193 | EXPORT_SYMBOL(bitmap_to_u32array); | ||
1194 | |||
1195 | /** | ||
1196 | * bitmap_copy_le - copy a bitmap, putting the bits into little-endian order. | 1109 | * bitmap_copy_le - copy a bitmap, putting the bits into little-endian order. |
1197 | * @dst: destination buffer | 1110 | * @dst: destination buffer |
1198 | * @src: bitmap to copy | 1111 | * @src: bitmap to copy |