padata: use %*pb[l] to print bitmaps including cpumasks and nodemasks
authorTejun Heo <tj@kernel.org>
Fri, 13 Feb 2015 22:38:05 +0000 (14:38 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 14 Feb 2015 05:21:38 +0000 (21:21 -0800)
printk and friends can now format bitmaps using '%*pb[l]'.  cpumask
and nodemask also provide cpumask_pr_args() and nodemask_pr_args()
respectively which can be used to generate the two printf arguments
necessary to format the specified cpu/nodemask.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/padata.c

index 161402f0b517c9f483f166585bd61d61bac2e3f3..b38bea9c466a012a9bc04423af25a5c7d04be34d 100644 (file)
@@ -917,15 +917,10 @@ static ssize_t show_cpumask(struct padata_instance *pinst,
        else
                cpumask = pinst->cpumask.pcpu;
 
-       len = bitmap_scnprintf(buf, PAGE_SIZE, cpumask_bits(cpumask),
-                              nr_cpu_ids);
-       if (PAGE_SIZE - len < 2)
-               len = -EINVAL;
-       else
-               len += sprintf(buf + len, "\n");
-
+       len = snprintf(buf, PAGE_SIZE, "%*pb\n",
+                      nr_cpu_ids, cpumask_bits(cpumask));
        mutex_unlock(&pinst->lock);
-       return len;
+       return len < PAGE_SIZE ? len : -EINVAL;
 }
 
 static ssize_t store_cpumask(struct padata_instance *pinst,