diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2008-05-12 15:21:00 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2008-05-23 15:50:38 -0400 |
commit | 93dcc6ea096c51cc30ad0f6647ed05fead2439bf (patch) | |
tree | 2490074ca4ee97e8ef9d4cbaa10bca8a4cd1a597 /kernel/trace/trace.c | |
parent | bb065afb8ebd07a03155502dba29ebf0f6fe67e8 (diff) |
ftrace: simplify hexprint
simplify hex to ascii conversion.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 4723e012151d..627e39936ea7 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -248,19 +248,18 @@ trace_seq_putmem(struct trace_seq *s, void *mem, size_t len) | |||
248 | } | 248 | } |
249 | 249 | ||
250 | #define HEX_CHARS 17 | 250 | #define HEX_CHARS 17 |
251 | static const char hex2asc[] = "0123456789abcdef"; | ||
251 | 252 | ||
252 | static int | 253 | static int |
253 | trace_seq_putmem_hex(struct trace_seq *s, void *mem, size_t len) | 254 | trace_seq_putmem_hex(struct trace_seq *s, void *mem, size_t len) |
254 | { | 255 | { |
255 | unsigned char hex[HEX_CHARS]; | 256 | unsigned char hex[HEX_CHARS]; |
256 | unsigned char *data; | 257 | unsigned char *data = mem; |
257 | unsigned char byte; | 258 | unsigned char byte; |
258 | int i, j; | 259 | int i, j; |
259 | 260 | ||
260 | BUG_ON(len >= HEX_CHARS); | 261 | BUG_ON(len >= HEX_CHARS); |
261 | 262 | ||
262 | data = mem; | ||
263 | |||
264 | #ifdef __BIG_ENDIAN | 263 | #ifdef __BIG_ENDIAN |
265 | for (i = 0, j = 0; i < len; i++) { | 264 | for (i = 0, j = 0; i < len; i++) { |
266 | #else | 265 | #else |
@@ -268,22 +267,10 @@ trace_seq_putmem_hex(struct trace_seq *s, void *mem, size_t len) | |||
268 | #endif | 267 | #endif |
269 | byte = data[i]; | 268 | byte = data[i]; |
270 | 269 | ||
271 | hex[j] = byte & 0x0f; | 270 | hex[j++] = hex2asc[byte & 0x0f]; |
272 | if (hex[j] >= 10) | 271 | hex[j++] = hex2asc[byte >> 4]; |
273 | hex[j] += 'a' - 10; | ||
274 | else | ||
275 | hex[j] += '0'; | ||
276 | j++; | ||
277 | |||
278 | hex[j] = byte >> 4; | ||
279 | if (hex[j] >= 10) | ||
280 | hex[j] += 'a' - 10; | ||
281 | else | ||
282 | hex[j] += '0'; | ||
283 | j++; | ||
284 | } | 272 | } |
285 | hex[j] = ' '; | 273 | hex[j++] = ' '; |
286 | j++; | ||
287 | 274 | ||
288 | return trace_seq_putmem(s, hex, j); | 275 | return trace_seq_putmem(s, hex, j); |
289 | } | 276 | } |