Skip to content

Commit f799b1a

Browse files
htejuntorvalds
authored andcommitted
drivers/base: use %*pb[l] to print bitmaps including cpumasks and nodemasks
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. * Line termination only requires one extra space at the end of the buffer. Use PAGE_SIZE - 1 instead of PAGE_SIZE - 2 when formatting. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 125918d commit f799b1a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

drivers/base/cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ static ssize_t print_cpus_offline(struct device *dev,
245245
if (!alloc_cpumask_var(&offline, GFP_KERNEL))
246246
return -ENOMEM;
247247
cpumask_andnot(offline, cpu_possible_mask, cpu_online_mask);
248-
n = cpulist_scnprintf(buf, len, offline);
248+
n = scnprintf(buf, len, "%*pbl", cpumask_pr_args(offline));
249249
free_cpumask_var(offline);
250250

251251
/* display offline cpus >= nr_cpu_ids */

drivers/base/node.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,8 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
605605
{
606606
int n;
607607

608-
n = nodelist_scnprintf(buf, PAGE_SIZE-2, node_states[state]);
608+
n = scnprintf(buf, PAGE_SIZE - 1, "%*pbl",
609+
nodemask_pr_args(&node_states[state]));
609610
buf[n++] = '\n';
610611
buf[n] = '\0';
611612
return n;

0 commit comments

Comments
 (0)