diff options
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 969ae8fbc85b..324ea9eab8c1 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 | /* |
| @@ -586,6 +588,33 @@ int bitmap_scnlistprintf(char *buf, unsigned int buflen, | |||
| 586 | EXPORT_SYMBOL(bitmap_scnlistprintf); | 588 | EXPORT_SYMBOL(bitmap_scnlistprintf); |
| 587 | 589 | ||
| 588 | /** | 590 | /** |
| 591 | * bitmap_print_to_pagebuf - convert bitmap to list or hex format ASCII string | ||
| 592 | * @list: indicates whether the bitmap must be list | ||
| 593 | * @buf: page aligned buffer into which string is placed | ||
| 594 | * @maskp: pointer to bitmap to convert | ||
| 595 | * @nmaskbits: size of bitmap, in bits | ||
| 596 | * | ||
| 597 | * Output format is a comma-separated list of decimal numbers and | ||
| 598 | * ranges if list is specified or hex digits grouped into comma-separated | ||
| 599 | * sets of 8 digits/set. Returns the number of characters written to buf. | ||
| 600 | */ | ||
| 601 | int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp, | ||
| 602 | int nmaskbits) | ||
| 603 | { | ||
| 604 | ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf - 2; | ||
| 605 | int n = 0; | ||
| 606 | |||
| 607 | if (len > 1) { | ||
| 608 | n = list ? bitmap_scnlistprintf(buf, len, maskp, nmaskbits) : | ||
| 609 | bitmap_scnprintf(buf, len, maskp, nmaskbits); | ||
| 610 | buf[n++] = '\n'; | ||
| 611 | buf[n] = '\0'; | ||
| 612 | } | ||
| 613 | return n; | ||
| 614 | } | ||
| 615 | EXPORT_SYMBOL(bitmap_print_to_pagebuf); | ||
| 616 | |||
| 617 | /** | ||
| 589 | * __bitmap_parselist - convert list format ASCII string to bitmap | 618 | * __bitmap_parselist - convert list format ASCII string to bitmap |
| 590 | * @buf: read nul-terminated user string from this buffer | 619 | * @buf: read nul-terminated user string from this buffer |
| 591 | * @buflen: buffer size in bytes. If string is smaller than this | 620 | * @buflen: buffer size in bytes. If string is smaller than this |
