diff options
author | Sudeep Holla <sudeep.holla@arm.com> | 2014-09-30 09:48:22 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-11-07 14:45:00 -0500 |
commit | 5aaba36318e5995e8c95d077a46d9a4d00fcc1cd (patch) | |
tree | edf9eb1ea758b82f1f04963a0fc54fab8bc8bc50 /drivers/base/topology.c | |
parent | 0372ffb35d00288802265586a29c117911d02fb8 (diff) |
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 <sudeep.holla@arm.com>
Suggested-by: Stephen Boyd <sboyd@codeaurora.org>
Tested-by: Stephen Boyd <sboyd@codeaurora.org>
Acked-by: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: x86@kernel.org
Cc: linux-acpi@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/topology.c')
-rw-r--r-- | drivers/base/topology.c | 22 |
1 files changed, 2 insertions, 20 deletions
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, \ | |||
42 | return sprintf(buf, "%d\n", topology_##name(dev->id)); \ | 42 | return sprintf(buf, "%d\n", topology_##name(dev->id)); \ |
43 | } | 43 | } |
44 | 44 | ||
45 | #if defined(topology_thread_cpumask) || defined(topology_core_cpumask) || \ | ||
46 | defined(topology_book_cpumask) | ||
47 | static ssize_t show_cpumap(int type, const struct cpumask *mask, char *buf) | ||
48 | { | ||
49 | ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf; | ||
50 | int n = 0; | ||
51 | |||
52 | if (len > 1) { | ||
53 | n = type? | ||
54 | cpulist_scnprintf(buf, len-2, mask) : | ||
55 | cpumask_scnprintf(buf, len-2, mask); | ||
56 | buf[n++] = '\n'; | ||
57 | buf[n] = '\0'; | ||
58 | } | ||
59 | return n; | ||
60 | } | ||
61 | #endif | ||
62 | |||
63 | #define define_siblings_show_map(name) \ | 45 | #define define_siblings_show_map(name) \ |
64 | static ssize_t show_##name(struct device *dev, \ | 46 | static ssize_t show_##name(struct device *dev, \ |
65 | struct device_attribute *attr, char *buf) \ | 47 | struct device_attribute *attr, char *buf) \ |
66 | { \ | 48 | { \ |
67 | return show_cpumap(0, topology_##name(dev->id), buf); \ | 49 | return cpumap_print_to_pagebuf(false, buf, topology_##name(dev->id));\ |
68 | } | 50 | } |
69 | 51 | ||
70 | #define define_siblings_show_list(name) \ | 52 | #define define_siblings_show_list(name) \ |
@@ -72,7 +54,7 @@ static ssize_t show_##name##_list(struct device *dev, \ | |||
72 | struct device_attribute *attr, \ | 54 | struct device_attribute *attr, \ |
73 | char *buf) \ | 55 | char *buf) \ |
74 | { \ | 56 | { \ |
75 | return show_cpumap(1, topology_##name(dev->id), buf); \ | 57 | return cpumap_print_to_pagebuf(true, buf, topology_##name(dev->id));\ |
76 | } | 58 | } |
77 | 59 | ||
78 | #define define_siblings_show_func(name) \ | 60 | #define define_siblings_show_func(name) \ |