diff options
author | Tejun Heo <tj@kernel.org> | 2015-02-13 17:37:42 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-14 00:21:38 -0500 |
commit | f09068276c5cbe2dd76679b2c9fcc91e12eb7ebe (patch) | |
tree | bfbeeb101294d9b2d64afe06ceed124ca8ad3688 /net/core/net-sysfs.c | |
parent | 1a40243bae6fa0cc09cee40d51e258c725d897e6 (diff) |
net: 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.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'net/core/net-sysfs.c')
-rw-r--r-- | net/core/net-sysfs.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 999341244434..f2aa73bfb0e4 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
@@ -614,8 +614,7 @@ static ssize_t show_rps_map(struct netdev_rx_queue *queue, | |||
614 | { | 614 | { |
615 | struct rps_map *map; | 615 | struct rps_map *map; |
616 | cpumask_var_t mask; | 616 | cpumask_var_t mask; |
617 | size_t len = 0; | 617 | int i, len; |
618 | int i; | ||
619 | 618 | ||
620 | if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) | 619 | if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) |
621 | return -ENOMEM; | 620 | return -ENOMEM; |
@@ -626,17 +625,11 @@ static ssize_t show_rps_map(struct netdev_rx_queue *queue, | |||
626 | for (i = 0; i < map->len; i++) | 625 | for (i = 0; i < map->len; i++) |
627 | cpumask_set_cpu(map->cpus[i], mask); | 626 | cpumask_set_cpu(map->cpus[i], mask); |
628 | 627 | ||
629 | len += cpumask_scnprintf(buf + len, PAGE_SIZE, mask); | 628 | len = snprintf(buf, PAGE_SIZE, "%*pb\n", cpumask_pr_args(mask)); |
630 | if (PAGE_SIZE - len < 3) { | ||
631 | rcu_read_unlock(); | ||
632 | free_cpumask_var(mask); | ||
633 | return -EINVAL; | ||
634 | } | ||
635 | rcu_read_unlock(); | 629 | rcu_read_unlock(); |
636 | |||
637 | free_cpumask_var(mask); | 630 | free_cpumask_var(mask); |
638 | len += sprintf(buf + len, "\n"); | 631 | |
639 | return len; | 632 | return len < PAGE_SIZE ? len : -EINVAL; |
640 | } | 633 | } |
641 | 634 | ||
642 | static ssize_t store_rps_map(struct netdev_rx_queue *queue, | 635 | static ssize_t store_rps_map(struct netdev_rx_queue *queue, |
@@ -1090,8 +1083,7 @@ static ssize_t show_xps_map(struct netdev_queue *queue, | |||
1090 | struct xps_dev_maps *dev_maps; | 1083 | struct xps_dev_maps *dev_maps; |
1091 | cpumask_var_t mask; | 1084 | cpumask_var_t mask; |
1092 | unsigned long index; | 1085 | unsigned long index; |
1093 | size_t len = 0; | 1086 | int i, len; |
1094 | int i; | ||
1095 | 1087 | ||
1096 | if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) | 1088 | if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) |
1097 | return -ENOMEM; | 1089 | return -ENOMEM; |
@@ -1117,15 +1109,9 @@ static ssize_t show_xps_map(struct netdev_queue *queue, | |||
1117 | } | 1109 | } |
1118 | rcu_read_unlock(); | 1110 | rcu_read_unlock(); |
1119 | 1111 | ||
1120 | len += cpumask_scnprintf(buf + len, PAGE_SIZE, mask); | 1112 | len = snprintf(buf, PAGE_SIZE, "%*pb\n", cpumask_pr_args(mask)); |
1121 | if (PAGE_SIZE - len < 3) { | ||
1122 | free_cpumask_var(mask); | ||
1123 | return -EINVAL; | ||
1124 | } | ||
1125 | |||
1126 | free_cpumask_var(mask); | 1113 | free_cpumask_var(mask); |
1127 | len += sprintf(buf + len, "\n"); | 1114 | return len < PAGE_SIZE ? len : -EINVAL; |
1128 | return len; | ||
1129 | } | 1115 | } |
1130 | 1116 | ||
1131 | static ssize_t store_xps_map(struct netdev_queue *queue, | 1117 | static ssize_t store_xps_map(struct netdev_queue *queue, |