aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2015-02-13 17:38:15 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-14 00:21:39 -0500
commit46385326cc1577587ed3e7432c2425cf6d3e4308 (patch)
treea4a87d47fb4ef5853c5c31236a272c22a9304caf
parentccbd59c1c104d6e42e949e2588563bfe25d9d98f (diff)
bitmap, cpumask, nodemask: remove dedicated formatting functions
Now that all bitmap formatting usages have been converted to '%*pb[l]', the separate formatting functions are unnecessary. The following functions are removed. * bitmap_scn[list]printf() * cpumask_scnprintf(), cpulist_scnprintf() * [__]nodemask_scnprintf(), [__]nodelist_scnprintf() * seq_bitmap[_list](), seq_cpumask[_list](), seq_nodemask[_list]() * seq_buf_bitmask() Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/seq_file.c32
-rw-r--r--include/linux/bitmap.h7
-rw-r--r--include/linux/cpumask.h31
-rw-r--r--include/linux/nodemask.h33
-rw-r--r--include/linux/seq_buf.h3
-rw-r--r--include/linux/seq_file.h25
-rw-r--r--lib/bitmap.c41
-rw-r--r--lib/seq_buf.c36
8 files changed, 7 insertions, 201 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c
index dbf3a59c86bb..555f82155be8 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -539,38 +539,6 @@ int seq_dentry(struct seq_file *m, struct dentry *dentry, const char *esc)
539 return res; 539 return res;
540} 540}
541 541
542int seq_bitmap(struct seq_file *m, const unsigned long *bits,
543 unsigned int nr_bits)
544{
545 if (m->count < m->size) {
546 int len = bitmap_scnprintf(m->buf + m->count,
547 m->size - m->count, bits, nr_bits);
548 if (m->count + len < m->size) {
549 m->count += len;
550 return 0;
551 }
552 }
553 seq_set_overflow(m);
554 return -1;
555}
556EXPORT_SYMBOL(seq_bitmap);
557
558int seq_bitmap_list(struct seq_file *m, const unsigned long *bits,
559 unsigned int nr_bits)
560{
561 if (m->count < m->size) {
562 int len = bitmap_scnlistprintf(m->buf + m->count,
563 m->size - m->count, bits, nr_bits);
564 if (m->count + len < m->size) {
565 m->count += len;
566 return 0;
567 }
568 }
569 seq_set_overflow(m);
570 return -1;
571}
572EXPORT_SYMBOL(seq_bitmap_list);
573
574static void *single_start(struct seq_file *p, loff_t *pos) 542static void *single_start(struct seq_file *p, loff_t *pos)
575{ 543{
576 return NULL + (*pos == 0); 544 return NULL + (*pos == 0);
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 5e7f75a6d7d0..dbfbf4990005 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -52,16 +52,13 @@
52 * bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit) 52 * bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit)
53 * bitmap_onto(dst, orig, relmap, nbits) *dst = orig relative to relmap 53 * bitmap_onto(dst, orig, relmap, nbits) *dst = orig relative to relmap
54 * bitmap_fold(dst, orig, sz, nbits) dst bits = orig bits mod sz 54 * bitmap_fold(dst, orig, sz, nbits) dst bits = orig bits mod sz
55 * bitmap_scnprintf(buf, len, src, nbits) Print bitmap src to buf
56 * bitmap_parse(buf, buflen, dst, nbits) Parse bitmap dst from kernel buf 55 * bitmap_parse(buf, buflen, dst, nbits) Parse bitmap dst from kernel buf
57 * bitmap_parse_user(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf 56 * bitmap_parse_user(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf
58 * bitmap_scnlistprintf(buf, len, src, nbits) Print bitmap src as list to buf
59 * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from kernel buf 57 * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from kernel buf
60 * bitmap_parselist_user(buf, dst, nbits) Parse bitmap dst from user buf 58 * bitmap_parselist_user(buf, dst, nbits) Parse bitmap dst from user buf
61 * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region 59 * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region
62 * bitmap_release_region(bitmap, pos, order) Free specified bit region 60 * bitmap_release_region(bitmap, pos, order) Free specified bit region
63 * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region 61 * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region
64 * bitmap_print_to_pagebuf(list, buf, mask, nbits) Print bitmap src as list/hex
65 */ 62 */
66 63
67/* 64/*
@@ -147,14 +144,10 @@ bitmap_find_next_zero_area(unsigned long *map,
147 align_mask, 0); 144 align_mask, 0);
148} 145}
149 146
150extern int bitmap_scnprintf(char *buf, unsigned int len,
151 const unsigned long *src, int nbits);
152extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user, 147extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user,
153 unsigned long *dst, int nbits); 148 unsigned long *dst, int nbits);
154extern int bitmap_parse_user(const char __user *ubuf, unsigned int ulen, 149extern int bitmap_parse_user(const char __user *ubuf, unsigned int ulen,
155 unsigned long *dst, int nbits); 150 unsigned long *dst, int nbits);
156extern int bitmap_scnlistprintf(char *buf, unsigned int len,
157 const unsigned long *src, int nbits);
158extern int bitmap_parselist(const char *buf, unsigned long *maskp, 151extern int bitmap_parselist(const char *buf, unsigned long *maskp,
159 int nmaskbits); 152 int nmaskbits);
160extern int bitmap_parselist_user(const char __user *ubuf, unsigned int ulen, 153extern int bitmap_parselist_user(const char __user *ubuf, unsigned int ulen,
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index a9b3d00915a0..086549a665e2 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -547,21 +547,6 @@ static inline void cpumask_copy(struct cpumask *dstp,
547#define cpumask_of(cpu) (get_cpu_mask(cpu)) 547#define cpumask_of(cpu) (get_cpu_mask(cpu))
548 548
549/** 549/**
550 * cpumask_scnprintf - print a cpumask into a string as comma-separated hex
551 * @buf: the buffer to sprintf into
552 * @len: the length of the buffer
553 * @srcp: the cpumask to print
554 *
555 * If len is zero, returns zero. Otherwise returns the length of the
556 * (nul-terminated) @buf string.
557 */
558static inline int cpumask_scnprintf(char *buf, int len,
559 const struct cpumask *srcp)
560{
561 return bitmap_scnprintf(buf, len, cpumask_bits(srcp), nr_cpu_ids);
562}
563
564/**
565 * cpumask_parse_user - extract a cpumask from a user string 550 * cpumask_parse_user - extract a cpumask from a user string
566 * @buf: the buffer to extract from 551 * @buf: the buffer to extract from
567 * @len: the length of the buffer 552 * @len: the length of the buffer
@@ -591,22 +576,6 @@ static inline int cpumask_parselist_user(const char __user *buf, int len,
591} 576}
592 577
593/** 578/**
594 * cpulist_scnprintf - print a cpumask into a string as comma-separated list
595 * @buf: the buffer to sprintf into
596 * @len: the length of the buffer
597 * @srcp: the cpumask to print
598 *
599 * If len is zero, returns zero. Otherwise returns the length of the
600 * (nul-terminated) @buf string.
601 */
602static inline int cpulist_scnprintf(char *buf, int len,
603 const struct cpumask *srcp)
604{
605 return bitmap_scnlistprintf(buf, len, cpumask_bits(srcp),
606 nr_cpu_ids);
607}
608
609/**
610 * cpumask_parse - extract a cpumask from from a string 579 * cpumask_parse - extract a cpumask from from a string
611 * @buf: the buffer to extract from 580 * @buf: the buffer to extract from
612 * @dstp: the cpumask to set. 581 * @dstp: the cpumask to set.
diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
index 10f8e556ba07..6e85889cf9ab 100644
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -8,14 +8,13 @@
8 * See detailed comments in the file linux/bitmap.h describing the 8 * See detailed comments in the file linux/bitmap.h describing the
9 * data type on which these nodemasks are based. 9 * data type on which these nodemasks are based.
10 * 10 *
11 * For details of nodemask_scnprintf() and nodemask_parse_user(), 11 * For details of nodemask_parse_user(), see bitmap_parse_user() in
12 * see bitmap_scnprintf() and bitmap_parse_user() in lib/bitmap.c. 12 * lib/bitmap.c. For details of nodelist_parse(), see bitmap_parselist(),
13 * For details of nodelist_scnprintf() and nodelist_parse(), see 13 * also in bitmap.c. For details of node_remap(), see bitmap_bitremap in
14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c. 14 * lib/bitmap.c. For details of nodes_remap(), see bitmap_remap in
15 * For details of node_remap(), see bitmap_bitremap in lib/bitmap.c. 15 * lib/bitmap.c. For details of nodes_onto(), see bitmap_onto in
16 * For details of nodes_remap(), see bitmap_remap in lib/bitmap.c. 16 * lib/bitmap.c. For details of nodes_fold(), see bitmap_fold in
17 * For details of nodes_onto(), see bitmap_onto in lib/bitmap.c. 17 * lib/bitmap.c.
18 * For details of nodes_fold(), see bitmap_fold in lib/bitmap.c.
19 * 18 *
20 * The available nodemask operations are: 19 * The available nodemask operations are:
21 * 20 *
@@ -52,9 +51,7 @@
52 * NODE_MASK_NONE Initializer - no bits set 51 * NODE_MASK_NONE Initializer - no bits set
53 * unsigned long *nodes_addr(mask) Array of unsigned long's in mask 52 * unsigned long *nodes_addr(mask) Array of unsigned long's in mask
54 * 53 *
55 * int nodemask_scnprintf(buf, len, mask) Format nodemask for printing
56 * int nodemask_parse_user(ubuf, ulen, mask) Parse ascii string as nodemask 54 * int nodemask_parse_user(ubuf, ulen, mask) Parse ascii string as nodemask
57 * int nodelist_scnprintf(buf, len, mask) Format nodemask as list for printing
58 * int nodelist_parse(buf, map) Parse ascii string as nodelist 55 * int nodelist_parse(buf, map) Parse ascii string as nodelist
59 * int node_remap(oldbit, old, new) newbit = map(old, new)(oldbit) 56 * int node_remap(oldbit, old, new) newbit = map(old, new)(oldbit)
60 * void nodes_remap(dst, src, old, new) *dst = map(old, new)(src) 57 * void nodes_remap(dst, src, old, new) *dst = map(old, new)(src)
@@ -312,14 +309,6 @@ static inline int __first_unset_node(const nodemask_t *maskp)
312 309
313#define nodes_addr(src) ((src).bits) 310#define nodes_addr(src) ((src).bits)
314 311
315#define nodemask_scnprintf(buf, len, src) \
316 __nodemask_scnprintf((buf), (len), &(src), MAX_NUMNODES)
317static inline int __nodemask_scnprintf(char *buf, int len,
318 const nodemask_t *srcp, int nbits)
319{
320 return bitmap_scnprintf(buf, len, srcp->bits, nbits);
321}
322
323#define nodemask_parse_user(ubuf, ulen, dst) \ 312#define nodemask_parse_user(ubuf, ulen, dst) \
324 __nodemask_parse_user((ubuf), (ulen), &(dst), MAX_NUMNODES) 313 __nodemask_parse_user((ubuf), (ulen), &(dst), MAX_NUMNODES)
325static inline int __nodemask_parse_user(const char __user *buf, int len, 314static inline int __nodemask_parse_user(const char __user *buf, int len,
@@ -328,14 +317,6 @@ static inline int __nodemask_parse_user(const char __user *buf, int len,
328 return bitmap_parse_user(buf, len, dstp->bits, nbits); 317 return bitmap_parse_user(buf, len, dstp->bits, nbits);
329} 318}
330 319
331#define nodelist_scnprintf(buf, len, src) \
332 __nodelist_scnprintf((buf), (len), &(src), MAX_NUMNODES)
333static inline int __nodelist_scnprintf(char *buf, int len,
334 const nodemask_t *srcp, int nbits)
335{
336 return bitmap_scnlistprintf(buf, len, srcp->bits, nbits);
337}
338
339#define nodelist_parse(buf, dst) __nodelist_parse((buf), &(dst), MAX_NUMNODES) 320#define nodelist_parse(buf, dst) __nodelist_parse((buf), &(dst), MAX_NUMNODES)
340static inline int __nodelist_parse(const char *buf, nodemask_t *dstp, int nbits) 321static inline int __nodelist_parse(const char *buf, nodemask_t *dstp, int nbits)
341{ 322{
diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h
index 9aafe0e24c68..fb7eb9ccb1cd 100644
--- a/include/linux/seq_buf.h
+++ b/include/linux/seq_buf.h
@@ -125,9 +125,6 @@ extern int seq_buf_putmem_hex(struct seq_buf *s, const void *mem,
125 unsigned int len); 125 unsigned int len);
126extern int seq_buf_path(struct seq_buf *s, const struct path *path, const char *esc); 126extern int seq_buf_path(struct seq_buf *s, const struct path *path, const char *esc);
127 127
128extern int seq_buf_bitmask(struct seq_buf *s, const unsigned long *maskp,
129 int nmaskbits);
130
131#ifdef CONFIG_BINARY_PRINTF 128#ifdef CONFIG_BINARY_PRINTF
132extern int 129extern int
133seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary); 130seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary);
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index cf6a9daaaf6d..afbb1fd77c77 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -126,31 +126,6 @@ int seq_path(struct seq_file *, const struct path *, const char *);
126int seq_dentry(struct seq_file *, struct dentry *, const char *); 126int seq_dentry(struct seq_file *, struct dentry *, const char *);
127int seq_path_root(struct seq_file *m, const struct path *path, 127int seq_path_root(struct seq_file *m, const struct path *path,
128 const struct path *root, const char *esc); 128 const struct path *root, const char *esc);
129int seq_bitmap(struct seq_file *m, const unsigned long *bits,
130 unsigned int nr_bits);
131static inline int seq_cpumask(struct seq_file *m, const struct cpumask *mask)
132{
133 return seq_bitmap(m, cpumask_bits(mask), nr_cpu_ids);
134}
135
136static inline int seq_nodemask(struct seq_file *m, nodemask_t *mask)
137{
138 return seq_bitmap(m, mask->bits, MAX_NUMNODES);
139}
140
141int seq_bitmap_list(struct seq_file *m, const unsigned long *bits,
142 unsigned int nr_bits);
143
144static inline int seq_cpumask_list(struct seq_file *m,
145 const struct cpumask *mask)
146{
147 return seq_bitmap_list(m, cpumask_bits(mask), nr_cpu_ids);
148}
149
150static inline int seq_nodemask_list(struct seq_file *m, nodemask_t *mask)
151{
152 return seq_bitmap_list(m, mask->bits, MAX_NUMNODES);
153}
154 129
155int single_open(struct file *, int (*)(struct seq_file *, void *), void *); 130int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
156int single_open_size(struct file *, int (*)(struct seq_file *, void *), void *, size_t); 131int single_open_size(struct file *, int (*)(struct seq_file *, void *), void *, size_t);
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 088adbdcbad9..d456f4c15a9f 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -370,24 +370,6 @@ EXPORT_SYMBOL(bitmap_find_next_zero_area_off);
370#define BASEDEC 10 /* fancier cpuset lists input in decimal */ 370#define BASEDEC 10 /* fancier cpuset lists input in decimal */
371 371
372/** 372/**
373 * bitmap_scnprintf - convert bitmap to an ASCII hex string.
374 * @buf: byte buffer into which string is placed
375 * @buflen: reserved size of @buf, in bytes
376 * @maskp: pointer to bitmap to convert
377 * @nmaskbits: size of bitmap, in bits
378 *
379 * Exactly @nmaskbits bits are displayed. Hex digits are grouped into
380 * comma-separated sets of eight digits per set. Returns the number of
381 * characters which were written to *buf, excluding the trailing \0.
382 */
383int bitmap_scnprintf(char *buf, unsigned int buflen,
384 const unsigned long *maskp, int nmaskbits)
385{
386 return scnprintf(buf, buflen, "%*pb", nmaskbits, maskp);
387}
388EXPORT_SYMBOL(bitmap_scnprintf);
389
390/**
391 * __bitmap_parse - convert an ASCII hex string into a bitmap. 373 * __bitmap_parse - convert an ASCII hex string into a bitmap.
392 * @buf: pointer to buffer containing string. 374 * @buf: pointer to buffer containing string.
393 * @buflen: buffer size in bytes. If string is smaller than this 375 * @buflen: buffer size in bytes. If string is smaller than this
@@ -501,29 +483,6 @@ int bitmap_parse_user(const char __user *ubuf,
501EXPORT_SYMBOL(bitmap_parse_user); 483EXPORT_SYMBOL(bitmap_parse_user);
502 484
503/** 485/**
504 * bitmap_scnlistprintf - convert bitmap to list format ASCII string
505 * @buf: byte buffer into which string is placed
506 * @buflen: reserved size of @buf, in bytes
507 * @maskp: pointer to bitmap to convert
508 * @nmaskbits: size of bitmap, in bits
509 *
510 * Output format is a comma-separated list of decimal numbers and
511 * ranges. Consecutively set bits are shown as two hyphen-separated
512 * decimal numbers, the smallest and largest bit numbers set in
513 * the range. Output format is compatible with the format
514 * accepted as input by bitmap_parselist().
515 *
516 * The return value is the number of characters which were written to *buf
517 * excluding the trailing '\0', as per ISO C99's scnprintf.
518 */
519int bitmap_scnlistprintf(char *buf, unsigned int buflen,
520 const unsigned long *maskp, int nmaskbits)
521{
522 return scnprintf(buf, buflen, "%*pbl", nmaskbits, maskp);
523}
524EXPORT_SYMBOL(bitmap_scnlistprintf);
525
526/**
527 * bitmap_print_to_pagebuf - convert bitmap to list or hex format ASCII string 486 * bitmap_print_to_pagebuf - convert bitmap to list or hex format ASCII string
528 * @list: indicates whether the bitmap must be list 487 * @list: indicates whether the bitmap must be list
529 * @buf: page aligned buffer into which string is placed 488 * @buf: page aligned buffer into which string is placed
diff --git a/lib/seq_buf.c b/lib/seq_buf.c
index 4eedfedb9e31..88c0854bd752 100644
--- a/lib/seq_buf.c
+++ b/lib/seq_buf.c
@@ -91,42 +91,6 @@ int seq_buf_printf(struct seq_buf *s, const char *fmt, ...)
91 return ret; 91 return ret;
92} 92}
93 93
94/**
95 * seq_buf_bitmask - write a bitmask array in its ASCII representation
96 * @s: seq_buf descriptor
97 * @maskp: points to an array of unsigned longs that represent a bitmask
98 * @nmaskbits: The number of bits that are valid in @maskp
99 *
100 * Writes a ASCII representation of a bitmask string into @s.
101 *
102 * Returns zero on success, -1 on overflow.
103 */
104int seq_buf_bitmask(struct seq_buf *s, const unsigned long *maskp,
105 int nmaskbits)
106{
107 unsigned int len = seq_buf_buffer_left(s);
108 int ret;
109
110 WARN_ON(s->size == 0);
111
112 /*
113 * Note, because bitmap_scnprintf() only returns the number of bytes
114 * written and not the number that would be written, we use the last
115 * byte of the buffer to let us know if we overflowed. There's a small
116 * chance that the bitmap could have fit exactly inside the buffer, but
117 * it's not that critical if that does happen.
118 */
119 if (len > 1) {
120 ret = bitmap_scnprintf(s->buffer + s->len, len, maskp, nmaskbits);
121 if (ret < len) {
122 s->len += ret;
123 return 0;
124 }
125 }
126 seq_buf_set_overflow(s);
127 return -1;
128}
129
130#ifdef CONFIG_BINARY_PRINTF 94#ifdef CONFIG_BINARY_PRINTF
131/** 95/**
132 * seq_buf_bprintf - Write the printf string from binary arguments 96 * seq_buf_bprintf - Write the printf string from binary arguments