]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - lib/bitmap.c
slub: Calculate min_objects based on number of processors.
[linux-2.6-omap-h63xx.git] / lib / bitmap.c
index ee6e58fce8f75f675c2688294b07e01655a4396e..a6939e18d7bb3bc4f8d0caba8004e6b075bd3983 100644 (file)
@@ -97,10 +97,10 @@ EXPORT_SYMBOL(__bitmap_complement);
 
 /**
  * __bitmap_shift_right - logical right shift of the bits in a bitmap
- *   @dst - destination bitmap
- *   @src - source bitmap
- *   @nbits - shift by this many bits
- *   @bits - bitmap size, in bits
+ *   @dst : destination bitmap
+ *   @src : source bitmap
+ *   @shift : shift by this many bits
+ *   @bits : bitmap size, in bits
  *
  * Shifting right (dividing) means moving bits in the MS -> LS bit
  * direction.  Zeros are fed into the vacated MS positions and the
@@ -141,10 +141,10 @@ EXPORT_SYMBOL(__bitmap_shift_right);
 
 /**
  * __bitmap_shift_left - logical left shift of the bits in a bitmap
- *   @dst - destination bitmap
- *   @src - source bitmap
- *   @nbits - shift by this many bits
- *   @bits - bitmap size, in bits
+ *   @dst : destination bitmap
+ *   @src : source bitmap
+ *   @shift : shift by this many bits
+ *   @bits : bitmap size, in bits
  *
  * Shifting left (multiplying) means moving bits in the LS -> MS
  * direction.  Zeros are fed into the vacated LS bit positions
@@ -315,6 +315,22 @@ int bitmap_scnprintf(char *buf, unsigned int buflen,
 }
 EXPORT_SYMBOL(bitmap_scnprintf);
 
+/**
+ * bitmap_scnprintf_len - return buffer length needed to convert
+ * bitmap to an ASCII hex string.
+ * @len: number of bits to be converted
+ */
+int bitmap_scnprintf_len(unsigned int len)
+{
+       /* 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;
+}
+EXPORT_SYMBOL(bitmap_scnprintf_len);
+
 /**
  * __bitmap_parse - convert an ASCII hex string into a bitmap.
  * @buf: pointer to buffer containing string.
@@ -469,6 +485,10 @@ int bitmap_scnlistprintf(char *buf, unsigned int buflen,
        /* current bit is 'cur', most recently seen range is [rbot, rtop] */
        int cur, rbot, rtop;
 
+       if (buflen == 0)
+               return 0;
+       buf[0] = 0;
+
        rbot = cur = find_first_bit(maskp, nmaskbits);
        while (cur < nmaskbits) {
                rtop = cur;