]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
xen/bitmap: Drop all bitmap_scn{,list}printf() infrastructure
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 6 Sep 2018 11:35:31 +0000 (11:35 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 16 Nov 2018 16:25:54 +0000 (16:25 +0000)
All callers have been convered to using %*pb[l].  In the unlikely case that
future code wants to retain this functionaly, it can be replicated in a more
convenient fashon with snprintf().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Dario Faggioli <dfaggioli@suse.com>
xen/common/bitmap.c
xen/include/xen/bitmap.h
xen/include/xen/cpumask.h
xen/include/xen/nodemask.h

index f498ee6b84df231185b5ff5691fe74abf5dfc86e..34de387880f2ab790e0286b901ed0a7f623be1fd 100644 (file)
@@ -300,111 +300,6 @@ int __bitmap_weight(const unsigned long *bitmap, int bits)
 #endif
 EXPORT_SYMBOL(__bitmap_weight);
 
-/*
- * Bitmap printing & parsing functions: first version by Bill Irwin,
- * second version by Paul Jackson, third by Joe Korty.
- */
-
-#define CHUNKSZ                                32
-#define nbits_to_hold_value(val)       fls(val)
-#define roundup_power2(val,modulus)    (((val) + (modulus) - 1) & ~((modulus) - 1))
-#define unhex(c)                       (isdigit(c) ? (c - '0') : (toupper(c) - 'A' + 10))
-#define BASEDEC 10             /* fancier cpuset lists input in decimal */
-
-/**
- * bitmap_scnprintf - convert bitmap to an ASCII hex string.
- * @buf: byte buffer into which string is placed
- * @buflen: reserved size of @buf, in bytes
- * @maskp: pointer to bitmap to convert
- * @nmaskbits: size of bitmap, in bits
- *
- * Exactly @nmaskbits bits are displayed.  Hex digits are grouped into
- * comma-separated sets of eight digits per set.
- */
-int bitmap_scnprintf(char *buf, unsigned int buflen,
-       const unsigned long *maskp, int nmaskbits)
-{
-       int i, word, bit, len = 0;
-       unsigned long val;
-       const char *sep = "";
-       int chunksz;
-       u32 chunkmask;
-
-       chunksz = nmaskbits & (CHUNKSZ - 1);
-       if (chunksz == 0)
-               chunksz = CHUNKSZ;
-
-       i = roundup_power2(nmaskbits, CHUNKSZ) - CHUNKSZ;
-       for (; i >= 0; i -= CHUNKSZ) {
-               chunkmask = ((1ULL << chunksz) - 1);
-               word = i / BITS_PER_LONG;
-               bit = i % BITS_PER_LONG;
-               val = (maskp[word] >> bit) & chunkmask;
-               len += scnprintf(buf+len, buflen-len, "%s%0*lx", sep,
-                       (chunksz+3)/4, val);
-               chunksz = CHUNKSZ;
-               sep = ",";
-       }
-       return len;
-}
-EXPORT_SYMBOL(bitmap_scnprintf);
-
-/*
- * bscnl_emit(buf, buflen, rbot, rtop, bp)
- *
- * Helper routine for bitmap_scnlistprintf().  Write decimal number
- * or range to buf, suppressing output past buf+buflen, with optional
- * comma-prefix.  Return len of what would be written to buf, if it
- * all fit.
- */
-static inline int bscnl_emit(char *buf, int buflen, int rbot, int rtop, int len)
-{
-       if (len > 0)
-               len += scnprintf(buf + len, buflen - len, ",");
-       if (rbot == rtop)
-               len += scnprintf(buf + len, buflen - len, "%d", rbot);
-       else
-               len += scnprintf(buf + len, buflen - len, "%d-%d", rbot, rtop);
-       return len;
-}
-
-/**
- * bitmap_scnlistprintf - convert bitmap to list format ASCII string
- * @buf: byte buffer into which string is placed
- * @buflen: reserved size of @buf, in bytes
- * @maskp: pointer to bitmap to convert
- * @nmaskbits: size of bitmap, in bits
- *
- * Output format is a comma-separated list of decimal numbers and
- * ranges.  Consecutively set bits are shown as two hyphen-separated
- * decimal numbers, the smallest and largest bit numbers set in
- * the range.  Output format is compatible with the format
- * accepted as input by bitmap_parselist().
- *
- * The return value is the number of characters which were output,
- * excluding the trailing '\0'.
- */
-int bitmap_scnlistprintf(char *buf, unsigned int buflen,
-       const unsigned long *maskp, int nmaskbits)
-{
-       int len = 0;
-       /* current bit is 'cur', most recently seen range is [rbot, rtop] */
-       int cur, rbot, rtop;
-
-       rbot = cur = find_first_bit(maskp, nmaskbits);
-       while (cur < nmaskbits) {
-               rtop = cur;
-               cur = find_next_bit(maskp, nmaskbits, cur+1);
-               if (cur >= nmaskbits || cur > rtop + 1) {
-                       len = bscnl_emit(buf, buflen, rbot, rtop, len);
-                       rbot = cur;
-               }
-       }
-       if (!len && buflen)
-               *buf = 0;
-       return len;
-}
-EXPORT_SYMBOL(bitmap_scnlistprintf);
 
 /**
  *     bitmap_find_free_region - find a contiguous aligned mem region
index e2a368691e311c52aa6a186939ee4217f3fe60c4..fe3c720e8253f6b43d5a9d08c6d21cab8d6af022 100644 (file)
@@ -40,8 +40,6 @@
  * bitmap_weight(src, nbits)                   Hamming Weight: number set bits
  * bitmap_shift_right(dst, src, n, nbits)      *dst = *src >> n
  * bitmap_shift_left(dst, src, n, nbits)       *dst = *src << n
- * bitmap_scnprintf(buf, len, src, nbits)      Print bitmap src to buf
- * bitmap_scnlistprintf(buf, len, src, nbits)  Print bitmap src as list to buf
  */
 
 /*
@@ -94,10 +92,6 @@ extern int __bitmap_subset(const unsigned long *bitmap1,
                        const unsigned long *bitmap2, int bits);
 extern int __bitmap_weight(const unsigned long *bitmap, int bits);
 
-extern int bitmap_scnprintf(char *buf, unsigned int len,
-                       const unsigned long *src, int nbits);
-extern int bitmap_scnlistprintf(char *buf, unsigned int len,
-                       const unsigned long *src, int nbits);
 extern int bitmap_find_free_region(unsigned long *bitmap, int bits, int order);
 extern void bitmap_release_region(unsigned long *bitmap, int pos, int order);
 extern int bitmap_allocate_region(unsigned long *bitmap, int pos, int order);
index 4731a636c027eee63fa1a4fe6b99a32084fe3a19..b4cc92a4f55ddb30960ec8c6a94366a637fd19f6 100644 (file)
@@ -8,9 +8,6 @@
  * See detailed comments in the file xen/bitmap.h describing the
  * data type on which these cpumasks are based.
  *
- * For details of cpumask_scnprintf() and cpulist_scnprintf(),
- * see bitmap_scnprintf() and bitmap_scnlistprintf() in lib/bitmap.c.
- *
  * The available cpumask operations are:
  *
  * void cpumask_set_cpu(cpu, mask)     turn on bit 'cpu' in mask
@@ -46,9 +43,6 @@
  * const cpumask_t *cpumask_of(cpu)    Return cpumask with bit 'cpu' set
  * unsigned long *cpumask_bits(mask)   Array of unsigned long's in mask
  *
- * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing
- * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing
- *
  * for_each_cpu(cpu, mask)             for-loop cpu over mask
  *
  * int num_online_cpus()               Number of online CPUs
@@ -312,18 +306,6 @@ static inline const cpumask_t *cpumask_of(unsigned int cpu)
 
 #define cpumask_bits(maskp) ((maskp)->bits)
 
-static inline int cpumask_scnprintf(char *buf, int len,
-                                   const cpumask_t *srcp)
-{
-       return bitmap_scnprintf(buf, len, srcp->bits, nr_cpu_ids);
-}
-
-static inline int cpulist_scnprintf(char *buf, int len,
-                                   const cpumask_t *srcp)
-{
-       return bitmap_scnlistprintf(buf, len, srcp->bits, nr_cpu_ids);
-}
-
 /*
  * cpumask_var_t: struct cpumask for stack usage.
  *
index 2a90dc1aefcc6cfe1046e736a137a694e6382f23..e287399352f6c79109f51e1ff90b7de9c3018518 100644 (file)
@@ -8,10 +8,6 @@
  * See detailed comments in the file linux/bitmap.h describing the
  * data type on which these nodemasks are based.
  *
- * For details of nodemask_scnprintf(), nodelist_scnpintf() and
- * nodemask_parse(), see bitmap_scnprintf() and bitmap_parse()
- * in lib/bitmap.c.
- *
  * The available nodemask operations are:
  *
  * void node_set(node, mask)           turn on bit 'node' in mask
  * NODE_MASK_NONE                      Initializer - no bits set
  * unsigned long *nodes_addr(mask)     Array of unsigned long's in mask
  *
- * int nodemask_scnprintf(buf, len, mask) Format nodemask for printing
- * int nodelist_scnprintf(buf, len, mask) Format nodemask as a list for printing
- * int nodemask_parse(ubuf, ulen, mask)        Parse ascii string as nodemask
- *
  * for_each_node_mask(node, mask)      for-loop node over mask
  *
  * int num_online_nodes()              Number of online Nodes
@@ -294,32 +286,6 @@ static inline int __cycle_node(int n, const nodemask_t *maskp, int nbits)
 
 #define nodes_addr(src) ((src).bits)
 
-#define nodelist_scnprintf(buf, len, src) \
-                       __nodelist_scnprintf((buf), (len), (src), MAX_NUMNODES)
-static inline int __nodelist_scnprintf(char *buf, int len,
-                                       const nodemask_t *srcp, int nbits)
-{
-       return bitmap_scnlistprintf(buf, len, srcp->bits, nbits);
-}
-
-#if 0
-#define nodemask_scnprintf(buf, len, src) \
-                       __nodemask_scnprintf((buf), (len), &(src), MAX_NUMNODES)
-static inline int __nodemask_scnprintf(char *buf, int len,
-                                       const nodemask_t *srcp, int nbits)
-{
-       return bitmap_scnprintf(buf, len, srcp->bits, nbits);
-}
-
-#define nodemask_parse(ubuf, ulen, dst) \
-                       __nodemask_parse((ubuf), (ulen), &(dst), MAX_NUMNODES)
-static inline int __nodemask_parse(const char __user *buf, int len,
-                                       nodemask_t *dstp, int nbits)
-{
-       return bitmap_parse(buf, len, dstp->bits, nbits);
-}
-#endif
-
 #if MAX_NUMNODES > 1
 #define for_each_node_mask(node, mask)                 \
        for ((node) = first_node(mask);                 \