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>
This commit is contained in:
parent
2840537228
commit
c91d3376e5
|
@ -604,26 +604,37 @@ static char *resource_string(char *buf, char *end, struct resource *res,
|
||||||
#ifndef MEM_RSRC_PRINTK_SIZE
|
#ifndef MEM_RSRC_PRINTK_SIZE
|
||||||
#define MEM_RSRC_PRINTK_SIZE 10
|
#define MEM_RSRC_PRINTK_SIZE 10
|
||||||
#endif
|
#endif
|
||||||
struct printf_spec num_spec = {
|
struct printf_spec hex_spec = {
|
||||||
.base = 16,
|
.base = 16,
|
||||||
.precision = -1,
|
.precision = -1,
|
||||||
.flags = SPECIAL | SMALL | ZEROPAD,
|
.flags = SPECIAL | SMALL | ZEROPAD,
|
||||||
};
|
};
|
||||||
/* room for the actual numbers, the two "0x", -, [, ] and the final zero */
|
struct printf_spec dec_spec = {
|
||||||
char sym[4*sizeof(resource_size_t) + 8];
|
.base = 10,
|
||||||
|
.precision = -1,
|
||||||
|
.flags = 0,
|
||||||
|
};
|
||||||
|
/* room for two actual numbers (decimal or hex), the two "0x", -, [, ]
|
||||||
|
* and the final zero */
|
||||||
|
char sym[2*3*sizeof(resource_size_t) + 8];
|
||||||
char *p = sym, *pend = sym + sizeof(sym);
|
char *p = sym, *pend = sym + sizeof(sym);
|
||||||
int size = -1;
|
int size = -1, addr = 0;
|
||||||
|
|
||||||
if (res->flags & IORESOURCE_IO)
|
if (res->flags & IORESOURCE_IO) {
|
||||||
size = IO_RSRC_PRINTK_SIZE;
|
size = IO_RSRC_PRINTK_SIZE;
|
||||||
else if (res->flags & IORESOURCE_MEM)
|
addr = 1;
|
||||||
|
} else if (res->flags & IORESOURCE_MEM) {
|
||||||
size = MEM_RSRC_PRINTK_SIZE;
|
size = MEM_RSRC_PRINTK_SIZE;
|
||||||
|
addr = 1;
|
||||||
|
}
|
||||||
|
|
||||||
*p++ = '[';
|
*p++ = '[';
|
||||||
num_spec.field_width = size;
|
hex_spec.field_width = size;
|
||||||
p = number(p, pend, res->start, num_spec);
|
p = number(p, pend, res->start, addr ? hex_spec : dec_spec);
|
||||||
|
if (res->start != res->end) {
|
||||||
*p++ = '-';
|
*p++ = '-';
|
||||||
p = number(p, pend, res->end, num_spec);
|
p = number(p, pend, res->end, addr ? hex_spec : dec_spec);
|
||||||
|
}
|
||||||
*p++ = ']';
|
*p++ = ']';
|
||||||
*p = 0;
|
*p = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue