[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1224212533.7654.60.camel@pasglop>
Date: Fri, 17 Oct 2008 14:02:13 +1100
From: Benjamin Herrenschmidt <benh@...nel.crashing.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Geert.Uytterhoeven@...ycom.com, hpa@...or.com,
linux-kernel@...r.kernel.org, mingo@...e.hu, yhlu.kernel@...il.com,
David Miller <davem@...emloft.net>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] Fix broken debug output reserve_region_with_split()
From: Linus Torvalds <torvalds@...ux-foundation.org>
Implement %pR to print struct resource content
Add a %pR option to the kernel vsnprintf that prints the range of
addresses inside a struct resource passed by pointer.
Signed-off-by: Linus Torvalds <torvalds@...ux-foundation.org>
Signed-off-by: Benjamin Herrenschmidt <benh@...nel.crashing.org>
---
Time that we sort that out once for all. I have patches for converting
some of PCI that I'll send later, and doing more as we speak.
I took Linus variant, added 0x and made it print lowercase. There's
still the question of whether we want to also make it pad with zeros
(the number of zeros being based on the size of resource_size_t,
maybe with hacks to limit IO size on x86 ?)
Let me know and I'll respin if necessary.
Index: linux-work/lib/vsprintf.c
===================================================================
--- linux-work.orig/lib/vsprintf.c 2008-10-17 13:30:18.000000000 +1100
+++ linux-work/lib/vsprintf.c 2008-10-17 13:55:25.000000000 +1100
@@ -24,6 +24,7 @@
#include <linux/kernel.h>
#include <linux/kallsyms.h>
#include <linux/uaccess.h>
+#include <linux/ioport.h>
#include <asm/page.h> /* for PAGE_SIZE */
#include <asm/div64.h>
@@ -550,6 +551,22 @@ static char *symbol_string(char *buf, ch
#endif
}
+static char *resource_string(char *buf, char *end, struct resource *res, int field_width, int precision, int flags)
+{
+ /* room for the actual numbers, the two "0x", -, [, ] and the final zero */
+ char sym[4*sizeof(resource_size_t) + 8];
+ char *p = sym, *pend = sym + sizeof(sym);
+
+ *p++ = '[';
+ p = number(p, pend, res->start, 16, -1, -1, SPECIAL | SMALL);
+ *p++ = '-';
+ p = number(p, pend, res->end, 16, -1, -1, SPECIAL | SMALL);
+ *p++ = ']';
+ *p = 0;
+
+ return string(buf, end, sym, field_width, precision, flags);
+}
+
/*
* Show a '%p' thing. A kernel extension is that the '%p' is followed
* by an extra set of alphanumeric characters that are extended format
@@ -571,6 +588,8 @@ static char *pointer(const char *fmt, ch
/* Fallthrough */
case 'S':
return symbol_string(buf, end, ptr, field_width, precision, flags);
+ case 'R':
+ return resource_string(buf, end, ptr, field_width, precision, flags);
}
flags |= SMALL;
if (field_width == -1) {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists