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 /lib/bitmap.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 'lib/bitmap.c')
-rw-r--r-- | lib/bitmap.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index b499ab6ada29..5bc7a1128fe8 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
@@ -12,6 +12,8 @@ | |||
12 | #include <linux/bitmap.h> | 12 | #include <linux/bitmap.h> |
13 | #include <linux/bitops.h> | 13 | #include <linux/bitops.h> |
14 | #include <linux/bug.h> | 14 | #include <linux/bug.h> |
15 | |||
16 | #include <asm/page.h> | ||
15 | #include <asm/uaccess.h> | 17 | #include <asm/uaccess.h> |
16 | 18 | ||
17 | /* | 19 | /* |
@@ -584,6 +586,33 @@ int bitmap_scnlistprintf(char *buf, unsigned int buflen, | |||
584 | EXPORT_SYMBOL(bitmap_scnlistprintf); | 586 | EXPORT_SYMBOL(bitmap_scnlistprintf); |
585 | 587 | ||
586 | /** | 588 | /** |
589 | * bitmap_print_to_pagebuf - convert bitmap to list or hex format ASCII string | ||
590 | * @list: indicates whether the bitmap must be list | ||
591 | * @buf: page aligned buffer into which string is placed | ||
592 | * @maskp: pointer to bitmap to convert | ||
593 | * @nmaskbits: size of bitmap, in bits | ||
594 | * | ||
595 | * Output format is a comma-separated list of decimal numbers and | ||
596 | * ranges if list is specified or hex digits grouped into comma-separated | ||
597 | * sets of 8 digits/set. Returns the number of characters written to buf. | ||
598 | */ | ||
599 | int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp, | ||
600 | int nmaskbits) | ||
601 | { | ||
602 | ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf - 2; | ||
603 | int n = 0; | ||
604 | |||
605 | if (len > 1) { | ||
606 | n = list ? bitmap_scnlistprintf(buf, len, maskp, nmaskbits) : | ||
607 | bitmap_scnprintf(buf, len, maskp, nmaskbits); | ||
608 | buf[n++] = '\n'; | ||
609 | buf[n] = '\0'; | ||
610 | } | ||
611 | return n; | ||
612 | } | ||
613 | EXPORT_SYMBOL(bitmap_print_to_pagebuf); | ||
614 | |||
615 | /** | ||
587 | * __bitmap_parselist - convert list format ASCII string to bitmap | 616 | * __bitmap_parselist - convert list format ASCII string to bitmap |
588 | * @buf: read nul-terminated user string from this buffer | 617 | * @buf: read nul-terminated user string from this buffer |
589 | * @buflen: buffer size in bytes. If string is smaller than this | 618 | * @buflen: buffer size in bytes. If string is smaller than this |