aboutsummaryrefslogtreecommitdiffstats
path: root/lib/vsprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r--lib/vsprintf.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 7830576018c0..1b60aedab44d 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -604,26 +604,37 @@ static char *resource_string(char *buf, char *end, struct resource *res,
604#ifndef MEM_RSRC_PRINTK_SIZE 604#ifndef MEM_RSRC_PRINTK_SIZE
605#define MEM_RSRC_PRINTK_SIZE 10 605#define MEM_RSRC_PRINTK_SIZE 10
606#endif 606#endif
607 struct printf_spec num_spec = { 607 struct printf_spec hex_spec = {
608 .base = 16, 608 .base = 16,
609 .precision = -1, 609 .precision = -1,
610 .flags = SPECIAL | SMALL | ZEROPAD, 610 .flags = SPECIAL | SMALL | ZEROPAD,
611 }; 611 };
612 /* room for the actual numbers, the two "0x", -, [, ] and the final zero */ 612 struct printf_spec dec_spec = {
613 char sym[4*sizeof(resource_size_t) + 8]; 613 .base = 10,
614 .precision = -1,
615 .flags = 0,
616 };
617 /* room for two actual numbers (decimal or hex), the two "0x", -, [, ]
618 * and the final zero */
619 char sym[2*3*sizeof(resource_size_t) + 8];
614 char *p = sym, *pend = sym + sizeof(sym); 620 char *p = sym, *pend = sym + sizeof(sym);
615 int size = -1; 621 int size = -1, addr = 0;
616 622
617 if (res->flags & IORESOURCE_IO) 623 if (res->flags & IORESOURCE_IO) {
618 size = IO_RSRC_PRINTK_SIZE; 624 size = IO_RSRC_PRINTK_SIZE;
619 else if (res->flags & IORESOURCE_MEM) 625 addr = 1;
626 } else if (res->flags & IORESOURCE_MEM) {
620 size = MEM_RSRC_PRINTK_SIZE; 627 size = MEM_RSRC_PRINTK_SIZE;
628 addr = 1;
629 }
621 630
622 *p++ = '['; 631 *p++ = '[';
623 num_spec.field_width = size; 632 hex_spec.field_width = size;
624 p = number(p, pend, res->start, num_spec); 633 p = number(p, pend, res->start, addr ? hex_spec : dec_spec);
625 *p++ = '-'; 634 if (res->start != res->end) {
626 p = number(p, pend, res->end, num_spec); 635 *p++ = '-';
636 p = number(p, pend, res->end, addr ? hex_spec : dec_spec);
637 }
627 *p++ = ']'; 638 *p++ = ']';
628 *p = 0; 639 *p = 0;
629 640