public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Stepan Moskovchenko <stepanm@codeaurora.org>
Cc: Rob Landley <rob@landley.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	George Spelvin <linux@horizon.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Andrei Emeltchenko <andrei.emeltchenko@intel.com>,
	mingo@kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH] lib: vsprintf: Add %pa format specifier for phys_addr_t types
Date: Tue, 22 Jan 2013 09:29:27 +0200	[thread overview]
Message-ID: <1358839767.12502.44.camel@smile> (raw)
In-Reply-To: <1358833677-15611-1-git-send-email-stepanm@codeaurora.org>

On Mon, 2013-01-21 at 21:47 -0800, Stepan Moskovchenko wrote: 
> Add the %pa format specifier for printing a phys_addr_t
> type, since the physical address size on some platforms
> can vary based on build options, regardless of the native
> integer type.
> 
> Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
> ---
>  Documentation/printk-formats.txt |   13 ++++++++++---
>  lib/vsprintf.c                   |    7 +++++++
>  2 files changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
> index 8ffb274..dbc977b 100644
> --- a/Documentation/printk-formats.txt
> +++ b/Documentation/printk-formats.txt
> @@ -53,6 +53,13 @@ Struct Resources:
>  	For printing struct resources. The 'R' and 'r' specifiers result in a
>  	printed resource with ('R') or without ('r') a decoded flags member.
> 
> +Physical addresses:
> +
> +	%pa	0x01234567 or 0x0123456789abcdef
> +
> +	For printing a phys_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
> @@ -150,9 +157,9 @@ s64 SHOULD be printed with %lld/%llx, (long long):
>  	printk("%lld", (long long)s64_var);
> 
>  If <type> is dependent on a config option for its size (e.g., sector_t,
> -blkcnt_t, phys_addr_t, resource_size_t) or is architecture-dependent
> -for its size (e.g., tcflag_t), use a format specifier of its largest
> -possible type and explicitly cast to it.  Example:
> +blkcnt_t, resource_size_t) or is architecture-dependent for its size (e.g.,

resource_size_t is a typedef of phys_addr_t.

Probably you should mention that your change related to the phys_addr_t
*and* derivatives.

> +tcflag_t), use a format specifier of its largest possible type and explicitly
> +cast to it.  Example:
> 
>  	printk("test: sector number/total blocks: %llu/%llu\n",
>  		(unsigned long long)sector, (unsigned long long)blockcount);
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 39c99fe..9b02a71 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -1022,6 +1022,7 @@ int kptr_restrict __read_mostly;
>   *              N no separator
>   *            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 (passed by reference)
>   *
>   * Note: The difference between 'S' and 'F' is that on ia64 and ppc64
>   * function pointers are really function descriptors, which contain a
> @@ -1112,6 +1113,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
>  			return netdev_feature_string(buf, end, ptr, spec);
>  		}
>  		break;
> +	case 'a':
> +		spec.flags |= SPECIAL | SMALL | ZEROPAD;
> +		spec.field_width = sizeof(phys_addr_t) * 2;
> +		spec.base = 16;
> +		return number(buf, end,
> +			      (unsigned long long) *((phys_addr_t *)ptr), spec);
>  	}
>  	spec.flags |= SMALL;
>  	if (spec.field_width == -1) {
> --
> The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> hosted by The Linux Foundation
> 

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

  reply	other threads:[~2013-01-22  7:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-22  5:47 [PATCH] lib: vsprintf: Add %pa format specifier for phys_addr_t types Stepan Moskovchenko
2013-01-22  7:29 ` Andy Shevchenko [this message]
2013-01-22  7:52   ` Joe Perches
2013-01-22 21:07     ` Stepan Moskovchenko
2013-01-22 22:26 ` Geert Uytterhoeven
2013-01-23  4:14   ` Joe Perches
2013-01-24  0:37     ` Stepan Moskovchenko
2013-01-23  0:14 ` [PATCH v2] " Stepan Moskovchenko
2013-01-24 23:07   ` Andrew Morton
2013-02-07  4:39   ` Rob Landley
2013-02-07  6:39     ` Geert Uytterhoeven

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=1358839767.12502.44.camel@smile \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=andrei.emeltchenko@intel.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@horizon.com \
    --cc=mingo@kernel.org \
    --cc=rob@landley.net \
    --cc=sboyd@codeaurora.org \
    --cc=stepanm@codeaurora.org \
    /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