aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/printk-formats.txt5
-rw-r--r--lib/vsprintf.c23
2 files changed, 24 insertions, 4 deletions
diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
index 5df176ed59b8..d8d168fa79d6 100644
--- a/Documentation/printk-formats.txt
+++ b/Documentation/printk-formats.txt
@@ -56,6 +56,7 @@ Struct Resources:
56MAC/FDDI addresses: 56MAC/FDDI addresses:
57 57
58 %pM 00:01:02:03:04:05 58 %pM 00:01:02:03:04:05
59 %pMR 05:04:03:02:01:00
59 %pMF 00-01-02-03-04-05 60 %pMF 00-01-02-03-04-05
60 %pm 000102030405 61 %pm 000102030405
61 62
@@ -67,6 +68,10 @@ MAC/FDDI addresses:
67 the 'M' specifier to use dash ('-') separators instead of the default 68 the 'M' specifier to use dash ('-') separators instead of the default
68 separator. 69 separator.
69 70
71 For Bluetooth addresses the 'R' specifier shall be used after the 'M'
72 specifier to use reversed byte order suitable for visual interpretation
73 of Bluetooth addresses which are in the little endian order.
74
70IPv4 addresses: 75IPv4 addresses:
71 76
72 %pI4 1.2.3.4 77 %pI4 1.2.3.4
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index c3f36d415bdf..736974576e2d 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -662,15 +662,28 @@ char *mac_address_string(char *buf, char *end, u8 *addr,
662 char *p = mac_addr; 662 char *p = mac_addr;
663 int i; 663 int i;
664 char separator; 664 char separator;
665 bool reversed = false;
665 666
666 if (fmt[1] == 'F') { /* FDDI canonical format */ 667 switch (fmt[1]) {
668 case 'F':
667 separator = '-'; 669 separator = '-';
668 } else { 670 break;
671
672 case 'R':
673 reversed = true;
674 /* fall through */
675
676 default:
669 separator = ':'; 677 separator = ':';
678 break;
670 } 679 }
671 680
672 for (i = 0; i < 6; i++) { 681 for (i = 0; i < 6; i++) {
673 p = hex_byte_pack(p, addr[i]); 682 if (reversed)
683 p = hex_byte_pack(p, addr[5 - i]);
684 else
685 p = hex_byte_pack(p, addr[i]);
686
674 if (fmt[0] == 'M' && i != 5) 687 if (fmt[0] == 'M' && i != 5)
675 *p++ = separator; 688 *p++ = separator;
676 } 689 }
@@ -933,6 +946,7 @@ int kptr_restrict __read_mostly;
933 * - 'm' For a 6-byte MAC address, it prints the hex address without colons 946 * - 'm' For a 6-byte MAC address, it prints the hex address without colons
934 * - 'MF' For a 6-byte MAC FDDI address, it prints the address 947 * - 'MF' For a 6-byte MAC FDDI address, it prints the address
935 * with a dash-separated hex notation 948 * with a dash-separated hex notation
949 * - '[mM]R For a 6-byte MAC address, Reverse order (Bluetooth)
936 * - 'I' [46] for IPv4/IPv6 addresses printed in the usual way 950 * - 'I' [46] for IPv4/IPv6 addresses printed in the usual way
937 * IPv4 uses dot-separated decimal without leading 0's (1.2.3.4) 951 * IPv4 uses dot-separated decimal without leading 0's (1.2.3.4)
938 * IPv6 uses colon separated network-order 16 bit hex with leading 0's 952 * IPv6 uses colon separated network-order 16 bit hex with leading 0's
@@ -995,7 +1009,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
995 return resource_string(buf, end, ptr, spec, fmt); 1009 return resource_string(buf, end, ptr, spec, fmt);
996 case 'M': /* Colon separated: 00:01:02:03:04:05 */ 1010 case 'M': /* Colon separated: 00:01:02:03:04:05 */
997 case 'm': /* Contiguous: 000102030405 */ 1011 case 'm': /* Contiguous: 000102030405 */
998 /* [mM]F (FDDI, bit reversed) */ 1012 /* [mM]F (FDDI) */
1013 /* [mM]R (Reverse order; Bluetooth) */
999 return mac_address_string(buf, end, ptr, spec, fmt); 1014 return mac_address_string(buf, end, ptr, spec, fmt);
1000 case 'I': /* Formatted IP supported 1015 case 'I': /* Formatted IP supported
1001 * 4: 1.2.3.4 1016 * 4: 1.2.3.4