Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Tejun Heo and committed by
Linus Torvalds
46385326 ccbd59c1

+7 -201
-32
fs/seq_file.c
··· 539 539 return res; 540 540 } 541 541 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 - 574 542 static void *single_start(struct seq_file *p, loff_t *pos) 575 543 { 576 544 return NULL + (*pos == 0);
-7
include/linux/bitmap.h
··· 52 52 * bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit) 53 53 * bitmap_onto(dst, orig, relmap, nbits) *dst = orig relative to relmap 54 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 55 * bitmap_parse(buf, buflen, dst, nbits) Parse bitmap dst from kernel buf 57 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 57 * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from kernel buf 60 58 * bitmap_parselist_user(buf, dst, nbits) Parse bitmap dst from user buf 61 59 * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region 62 60 * bitmap_release_region(bitmap, pos, order) Free specified bit region 63 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 /* ··· 144 147 align_mask, 0); 145 148 } 146 149 147 - extern int bitmap_scnprintf(char *buf, unsigned int len, 148 - const unsigned long *src, int nbits); 149 150 extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user, 150 151 unsigned long *dst, int nbits); 151 152 extern int bitmap_parse_user(const char __user *ubuf, unsigned int ulen, 152 153 unsigned long *dst, int nbits); 153 - extern int bitmap_scnlistprintf(char *buf, unsigned int len, 154 - const unsigned long *src, int nbits); 155 154 extern int bitmap_parselist(const char *buf, unsigned long *maskp, 156 155 int nmaskbits); 157 156 extern int bitmap_parselist_user(const char __user *ubuf, unsigned int ulen,
-31
include/linux/cpumask.h
··· 547 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 - */ 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 - 564 - /** 565 550 * cpumask_parse_user - extract a cpumask from a user string 566 551 * @buf: the buffer to extract from 567 552 * @len: the length of the buffer ··· 573 588 { 574 589 return bitmap_parselist_user(buf, len, cpumask_bits(dstp), 575 590 nr_cpu_ids); 576 - } 577 - 578 - /** 579 - * cpulist_scnprintf - print a cpumask into a string as comma-separated list 580 - * @buf: the buffer to sprintf into 581 - * @len: the length of the buffer 582 - * @srcp: the cpumask to print 583 - * 584 - * If len is zero, returns zero. Otherwise returns the length of the 585 - * (nul-terminated) @buf string. 586 - */ 587 - static inline int cpulist_scnprintf(char *buf, int len, 588 - const struct cpumask *srcp) 589 - { 590 - return bitmap_scnlistprintf(buf, len, cpumask_bits(srcp), 591 - nr_cpu_ids); 592 591 } 593 592 594 593 /**
+7 -26
include/linux/nodemask.h
··· 8 8 * See detailed comments in the file linux/bitmap.h describing the 9 9 * data type on which these nodemasks are based. 10 10 * 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. 19 18 * 20 19 * The available nodemask operations are: 21 20 * ··· 51 52 * NODE_MASK_NONE Initializer - no bits set 52 53 * unsigned long *nodes_addr(mask) Array of unsigned long's in mask 53 54 * 54 - * int nodemask_scnprintf(buf, len, mask) Format nodemask for printing 55 55 * int nodemask_parse_user(ubuf, ulen, mask) Parse ascii string as nodemask 56 - * int nodelist_scnprintf(buf, len, mask) Format nodemask as list for printing 57 56 * int nodelist_parse(buf, map) Parse ascii string as nodelist 58 57 * int node_remap(oldbit, old, new) newbit = map(old, new)(oldbit) 59 58 * void nodes_remap(dst, src, old, new) *dst = map(old, new)(src) ··· 309 312 310 313 #define nodes_addr(src) ((src).bits) 311 314 312 - #define nodemask_scnprintf(buf, len, src) \ 313 - __nodemask_scnprintf((buf), (len), &(src), MAX_NUMNODES) 314 - static inline int __nodemask_scnprintf(char *buf, int len, 315 - const nodemask_t *srcp, int nbits) 316 - { 317 - return bitmap_scnprintf(buf, len, srcp->bits, nbits); 318 - } 319 - 320 315 #define nodemask_parse_user(ubuf, ulen, dst) \ 321 316 __nodemask_parse_user((ubuf), (ulen), &(dst), MAX_NUMNODES) 322 317 static inline int __nodemask_parse_user(const char __user *buf, int len, 323 318 nodemask_t *dstp, int nbits) 324 319 { 325 320 return bitmap_parse_user(buf, len, dstp->bits, nbits); 326 - } 327 - 328 - #define nodelist_scnprintf(buf, len, src) \ 329 - __nodelist_scnprintf((buf), (len), &(src), MAX_NUMNODES) 330 - static inline int __nodelist_scnprintf(char *buf, int len, 331 - const nodemask_t *srcp, int nbits) 332 - { 333 - return bitmap_scnlistprintf(buf, len, srcp->bits, nbits); 334 321 } 335 322 336 323 #define nodelist_parse(buf, dst) __nodelist_parse((buf), &(dst), MAX_NUMNODES)
-3
include/linux/seq_buf.h
··· 125 125 unsigned int len); 126 126 extern int seq_buf_path(struct seq_buf *s, const struct path *path, const char *esc); 127 127 128 - extern int seq_buf_bitmask(struct seq_buf *s, const unsigned long *maskp, 129 - int nmaskbits); 130 - 131 128 #ifdef CONFIG_BINARY_PRINTF 132 129 extern int 133 130 seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary);
-25
include/linux/seq_file.h
··· 126 126 int seq_dentry(struct seq_file *, struct dentry *, const char *); 127 127 int seq_path_root(struct seq_file *m, const struct path *path, 128 128 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 - } 154 129 155 130 int single_open(struct file *, int (*)(struct seq_file *, void *), void *); 156 131 int single_open_size(struct file *, int (*)(struct seq_file *, void *), void *, size_t);
-41
lib/bitmap.c
··· 370 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 - */ 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 - 390 - /** 391 373 * __bitmap_parse - convert an ASCII hex string into a bitmap. 392 374 * @buf: pointer to buffer containing string. 393 375 * @buflen: buffer size in bytes. If string is smaller than this ··· 481 499 482 500 } 483 501 EXPORT_SYMBOL(bitmap_parse_user); 484 - 485 - /** 486 - * bitmap_scnlistprintf - convert bitmap to list format ASCII string 487 - * @buf: byte buffer into which string is placed 488 - * @buflen: reserved size of @buf, in bytes 489 - * @maskp: pointer to bitmap to convert 490 - * @nmaskbits: size of bitmap, in bits 491 - * 492 - * Output format is a comma-separated list of decimal numbers and 493 - * ranges. Consecutively set bits are shown as two hyphen-separated 494 - * decimal numbers, the smallest and largest bit numbers set in 495 - * the range. Output format is compatible with the format 496 - * accepted as input by bitmap_parselist(). 497 - * 498 - * The return value is the number of characters which were written to *buf 499 - * excluding the trailing '\0', as per ISO C99's scnprintf. 500 - */ 501 - int bitmap_scnlistprintf(char *buf, unsigned int buflen, 502 - const unsigned long *maskp, int nmaskbits) 503 - { 504 - return scnprintf(buf, buflen, "%*pbl", nmaskbits, maskp); 505 - } 506 - EXPORT_SYMBOL(bitmap_scnlistprintf); 507 502 508 503 /** 509 504 * bitmap_print_to_pagebuf - convert bitmap to list or hex format ASCII string
-36
lib/seq_buf.c
··· 91 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 - */ 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 - 130 94 #ifdef CONFIG_BINARY_PRINTF 131 95 /** 132 96 * seq_buf_bprintf - Write the printf string from binary arguments