diff options
-rw-r--r-- | lib/vsprintf.c | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index bdc4985b1ea7..b30203b00adf 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -515,6 +515,20 @@ char *number(char *buf, char *end, unsigned long long num, | |||
515 | return buf; | 515 | return buf; |
516 | } | 516 | } |
517 | 517 | ||
518 | static noinline_for_stack | ||
519 | char *special_hex_number(char *buf, char *end, unsigned long long num, int size) | ||
520 | { | ||
521 | struct printf_spec spec; | ||
522 | |||
523 | spec.type = FORMAT_TYPE_PTR; | ||
524 | spec.field_width = 2 + 2 * size; /* 0x + hex */ | ||
525 | spec.flags = SPECIAL | SMALL | ZEROPAD; | ||
526 | spec.base = 16; | ||
527 | spec.precision = -1; | ||
528 | |||
529 | return number(buf, end, num, spec); | ||
530 | } | ||
531 | |||
518 | static void move_right(char *buf, char *end, unsigned len, unsigned spaces) | 532 | static void move_right(char *buf, char *end, unsigned len, unsigned spaces) |
519 | { | 533 | { |
520 | size_t size; | 534 | size_t size; |
@@ -670,11 +684,7 @@ char *symbol_string(char *buf, char *end, void *ptr, | |||
670 | 684 | ||
671 | return string(buf, end, sym, spec); | 685 | return string(buf, end, sym, spec); |
672 | #else | 686 | #else |
673 | spec.field_width = 2 * sizeof(void *); | 687 | return special_hex_number(buf, end, value, sizeof(void *)); |
674 | spec.flags |= SPECIAL | SMALL | ZEROPAD; | ||
675 | spec.base = 16; | ||
676 | |||
677 | return number(buf, end, value, spec); | ||
678 | #endif | 688 | #endif |
679 | } | 689 | } |
680 | 690 | ||
@@ -1336,39 +1346,33 @@ char *uuid_string(char *buf, char *end, const u8 *addr, | |||
1336 | } | 1346 | } |
1337 | 1347 | ||
1338 | static | 1348 | static |
1339 | char *netdev_feature_string(char *buf, char *end, const u8 *addr, | 1349 | char *netdev_feature_string(char *buf, char *end, const void *addr) |
1340 | struct printf_spec spec) | ||
1341 | { | 1350 | { |
1342 | spec.flags |= SPECIAL | SMALL | ZEROPAD; | 1351 | unsigned long long num = *(const netdev_features_t *)addr; |
1343 | if (spec.field_width == -1) | 1352 | int size = sizeof(netdev_features_t); |
1344 | spec.field_width = 2 + 2 * sizeof(netdev_features_t); | ||
1345 | spec.base = 16; | ||
1346 | 1353 | ||
1347 | return number(buf, end, *(const netdev_features_t *)addr, spec); | 1354 | return special_hex_number(buf, end, num, size); |
1348 | } | 1355 | } |
1349 | 1356 | ||
1350 | static noinline_for_stack | 1357 | static noinline_for_stack |
1351 | char *address_val(char *buf, char *end, const void *addr, | 1358 | char *address_val(char *buf, char *end, const void *addr, const char *fmt) |
1352 | struct printf_spec spec, const char *fmt) | ||
1353 | { | 1359 | { |
1354 | unsigned long long num; | 1360 | unsigned long long num; |
1355 | 1361 | int size; | |
1356 | spec.flags |= SPECIAL | SMALL | ZEROPAD; | ||
1357 | spec.base = 16; | ||
1358 | 1362 | ||
1359 | switch (fmt[1]) { | 1363 | switch (fmt[1]) { |
1360 | case 'd': | 1364 | case 'd': |
1361 | num = *(const dma_addr_t *)addr; | 1365 | num = *(const dma_addr_t *)addr; |
1362 | spec.field_width = sizeof(dma_addr_t) * 2 + 2; | 1366 | size = sizeof(dma_addr_t); |
1363 | break; | 1367 | break; |
1364 | case 'p': | 1368 | case 'p': |
1365 | default: | 1369 | default: |
1366 | num = *(const phys_addr_t *)addr; | 1370 | num = *(const phys_addr_t *)addr; |
1367 | spec.field_width = sizeof(phys_addr_t) * 2 + 2; | 1371 | size = sizeof(phys_addr_t); |
1368 | break; | 1372 | break; |
1369 | } | 1373 | } |
1370 | 1374 | ||
1371 | return number(buf, end, num, spec); | 1375 | return special_hex_number(buf, end, num, size); |
1372 | } | 1376 | } |
1373 | 1377 | ||
1374 | static noinline_for_stack | 1378 | static noinline_for_stack |
@@ -1387,10 +1391,7 @@ char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec, | |||
1387 | #ifdef CONFIG_COMMON_CLK | 1391 | #ifdef CONFIG_COMMON_CLK |
1388 | return string(buf, end, __clk_get_name(clk), spec); | 1392 | return string(buf, end, __clk_get_name(clk), spec); |
1389 | #else | 1393 | #else |
1390 | spec.base = 16; | 1394 | return special_hex_number(buf, end, (unsigned long)clk, sizeof(unsigned long)); |
1391 | spec.field_width = sizeof(unsigned long) * 2 + 2; | ||
1392 | spec.flags |= SPECIAL | SMALL | ZEROPAD; | ||
1393 | return number(buf, end, (unsigned long)clk, spec); | ||
1394 | #endif | 1395 | #endif |
1395 | } | 1396 | } |
1396 | } | 1397 | } |
@@ -1622,11 +1623,11 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, | |||
1622 | case 'N': | 1623 | case 'N': |
1623 | switch (fmt[1]) { | 1624 | switch (fmt[1]) { |
1624 | case 'F': | 1625 | case 'F': |
1625 | return netdev_feature_string(buf, end, ptr, spec); | 1626 | return netdev_feature_string(buf, end, ptr); |
1626 | } | 1627 | } |
1627 | break; | 1628 | break; |
1628 | case 'a': | 1629 | case 'a': |
1629 | return address_val(buf, end, ptr, spec, fmt); | 1630 | return address_val(buf, end, ptr, fmt); |
1630 | case 'd': | 1631 | case 'd': |
1631 | return dentry_name(buf, end, ptr, spec, fmt); | 1632 | return dentry_name(buf, end, ptr, spec, fmt); |
1632 | case 'C': | 1633 | case 'C': |