diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2009-10-06 17:33:34 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-11-04 11:47:16 -0500 |
commit | c91d3376e5f4277173a22f0ef9989125c318bacb (patch) | |
tree | 1f5534a2792f0de2cd8937d7efd9dc03d97ac2e4 /lib | |
parent | 2840537228fba95e05cab1a6b5719c61982db279 (diff) |
vsprintf: add %pR support for IRQ and DMA resources
Print addresses (IO port numbers and memory addresses) in hex, but print
others (IRQs and DMA channels) in decimal. Only print the end if it's
different from the start.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vsprintf.c | 31 |
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 | ||