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 /include/linux | |
| 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 'include/linux')
| -rw-r--r-- | include/linux/bitmap.h | 3 | ||||
| -rw-r--r-- | include/linux/cpumask.h | 17 |
2 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index e1c8d080c427..9d5c3224a1e2 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h | |||
| @@ -60,6 +60,7 @@ | |||
| 60 | * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region | 60 | * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region |
| 61 | * bitmap_release_region(bitmap, pos, order) Free specified bit region | 61 | * bitmap_release_region(bitmap, pos, order) Free specified bit region |
| 62 | * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region | 62 | * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region |
| 63 | * bitmap_print_to_pagebuf(list, buf, mask, nbits) Print bitmap src as list/hex | ||
| 63 | */ | 64 | */ |
| 64 | 65 | ||
| 65 | /* | 66 | /* |
| @@ -145,6 +146,8 @@ extern void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int o | |||
| 145 | extern int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order); | 146 | extern int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order); |
| 146 | extern void bitmap_copy_le(void *dst, const unsigned long *src, int nbits); | 147 | extern void bitmap_copy_le(void *dst, const unsigned long *src, int nbits); |
| 147 | extern int bitmap_ord_to_pos(const unsigned long *bitmap, int n, int bits); | 148 | extern int bitmap_ord_to_pos(const unsigned long *bitmap, int n, int bits); |
| 149 | extern int bitmap_print_to_pagebuf(bool list, char *buf, | ||
| 150 | const unsigned long *maskp, int nmaskbits); | ||
| 148 | 151 | ||
| 149 | #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG)) | 152 | #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG)) |
| 150 | #define BITMAP_LAST_WORD_MASK(nbits) \ | 153 | #define BITMAP_LAST_WORD_MASK(nbits) \ |
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 0a9a6da21e74..b950e9d6008b 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h | |||
| @@ -803,6 +803,23 @@ static inline const struct cpumask *get_cpu_mask(unsigned int cpu) | |||
| 803 | } | 803 | } |
| 804 | #endif /* NR_CPUS > BITS_PER_LONG */ | 804 | #endif /* NR_CPUS > BITS_PER_LONG */ |
| 805 | 805 | ||
| 806 | /** | ||
| 807 | * cpumap_print_to_pagebuf - copies the cpumask into the buffer either | ||
| 808 | * as comma-separated list of cpus or hex values of cpumask | ||
| 809 | * @list: indicates whether the cpumap must be list | ||
| 810 | * @mask: the cpumask to copy | ||
| 811 | * @buf: the buffer to copy into | ||
| 812 | * | ||
| 813 | * Returns the length of the (null-terminated) @buf string, zero if | ||
| 814 | * nothing is copied. | ||
| 815 | */ | ||
| 816 | static inline ssize_t | ||
| 817 | cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask) | ||
| 818 | { | ||
| 819 | return bitmap_print_to_pagebuf(list, buf, cpumask_bits(mask), | ||
| 820 | nr_cpumask_bits); | ||
| 821 | } | ||
| 822 | |||
| 806 | /* | 823 | /* |
| 807 | * | 824 | * |
| 808 | * From here down, all obsolete. Use cpumask_ variants! | 825 | * From here down, all obsolete. Use cpumask_ variants! |
