/**
* bitmap_scnprintf_len - return buffer length needed to convert
- * bitmap to an ASCII hex string.
- * @len: number of bits to be converted
+ * bitmap to an ASCII hex string
+ * @nr_bits: number of bits to be converted
*/
-int bitmap_scnprintf_len(unsigned int len)
+int bitmap_scnprintf_len(unsigned int nr_bits)
{
- /* we need 9 chars per word for 32 bit words (8 hexdigits + sep/null) */
- int bitslen = ALIGN(len, CHUNKSZ);
- int wordlen = CHUNKSZ / 4;
- int buflen = (bitslen / wordlen) * (wordlen + 1) * sizeof(char);
-
- return buflen;
+ unsigned int nr_nibbles = ALIGN(nr_bits, 4) / 4;
+ return nr_nibbles + ALIGN(nr_nibbles, CHUNKSZ / 4) / (CHUNKSZ / 4) - 1;
}
-EXPORT_SYMBOL(bitmap_scnprintf_len);
/**
* __bitmap_parse - convert an ASCII hex string into a bitmap.