lib/vsprintf: factor out %pN[F] handler as netdev_bits()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Sat, 16 Jan 2016 00:59:20 +0000 (16:59 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 16 Jan 2016 19:17:30 +0000 (11:17 -0800)
Move switch case to the netdev_features_string() and rename it to
netdev_bits().  In the future we can extend it as needed.

Here we replace the fallback of %pN from '%p' with possible flags to
sticter '0x%p' without any flags variation.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/vsprintf.c

index b30203b00adfba162e0017e8d77401d9c5f57af6..48ff9c36644d64c324c5c243212f282e406dce2f 100644 (file)
@@ -1345,11 +1345,22 @@ char *uuid_string(char *buf, char *end, const u8 *addr,
        return string(buf, end, uuid, spec);
 }
 
-static
-char *netdev_feature_string(char *buf, char *end, const void *addr)
+static noinline_for_stack
+char *netdev_bits(char *buf, char *end, const void *addr, const char *fmt)
 {
-       unsigned long long num = *(const netdev_features_t *)addr;
-       int size = sizeof(netdev_features_t);
+       unsigned long long num;
+       int size;
+
+       switch (fmt[1]) {
+       case 'F':
+               num = *(const netdev_features_t *)addr;
+               size = sizeof(netdev_features_t);
+               break;
+       default:
+               num = (unsigned long)addr;
+               size = sizeof(unsigned long);
+               break;
+       }
 
        return special_hex_number(buf, end, num, size);
 }
@@ -1621,11 +1632,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
                break;
 
        case 'N':
-               switch (fmt[1]) {
-               case 'F':
-                       return netdev_feature_string(buf, end, ptr);
-               }
-               break;
+               return netdev_bits(buf, end, ptr, fmt);
        case 'a':
                return address_val(buf, end, ptr, fmt);
        case 'd':