]> nv-tegra.nvidia Code Review - linux-3.10.git/blobdiff - lib/bitmap.c
Merge tag 'iommu-updates-v3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/joro...
[linux-3.10.git] / lib / bitmap.c
index 2f4412e4d0719c25ca1d4948d489eee8c998f444..06f7e4fe8d2de4046a3139106058b9c831c9b789 100644 (file)
@@ -5,11 +5,13 @@
  * This source code is licensed under the GNU General Public License,
  * Version 2.  See the file COPYING for more details.
  */
-#include <linux/module.h>
+#include <linux/export.h>
+#include <linux/thread_info.h>
 #include <linux/ctype.h>
 #include <linux/errno.h>
 #include <linux/bitmap.h>
 #include <linux/bitops.h>
+#include <linux/bug.h>
 #include <asm/uaccess.h>
 
 /*
@@ -351,7 +353,7 @@ again:
 EXPORT_SYMBOL(bitmap_find_next_zero_area);
 
 /*
- * Bitmap printing & parsing functions: first version by Bill Irwin,
+ * Bitmap printing & parsing functions: first version by Nadia Yvette Chambers,
  * second version by Paul Jackson, third by Joe Korty.
  */
 
@@ -367,7 +369,8 @@ EXPORT_SYMBOL(bitmap_find_next_zero_area);
  * @nmaskbits: size of bitmap, in bits
  *
  * Exactly @nmaskbits bits are displayed.  Hex digits are grouped into
- * comma-separated sets of eight digits per set.
+ * comma-separated sets of eight digits per set.  Returns the number of
+ * characters which were written to *buf, excluding the trailing \0.
  */
 int bitmap_scnprintf(char *buf, unsigned int buflen,
        const unsigned long *maskp, int nmaskbits)
@@ -419,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
 {
        int c, old_c, totaldigits, ndigits, nchunks, nbits;
        u32 chunk;
-       const char __user *ubuf = buf;
+       const char __user __force *ubuf = (const char __user __force *)buf;
 
        bitmap_zero(maskp, nmaskbits);
 
@@ -504,7 +507,9 @@ int bitmap_parse_user(const char __user *ubuf,
 {
        if (!access_ok(VERIFY_READ, ubuf, ulen))
                return -EFAULT;
-       return __bitmap_parse((const char *)ubuf, ulen, 1, maskp, nmaskbits);
+       return __bitmap_parse((const char __force *)ubuf,
+                               ulen, 1, maskp, nmaskbits);
+
 }
 EXPORT_SYMBOL(bitmap_parse_user);
 
@@ -513,8 +518,8 @@ EXPORT_SYMBOL(bitmap_parse_user);
  *
  * Helper routine for bitmap_scnlistprintf().  Write decimal number
  * or range to buf, suppressing output past buf+buflen, with optional
- * comma-prefix.  Return len of what would be written to buf, if it
- * all fit.
+ * comma-prefix.  Return len of what was written to *buf, excluding the
+ * trailing \0.
  */
 static inline int bscnl_emit(char *buf, int buflen, int rbot, int rtop, int len)
 {
@@ -540,9 +545,8 @@ static inline int bscnl_emit(char *buf, int buflen, int rbot, int rtop, int len)
  * the range.  Output format is compatible with the format
  * accepted as input by bitmap_parselist().
  *
- * The return value is the number of characters which would be
- * generated for the given input, excluding the trailing '\0', as
- * per ISO C99.
+ * The return value is the number of characters which were written to *buf
+ * excluding the trailing '\0', as per ISO C99's scnprintf.
  */
 int bitmap_scnlistprintf(char *buf, unsigned int buflen,
        const unsigned long *maskp, int nmaskbits)
@@ -594,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
 {
        unsigned a, b;
        int c, old_c, totaldigits;
-       const char __user *ubuf = buf;
+       const char __user __force *ubuf = (const char __user __force *)buf;
        int exp_digit, in_range;
 
        totaldigits = c = 0;
@@ -694,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
 {
        if (!access_ok(VERIFY_READ, ubuf, ulen))
                return -EFAULT;
-       return __bitmap_parselist((const char *)ubuf,
+       return __bitmap_parselist((const char __force *)ubuf,
                                        ulen, 1, maskp, nmaskbits);
 }
 EXPORT_SYMBOL(bitmap_parselist_user);