From df335f75387fcb57bc81259ff6893f4458d47747 Mon Sep 17 00:00:00 2001
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Date: Wed, 27 Nov 2013 17:19:04 +0100
Subject: [PATCH] lib/vsprintf.c: add %paD format specifier for dma_addr_t
types
Add the %paD format specifier for printing a dma_addr_t type, since the
DMA address size on some platforms can vary based on build options,
regardless of the native integer type.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
Documentation/printk-formats.txt | 7 +++++++
lib/vsprintf.c | 14 +++++++++++---
2 files changed, 18 insertions(+), 3 deletions(-)
@@ -63,6 +63,13 @@ Physical addresses:
resource_size_t) which can vary based on build options, regardless of
the width of the CPU data path. Passed by reference.
+DMA addresses:
+
+ %paD 0x01234567 or 0x0123456789abcdef
+
+ For printing a dma_addr_t type which can vary based on build options,
+ regardless of the width of the CPU data path. Passed by reference.
+
Raw buffer as a hex string:
%*ph 00 01 02 ... 3f
%*phC 00:01:02: ... :3f
@@ -1219,6 +1219,7 @@ int kptr_restrict __read_mostly;
* The maximum supported length is 64 bytes of the input. Consider
* to use print_hex_dump() for the larger input.
* - 'a' For a phys_addr_t type and its derivative types (passed by reference)
+ * - 'aD' For a dma_addr_t type (passed by reference)
* - 'd[234]' For a dentry name (optionally 2-4 last components)
* - 'D[234]' Same as 'd' but for a struct file
*
@@ -1354,10 +1355,17 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
break;
case 'a':
spec.flags |= SPECIAL | SMALL | ZEROPAD;
- spec.field_width = sizeof(phys_addr_t) * 2 + 2;
spec.base = 16;
- return number(buf, end,
- (unsigned long long) *((phys_addr_t *)ptr), spec);
+ switch (fmt[1]) {
+ case 'D':
+ spec.field_width = sizeof(dma_addr_t) * 2 + 2;
+ return number(buf, end,
+ (unsigned long long)*((dma_addr_t *)ptr), spec);
+ default:
+ spec.field_width = sizeof(phys_addr_t) * 2 + 2;
+ return number(buf, end,
+ (unsigned long long)*((phys_addr_t *)ptr), spec);
+ }
case 'd':
return dentry_name(buf, end, ptr, spec, fmt);
case 'D':
--
1.8.3.2