mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Robert Elliott <elliott@hpe.com>,
	Matt Fleming <matt@codeblueprint.co.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	linux-kernel@vger.kernel.org,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Brian Norris <computersforpeace@gmail.com>,
	Hariprasad S <hariprasad@chelsio.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v2 03/11] lib/vsprintf: make default_str_spec global
Date: Fri, 15 Jan 2016 00:23:33 +0200	[thread overview]
Message-ID: <1452810221-116505-4-git-send-email-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <1452810221-116505-1-git-send-email-andriy.shevchenko@linux.intel.com>

There will be place where default specification to print string is used.
Make it global and convert existing user.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 lib/vsprintf.c | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 53a6e7c..f0789e3 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -671,6 +671,12 @@ static const struct printf_spec default_dec_spec = {
 	.precision = -1,
 };
 
+static const struct printf_spec default_str_spec = {
+	.field_width = -1,
+	.precision = 10,
+	.flags = LEFT,
+};
+
 static noinline_for_stack
 char *resource_string(char *buf, char *end, struct resource *res,
 		      struct printf_spec spec, const char *fmt)
@@ -700,11 +706,6 @@ char *resource_string(char *buf, char *end, struct resource *res,
 		.precision = -1,
 		.flags = SMALL | ZEROPAD,
 	};
-	static const struct printf_spec str_spec = {
-		.field_width = -1,
-		.precision = 10,
-		.flags = LEFT,
-	};
 	static const struct printf_spec flag_spec = {
 		.base = 16,
 		.precision = -1,
@@ -726,27 +727,27 @@ char *resource_string(char *buf, char *end, struct resource *res,
 
 	*p++ = '[';
 	if (res->flags & IORESOURCE_IO) {
-		p = string(p, pend, "io  ", str_spec);
+		p = string(p, pend, "io  ", default_str_spec);
 		specp = &io_spec;
 	} else if (res->flags & IORESOURCE_MEM) {
-		p = string(p, pend, "mem ", str_spec);
+		p = string(p, pend, "mem ", default_str_spec);
 		specp = &mem_spec;
 	} else if (res->flags & IORESOURCE_IRQ) {
-		p = string(p, pend, "irq ", str_spec);
+		p = string(p, pend, "irq ", default_str_spec);
 		specp = &default_dec_spec;
 	} else if (res->flags & IORESOURCE_DMA) {
-		p = string(p, pend, "dma ", str_spec);
+		p = string(p, pend, "dma ", default_str_spec);
 		specp = &default_dec_spec;
 	} else if (res->flags & IORESOURCE_BUS) {
-		p = string(p, pend, "bus ", str_spec);
+		p = string(p, pend, "bus ", default_str_spec);
 		specp = &bus_spec;
 	} else {
-		p = string(p, pend, "??? ", str_spec);
+		p = string(p, pend, "??? ", default_str_spec);
 		specp = &mem_spec;
 		decode = 0;
 	}
 	if (decode && res->flags & IORESOURCE_UNSET) {
-		p = string(p, pend, "size ", str_spec);
+		p = string(p, pend, "size ", default_str_spec);
 		p = number(p, pend, resource_size(res), *specp);
 	} else {
 		p = number(p, pend, res->start, *specp);
@@ -757,15 +758,15 @@ char *resource_string(char *buf, char *end, struct resource *res,
 	}
 	if (decode) {
 		if (res->flags & IORESOURCE_MEM_64)
-			p = string(p, pend, " 64bit", str_spec);
+			p = string(p, pend, " 64bit", default_str_spec);
 		if (res->flags & IORESOURCE_PREFETCH)
-			p = string(p, pend, " pref", str_spec);
+			p = string(p, pend, " pref", default_str_spec);
 		if (res->flags & IORESOURCE_WINDOW)
-			p = string(p, pend, " window", str_spec);
+			p = string(p, pend, " window", default_str_spec);
 		if (res->flags & IORESOURCE_DISABLED)
-			p = string(p, pend, " disabled", str_spec);
+			p = string(p, pend, " disabled", default_str_spec);
 	} else {
-		p = string(p, pend, " flags ", str_spec);
+		p = string(p, pend, " flags ", default_str_spec);
 		p = number(p, pend, res->flags, flag_spec);
 	}
 	*p++ = ']';
-- 
2.6.4

  parent reply	other threads:[~2016-01-14 22:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-14 22:23 [PATCH v2 00/11] lib/vsprintf: refactor and introduce %pl specifier Andy Shevchenko
2016-01-14 22:23 ` [PATCH v2 01/11] lib/vsprintf: introduce put_one_char() for 3 line idiom Andy Shevchenko
2016-01-18 20:35   ` Rasmus Villemoes
2016-01-14 22:23 ` [PATCH v2 02/11] lib/vsprintf: make default_dec_spec global Andy Shevchenko
2016-01-18 20:38   ` Rasmus Villemoes
2016-01-14 22:23 ` Andy Shevchenko [this message]
2016-01-14 22:23 ` [PATCH v2 04/11] lib/string_helpers: export string_units_{2,10} for others Andy Shevchenko
2016-01-14 22:23 ` [PATCH v2 05/11] lib/string_helpers: fix indentation in few places Andy Shevchenko
2016-01-14 22:23 ` [PATCH v2 06/11] lib/vsprintf: introduce %pl to print in human-readable form Andy Shevchenko
2016-01-15  3:04   ` Joe Perches
2016-01-18 20:57   ` Rasmus Villemoes
2016-01-21 21:13   ` H. Peter Anvin
2016-01-14 22:23 ` [PATCH v2 07/11] x86/efi: print size and base in binary units in efi_print_memmap Andy Shevchenko
2016-01-14 22:23 ` [PATCH v2 08/11] lib/vsprintf: allow range of prefix for %pl[From[To]] Andy Shevchenko
2016-01-18 21:40   ` Rasmus Villemoes
2016-01-14 22:23 ` [PATCH v2 09/11] lib/vsprintf: use precision field with %pl[From[To]] Andy Shevchenko
2016-01-18 22:21   ` Rasmus Villemoes
2016-01-14 22:23 ` [PATCH v2 10/11] cxgb4: print value in human-readable form via %.0plKM Andy Shevchenko
2016-01-14 22:23 ` [PATCH v2 11/11] pcmciamtd: " Andy Shevchenko
2016-01-21 12:51 ` [PATCH v2 00/11] lib/vsprintf: refactor and introduce %pl specifier Andy Shevchenko

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=1452810221-116505-4-git-send-email-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=computersforpeace@gmail.com \
    --cc=elliott@hpe.com \
    --cc=hariprasad@chelsio.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=matt@codeblueprint.co.uk \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    /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

Powered by JetHome