From: "user.email" <andriy.shevchenko@linux.intel.com>
To: Rob Landley <rob@landley.net>,
Andrew Morton <akpm@linux-foundation.org>,
Joe Perches <joe@perches.com>,
linux-kernel@vger.kernel.org,
Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
dmaengine@vger.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH] lib/vsprintf.c: add %paD format specifier for dma_addr_t types
Date: Thu, 28 Nov 2013 13:28:04 +0200 [thread overview]
Message-ID: <1385638084-10719-1-git-send-email-andriy.shevchenko@linux.intel.com> (raw)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
Documentation/printk-formats.txt | 7 +++++++
lib/vsprintf.c | 15 ++++++++++++---
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
index 445ad74..3344ca9 100644
--- a/Documentation/printk-formats.txt
+++ b/Documentation/printk-formats.txt
@@ -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
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 10909c5..12ea69d 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -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,18 @@ 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);
+ }
+ break;
case 'd':
return dentry_name(buf, end, ptr, spec, fmt);
case 'D':
--
1.8.4.4
next reply other threads:[~2013-11-28 11:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-28 11:28 user.email [this message]
2013-11-28 18:32 ` Joe Perches
2013-11-29 12:56 ` Andy Shevchenko
2013-11-29 22:10 ` Joe Perches
2013-11-29 22:50 ` Lars-Peter Clausen
2013-11-29 22:58 ` Joe Perches
2013-11-29 23:44 ` Laurent Pinchart
2013-12-02 9:06 ` Andy Shevchenko
2013-12-02 9:08 ` Shevchenko, Andriy
2013-12-03 22:16 ` [PATCH -next] vsprintf: add %pad extension for dma_addr_t use Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1385638084-10719-1-git-send-email-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=dmaengine@vger.kernel.org \
--cc=joe@perches.com \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rob@landley.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®