@@ -60,6 +60,7 @@
* bitmap_find_free_region(bitmap, bits, order) Find and
allocate bit region
* bitmap_release_region(bitmap, pos, order) Free specified bit region
* bitmap_allocate_region(bitmap, pos, order) Allocate specified bit
region
+ * bitmap_copy_to_pagebuf(list, src, buf) Print bitmap src as
list/hex to buf
*/
/*
@@ -145,6 +146,8 @@ extern void bitmap_release_region(unsigned long
*bitmap, unsigned int pos, int o
extern int bitmap_allocate_region(unsigned long *bitmap, unsigned int
pos, int order);
extern void bitmap_copy_le(void *dst, const unsigned long *src, int
nbits);
extern int bitmap_ord_to_pos(const unsigned long *bitmap, int n, int
bits);
+extern int bitmap_copy_to_pagebuf(bool list, const unsigned long *maskp,
+ char *buf);
#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG))
#define BITMAP_LAST_WORD_MASK(nbits) \
@@ -807,16 +807,7 @@ static inline const struct cpumask
*get_cpu_mask(unsigned int cpu)
static inline ssize_t
cpumap_copy_to_buf(bool list, const struct cpumask *mask, char *buf)
{
- ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf - 2;
- int n = 0;
-
- if (len > 1) {
- n = list ? cpulist_scnprintf(buf, len, mask) :
- cpumask_scnprintf(buf, len, mask);
- buf[n++] = '\n';
- buf[n] = '\0';
- }
- return n;
+ return bitmap_copy_to_pagebuf(list, cpumask_bits(mask), buf);
}
sudeep@e103737-lin:~/work/power/kernel$ git diff > /tmp/log
sudeep@e103737-lin:~/work/power/kernel$ cat /tmp/log
@@ -60,6 +60,7 @@
* bitmap_find_free_region(bitmap, bits, order) Find and allocate bit
region
* bitmap_release_region(bitmap, pos, order) Free specified bit region
* bitmap_allocate_region(bitmap, pos, order) Allocate specified bit
region
+ * bitmap_copy_to_pagebuf(list, src, buf) Print bitmap src as list/hex
to buf
*/
/*
@@ -145,6 +146,8 @@ extern void bitmap_release_region(unsigned long
*bitmap, unsigned int pos, int o
extern int bitmap_allocate_region(unsigned long *bitmap, unsigned int
pos, int order);
extern void bitmap_copy_le(void *dst, const unsigned long *src, int
nbits);
extern int bitmap_ord_to_pos(const unsigned long *bitmap, int n, int
bits);
+extern int bitmap_copy_to_pagebuf(bool list, const unsigned long *maskp,
+ char *buf);
#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG))
#define BITMAP_LAST_WORD_MASK(nbits) \
@@ -807,16 +807,7 @@ static inline const struct cpumask
*get_cpu_mask(unsigned int cpu)
static inline ssize_t
cpumap_copy_to_buf(bool list, const struct cpumask *mask, char *buf)
{
- ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf - 2;
- int n = 0;
-
- if (len > 1) {
- n = list ? cpulist_scnprintf(buf, len, mask) :
- cpumask_scnprintf(buf, len, mask);
- buf[n++] = '\n';
- buf[n] = '\0';
- }
- return n;
+ return bitmap_copy_to_pagebuf(list, cpumask_bits(mask), buf);
}
/*
@@ -580,6 +580,32 @@ int bitmap_scnlistprintf(char *buf, unsigned int
buflen,
EXPORT_SYMBOL(bitmap_scnlistprintf);
/**
+ * bitmap_copy_to_pagebuf - convert bitmap to list or hex format ASCII
string
+ * @list: indicates whether the bitmap must be list
+ * @maskp: pointer to bitmap to convert
+ * @buf: page aligned buffer into which string is placed
+ *
+ * Output format is a comma-separated list of decimal numbers and
+ * ranges if list is specified or hex digits grouped into comma-separated
+ * sets of 8 digits/set. Returns the number of characters written to buf.
+ */
+int bitmap_copy_to_pagebuf(bool list, const unsigned long *maskp, char
*buf)
+{
+ ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf - 2;
+ int n = 0;
+
+ if (len > 1) {
+ n = list ?
+ bitmap_scnlistprintf(buf, len, maskp, nr_cpumask_bits) :
+ bitmap_scnprintf(buf, len, maskp, nr_cpumask_bits);
+ buf[n++] = '\n';
+ buf[n] = '\0';
+ }
+ return n;
+}
+EXPORT_SYMBOL(bitmap_copy_to_pagebuf);
+
+/**