aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/bitmap.c29
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,
584EXPORT_SYMBOL(bitmap_scnlistprintf); 586EXPORT_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 */
599int 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}
613EXPORT_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