Skip to content

Commit 4638532

Browse files
htejuntorvalds
authored andcommitted
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 <[email protected]> Cc: Rusty Russell <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent ccbd59c commit 4638532

File tree

8 files changed

+7
-201
lines changed

8 files changed

+7
-201
lines changed

fs/seq_file.c

-32
Original file line numberDiff line numberDiff line change
@@ -539,38 +539,6 @@ int seq_dentry(struct seq_file *m, struct dentry *dentry, const char *esc)
539539
return res;
540540
}
541541

542-
int 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-
}
556-
EXPORT_SYMBOL(seq_bitmap);
557-
558-
int 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-
}
572-
EXPORT_SYMBOL(seq_bitmap_list);
573-
574542
static void *single_start(struct seq_file *p, loff_t *pos)
575543
{
576544
return NULL + (*pos == 0);

include/linux/bitmap.h

-7
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,13 @@
5252
* bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit)
5353
* bitmap_onto(dst, orig, relmap, nbits) *dst = orig relative to relmap
5454
* bitmap_fold(dst, orig, sz, nbits) dst bits = orig bits mod sz
55-
* bitmap_scnprintf(buf, len, src, nbits) Print bitmap src to buf
5655
* bitmap_parse(buf, buflen, dst, nbits) Parse bitmap dst from kernel buf
5756
* 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
5957
* bitmap_parselist(buf, dst, nbits) Parse bitmap dst from kernel buf
6058
* bitmap_parselist_user(buf, dst, nbits) Parse bitmap dst from user buf
6159
* bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region
6260
* bitmap_release_region(bitmap, pos, order) Free specified bit region
6361
* 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
6562
*/
6663

