From 5aaba36318e5995e8c95d077a46d9a4d00fcc1cd Mon Sep 17 00:00:00 2001 From: Sudeep Holla Date: Tue, 30 Sep 2014 14:48:22 +0100 Subject: cpumask: factor out show_cpumap into separate helper function Many sysfs *_show function use cpu{list,mask}_scnprintf to copy cpumap to the buffer aligned to PAGE_SIZE, append '\n' and '\0' to return null terminated buffer with newline. This patch creates a new helper function cpumap_print_to_pagebuf in cpumask.h using newly added bitmap_print_to_pagebuf and consolidates most of those sysfs functions using the new helper function. Signed-off-by: Sudeep Holla Suggested-by: Stephen Boyd Tested-by: Stephen Boyd Acked-by: "Rafael J. Wysocki" Acked-by: Bjorn Helgaas Acked-by: Peter Zijlstra (Intel) Cc: Greg Kroah-Hartman Cc: x86@kernel.org Cc: linux-acpi@vger.kernel.org Cc: linux-pci@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/base/topology.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'drivers/base/topology.c') diff --git a/drivers/base/topology.c b/drivers/base/topology.c index be7c1fb7c0c9..f7c353843ddf 100644 --- a/drivers/base/topology.c +++ b/drivers/base/topology.c @@ -42,29 +42,11 @@ static ssize_t show_##name(struct device *dev, \ return sprintf(buf, "%d\n", topology_##name(dev->id)); \ } -#if defined(topology_thread_cpumask) || defined(topology_core_cpumask) || \ - defined(topology_book_cpumask) -static ssize_t show_cpumap(int type, const struct cpumask *mask, char *buf) -{ - ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf; - int n = 0; - - if (len > 1) { - n = type? - cpulist_scnprintf(buf, len-2, mask) : - cpumask_scnprintf(buf, len-2, mask); - buf[n++] = '\n'; - buf[n] = '\0'; - } - return n; -} -#endif - #define define_siblings_show_map(name) \ static ssize_t show_##name(struct device *dev, \ struct device_attribute *attr, char *buf) \ { \ - return show_cpumap(0, topology_##name(dev->id), buf); \ + return cpumap_print_to_pagebuf(false, buf, topology_##name(dev->id));\ } #define define_siblings_show_list(name) \ @@ -72,7 +54,7 @@ static ssize_t show_##name##_list(struct device *dev, \ struct device_attribute *attr, \ char *buf) \ { \ - return show_cpumap(1, topology_##name(dev->id), buf); \ + return cpumap_print_to_pagebuf(true, buf, topology_##name(dev->id));\ } #define define_siblings_show_func(name) \ -- cgit v1.2.1