diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2014-02-26 13:25:56 -0500 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2014-02-26 16:42:09 -0500 |
commit | d19cb803a2ff85d1b64b9628e1aec2aa76a9260b (patch) | |
tree | ad782893ca50522d4285df1e523c5020f7095bfe | |
parent | 5edb93b89f6cc3089ee283656555e7a9ad36a8a0 (diff) |
vsprintf: Add support for IORESOURCE_UNSET in %pR
Sometimes we have a struct resource where we know the type (MEM/IO/etc.)
and the size, but we haven't assigned address space for it. The
IORESOURCE_UNSET flag is a way to indicate this situation. For these
"unset" resources, the start address is meaningless, so print only the
size, e.g.,
- pci 0000:0c:00.0: reg 184: [mem 0x00000000-0x00001fff 64bit]
+ pci 0000:0c:00.0: reg 184: [mem size 0x2000 64bit]
For %pr (printing with raw flags), we still print the address range,
because %pr is mostly used for debugging anyway.
Thanks to Fengguang Wu <fengguang.wu@intel.com> for suggesting
resource_size().
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r-- | include/linux/ioport.h | 2 | ||||
-rw-r--r-- | lib/vsprintf.c | 13 |
2 files changed, 10 insertions, 5 deletions
diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 9fcaac8bc4f6..5e3a906cc089 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h | |||
@@ -51,7 +51,7 @@ struct resource { | |||
51 | 51 | ||
52 | #define IORESOURCE_EXCLUSIVE 0x08000000 /* Userland may not map this resource */ | 52 | #define IORESOURCE_EXCLUSIVE 0x08000000 /* Userland may not map this resource */ |
53 | #define IORESOURCE_DISABLED 0x10000000 | 53 | #define IORESOURCE_DISABLED 0x10000000 |
54 | #define IORESOURCE_UNSET 0x20000000 | 54 | #define IORESOURCE_UNSET 0x20000000 /* No address assigned yet */ |
55 | #define IORESOURCE_AUTO 0x40000000 | 55 | #define IORESOURCE_AUTO 0x40000000 |
56 | #define IORESOURCE_BUSY 0x80000000 /* Driver has marked this resource busy */ | 56 | #define IORESOURCE_BUSY 0x80000000 /* Driver has marked this resource busy */ |
57 | 57 | ||
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 185b6d300ebc..5e2cf6f342f8 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -719,10 +719,15 @@ char *resource_string(char *buf, char *end, struct resource *res, | |||
719 | specp = &mem_spec; | 719 | specp = &mem_spec; |
720 | decode = 0; | 720 | decode = 0; |
721 | } | 721 | } |
722 | p = number(p, pend, res->start, *specp); | 722 | if (decode && res->flags & IORESOURCE_UNSET) { |
723 | if (res->start != res->end) { | 723 | p = string(p, pend, "size ", str_spec); |
724 | *p++ = '-'; | 724 | p = number(p, pend, resource_size(res), *specp); |
725 | p = number(p, pend, res->end, *specp); | 725 | } else { |
726 | p = number(p, pend, res->start, *specp); | ||
727 | if (res->start != res->end) { | ||
728 | *p++ = '-'; | ||
729 | p = number(p, pend, res->end, *specp); | ||
730 | } | ||
726 | } | 731 | } |
727 | if (decode) { | 732 | if (decode) { |
728 | if (res->flags & IORESOURCE_MEM_64) | 733 | if (res->flags & IORESOURCE_MEM_64) |