6764
/*
@@ -147,14 +144,10 @@ bitmap_find_next_zero_area(unsigned long *map,
147144
align_mask, 0);
148145
}
149146

150-
extern int bitmap_scnprintf(char *buf, unsigned int len,
151-
const unsigned long *src, int nbits);
152147
extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user,
153148
unsigned long *dst, int nbits);
154149
extern int bitmap_parse_user(const char __user *ubuf, unsigned int ulen,
155150
unsigned long *dst, int nbits);
156-
extern int bitmap_scnlistprintf(char *buf, unsigned int len,
157-
const unsigned long *src, int nbits);
158151
extern int bitmap_parselist(const char *buf, unsigned long *maskp,
159152
int nmaskbits);
160153
extern int bitmap_parselist_user(const char __user *ubuf, unsigned int ulen,

include/linux/cpumask.h

-31
Original file line numberDiff line numberDiff line change
@@ -546,21 +546,6 @@ static inline void cpumask_copy(struct cpumask *dstp,
546546
*/
547547
#define cpumask_of(cpu) (get_cpu_mask(cpu))
548548

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-
*/
558-
static 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-
564549
/**
565550
* cpumask_parse_user - extract a cpumask from a user string
566551
* @buf: the buffer to extract from
@@ -590,22 +575,6 @@ static inline int cpumask_parselist_user(const char __user *buf, int len,
590575
nr_cpu_ids);
591576
}
592577

593-
/**
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-
*/
602-
static 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-
609578
/**
610579
* cpumask_parse - extract a cpumask from from a string
611580
* @buf: the buffer to extract from

include/linux/nodemask.h

+7-26
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
* See detailed comments in the file linux/bitmap.h describing the
99
* data type on which these nodemasks are based.
1010
*
11-
* For details of nodemask_scnprintf() and nodemask_parse_user(),
12-
* see bitmap_scnprintf() and bitmap_parse_user() in lib/bitmap.c.
13-
* For details of nodelist_scnprintf() and nodelist_parse(), see
14-
* bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c.
15-
* For details of node_remap(), see bitmap_bitremap in lib/bitmap.c.
16-
* For details of nodes_remap(), see bitmap_remap in lib/bitmap.c.
17-
* For details of nodes_onto(), see bitmap_onto in lib/bitmap.c.
18-
* For details of nodes_fold(), see bitmap_fold in lib/bitmap.c.
11+
* For details of nodemask_parse_user(), see bitmap_parse_user() in
12+
* lib/bitmap.c. For details of nodelist_parse(), see bitmap_parselist(),
13+
* also in bitmap.c. For details of node_remap(), see bitmap_bitremap in
14+
* lib/bitmap.c. For details of nodes_remap(), see bitmap_remap in
15+
* lib/bitmap.c. For details of nodes_onto(), see bitmap_onto in
16+
* lib/bitmap.c. For details of nodes_fold(), see bitmap_fold in
17+
* lib/bitmap.c.
1918
*
2019
* The available nodemask operations are:
2120
*
@@ -52,9 +51,7 @@
5251
* NODE_MASK_NONE Initializer - no bits set
5352
* unsigned long *nodes_addr(mask) Array of unsigned long's in mask
5453
*
55-
* int nodemask_scnprintf(buf, len, mask) Format nodemask for printing
5654
* 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
5855
* int nodelist_parse(buf, map) Parse ascii string as nodelist
5956
* int node_remap(oldbit, old, new) newbit = map(old, new)(oldbit)
6057
* 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)
312309

313310
#define nodes_addr(src) ((src).bits)
314311

315-
#define nodemask_scnprintf(buf, len, src) \
316-
__nodemask_scnprintf((buf), (len), &(src), MAX_NUMNODES)
317-
static 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-
323312
#define nodemask_parse_user(ubuf, ulen, dst) \
324313
__nodemask_parse_user((ubuf), (ulen), &(dst), MAX_NUMNODES)
325314
static 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,
328317
return bitmap_parse_user(buf, len, dstp->bits, nbits);
329318
}
330319

331-
#define nodelist_scnprintf(buf, len, src) \
332-
__nodelist_scnprintf((buf), (len), &(src), MAX_NUMNODES)
333-
static 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-
339320
#define nodelist_parse(buf, dst) __nodelist_parse((buf), &(dst), MAX_NUMNODES)
340321
static inline int __nodelist_parse(const char *buf, nodemask_t *dstp, int nbits)
341322
{

include/linux/seq_buf.h

-3
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ extern int seq_buf_putmem_hex(struct seq_buf *s, const void *mem,
125125
unsigned int len);
126126
extern int seq_buf_path(struct seq_buf *s, const struct path *path, const char *esc);
127127

128-
extern int seq_buf_bitmask(struct seq_buf *s, const unsigned long *maskp,
129-
int nmaskbits);
130-
131128
#ifdef CONFIG_BINARY_PRINTF
132129
extern int
133130
seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary);

include/linux/seq_file.h

-25
Original file line numberDiff line numberDiff line change
@@ -126,31 +126,6 @@ int seq_path(struct seq_file *, const struct path *, const char *);
126126
int seq_dentry(struct seq_file *, struct dentry *, const char *);
127127
int seq_path_root(struct seq_file *m, const struct path *path,
128128
const struct path *root, const char *esc);
129-
int seq_bitmap(struct seq_file *m, const unsigned long *bits,
130-
unsigned int nr_bits);
131-
static 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-
136-
static inline int seq_nodemask(struct seq_file *m, nodemask_t *mask)
137-
{
138-
return seq_bitmap(m, mask->bits, MAX_NUMNODES);
139-
}
140-
141-
int seq_bitmap_list(struct seq_file *m, const unsigned long *bits,
142-
unsigned int nr_bits);
143-
144-
static 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-
150-
static inline int seq_nodemask_list(struct seq_file *m, nodemask_t *mask)
151-
{
152-
return seq_bitmap_list(m, mask->bits, MAX_NUMNODES);
153-
}
154129

155130
int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
156131
int single_open_size(struct file *, int (*)(struct seq_file *, void *), void *, size_t);

lib/bitmap.c

-41
Original file line numberDiff line numberDiff line change
@@ -369,24 +369,6 @@ EXPORT_SYMBOL(bitmap_find_next_zero_area_off);
369369
#define nbits_to_hold_value(val) fls(val)
370370
#define BASEDEC 10 /* fancier cpuset lists input in decimal */
371371

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-
*/
383-
int bitmap_scnprintf(char *buf, unsigned int buflen,
384-
const unsigned long *maskp, int nmaskbits)
385-
{
386-
return scnprintf(buf, buflen, "%*pb", nmaskbits, maskp);
387-
}
388-
EXPORT_SYMBOL(bitmap_scnprintf);
389-
390372
/**
391373
* __bitmap_parse - convert an ASCII hex string into a bitmap.
392374
* @buf: pointer to buffer containing string.
@@ -500,29 +482,6 @@ int bitmap_parse_user(const char __user *ubuf,
500482
}
501483
EXPORT_SYMBOL(bitmap_parse_user);
502484

503-
/**
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-
*/
519-
int bitmap_scnlistprintf(char *buf, unsigned int buflen,
520-
const unsigned long *maskp, int nmaskbits)
521-
{
522-
return scnprintf(buf, buflen, "%*pbl", nmaskbits, maskp);
523-
}
524-
EXPORT_SYMBOL(bitmap_scnlistprintf);
525-
526485
/**
527486
* bitmap_print_to_pagebuf - convert bitmap to list or hex format ASCII string
528487
* @list: indicates whether the bitmap must be list

lib/seq_buf.c

-36
Original file line numberDiff line numberDiff line change
@@ -91,42 +91,6 @@ int seq_buf_printf(struct seq_buf *s, const char *fmt, ...)
9191
return ret;
9292
}
9393

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-
*/
104-
int 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-
13094
#ifdef CONFIG_BINARY_PRINTF
13195
/**
13296
* seq_buf_bprintf - Write the printf string from binary arguments

0 commit comments

Comments
 (0)