Skip to content

Commit e015e03

Browse files
JoePerchesgregkh
authored andcommitted
drivers core: Use sysfs_emit for shared_cpu_map_show and shared_cpu_list_show
Do not indirect the bitmap printing of these shared_cpu show functions by using cpumap_print_to_pagebuf/bitmap_print_to_pagebuf. Use the more typical style with the vsnprintf %*pb and %*pbl extensions directly so there is no possible mixup about the use of offset_in_page(buf) by bitmap_print_to_pagebuf. Signed-off-by: Joe Perches <[email protected]> Link: https://lore.kernel.org/r/80457b467ab6cde13a173cfd8a4f49cd8467a7fd.1600285923.git.joe@perches.com Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7981593 commit e015e03

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

drivers/base/cacheinfo.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -380,24 +380,22 @@ static ssize_t size_show(struct device *dev,
380380
return sysfs_emit(buf, "%uK\n", this_leaf->size >> 10);
381381
}
382382

383-
static ssize_t shared_cpumap_show_func(struct device *dev, bool list, char *buf)
383+
static ssize_t shared_cpu_map_show(struct device *dev,
384+
struct device_attribute *attr, char *buf)
384385
{
385386
struct cacheinfo *this_leaf = dev_get_drvdata(dev);
386387
const struct cpumask *mask = &this_leaf->shared_cpu_map;
387388

388-
return cpumap_print_to_pagebuf(list, buf, mask);
389-
}
390-
391-
static ssize_t shared_cpu_map_show(struct device *dev,
392-
struct device_attribute *attr, char *buf)
393-
{
394-
return shared_cpumap_show_func(dev, false, buf);
389+
return sysfs_emit(buf, "%*pb\n", nr_cpu_ids, mask);
395390
}
396391

397392
static ssize_t shared_cpu_list_show(struct device *dev,
398393
struct device_attribute *attr, char *buf)
399394
{
400-
return shared_cpumap_show_func(dev, true, buf);
395+
struct cacheinfo *this_leaf = dev_get_drvdata(dev);
396+
const struct cpumask *mask = &this_leaf->shared_cpu_map;
397+
398+
return sysfs_emit(buf, "%*pbl\n", nr_cpu_ids, mask);
401399
}
402400

403401
static ssize_t type_show(struct device *dev,

0 commit comments

Comments
 (0)