Commit ea4fe7e8 authored by Antoine Tenart's avatar Antoine Tenart Committed by David S. Miller

net-sysfs: convert xps_cpus_show to bitmap_zalloc

Use bitmap_zalloc instead of zalloc_cpumask_var in xps_cpus_show to
align with xps_rxqs_show. This will improve maintenance and allow us to
factorize the two functions. The function should behave the same.
Signed-off-by: default avatarAntoine Tenart <atenart@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6859d915
...@@ -1367,8 +1367,7 @@ static ssize_t xps_cpus_show(struct netdev_queue *queue, ...@@ -1367,8 +1367,7 @@ static ssize_t xps_cpus_show(struct netdev_queue *queue,
int cpu, len, ret, num_tc = 1, tc = 0; int cpu, len, ret, num_tc = 1, tc = 0;
struct net_device *dev = queue->dev; struct net_device *dev = queue->dev;
struct xps_dev_maps *dev_maps; struct xps_dev_maps *dev_maps;
cpumask_var_t mask; unsigned long *mask, index;
unsigned long index;
if (!netif_is_multiqueue(dev)) if (!netif_is_multiqueue(dev))
return -ENOENT; return -ENOENT;
...@@ -1396,7 +1395,8 @@ static ssize_t xps_cpus_show(struct netdev_queue *queue, ...@@ -1396,7 +1395,8 @@ static ssize_t xps_cpus_show(struct netdev_queue *queue,
} }
} }
if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) { mask = bitmap_zalloc(nr_cpu_ids, GFP_KERNEL);
if (!mask) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_rtnl_unlock; goto err_rtnl_unlock;
} }
...@@ -1414,7 +1414,7 @@ static ssize_t xps_cpus_show(struct netdev_queue *queue, ...@@ -1414,7 +1414,7 @@ static ssize_t xps_cpus_show(struct netdev_queue *queue,
for (i = map->len; i--;) { for (i = map->len; i--;) {
if (map->queues[i] == index) { if (map->queues[i] == index) {
cpumask_set_cpu(cpu, mask); set_bit(cpu, mask);
break; break;
} }
} }
...@@ -1424,8 +1424,8 @@ static ssize_t xps_cpus_show(struct netdev_queue *queue, ...@@ -1424,8 +1424,8 @@ static ssize_t xps_cpus_show(struct netdev_queue *queue,
rtnl_unlock(); rtnl_unlock();
len = snprintf(buf, PAGE_SIZE, "%*pb\n", cpumask_pr_args(mask)); len = bitmap_print_to_pagebuf(false, buf, mask, nr_cpu_ids);
free_cpumask_var(mask); bitmap_free(mask);
return len < PAGE_SIZE ? len : -EINVAL; return len < PAGE_SIZE ? len : -EINVAL;
err_rtnl_unlock: err_rtnl_unlock:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment