Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1309712

[PATCH v2 11/11] pcmciamtd: print value in human-readable form via %.0plKM

From Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCH v2 11/11] pcmciamtd: print value in human-readable form via %.0plKM
Date 2016-01-14 23:30 +0100
Message-ID <qQYz0-5b5-23@gated-at.bofh.it> (permalink)
References <qQYz0-5b5-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Recently added %pl[From[To]] specifier is dedicated to print values in
human-readable format with IEC prefix. Convert the code to use it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mtd/maps/pcmciamtd.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index 70bb403..44c2fe9 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -589,19 +589,11 @@ static int pcmciamtd_config(struct pcmcia_device *link)
 	mtd->owner = THIS_MODULE;
 
 	if(new_name) {
-		int size = 0;
-		char unit = ' ';
 		/* Since we are using a default name, make it better by adding
 		 * in the size
 		 */
-		if(mtd->size < 1048576) { /* <1MiB in size, show size in KiB */
-			size = mtd->size >> 10;
-			unit = 'K';
-		} else {
-			size = mtd->size >> 20;
-			unit = 'M';
-		}
-		snprintf(dev->mtd_name, sizeof(dev->mtd_name), "%d%ciB %s", size, unit, "PCMCIA Memory card");
+		snprintf(dev->mtd_name, sizeof(dev->mtd_name), "%.0plKM %s",
+			 &mtd->size, "PCMCIA Memory card");
 	}
 
 	/* If the memory found is fits completely into the mapped PCMCIA window,
-- 
2.6.4

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 00/11] lib/vsprintf: refactor and introduce %pl specifier Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-01-14 23:30 +0100
  [PATCH v2 08/11] lib/vsprintf: allow range of prefix for %pl[From[To]] Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-01-14 23:30 +0100
    Re: [PATCH v2 08/11] lib/vsprintf: allow range of prefix for %pl[From[To]] Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-01-18 22:50 +0100
  [PATCH v2 02/11] lib/vsprintf: make default_dec_spec global Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-01-14 23:30 +0100
    Re: [PATCH v2 02/11] lib/vsprintf: make default_dec_spec global Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-01-18 21:40 +0100
  [PATCH v2 11/11] pcmciamtd: print value in human-readable form via %.0plKM Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-01-14 23:30 +0100
  [PATCH v2 04/11] lib/string_helpers: export string_units_{2,10} for others Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-01-14 23:30 +0100
  [PATCH v2 03/11] lib/vsprintf: make default_str_spec global Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-01-14 23:30 +0100
  [PATCH v2 07/11] x86/efi: print size and base in binary units in efi_print_memmap Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-01-14 23:30 +0100
  [PATCH v2 10/11] cxgb4: print value in human-readable form via %.0plKM Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-01-14 23:30 +0100
  [PATCH v2 05/11] lib/string_helpers: fix indentation in few places Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-01-14 23:30 +0100
  [PATCH v2 06/11] lib/vsprintf: introduce %pl to print in human-readable form Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-01-14 23:30 +0100
    Re: [PATCH v2 06/11] lib/vsprintf: introduce %pl to print in  human-readable form Joe Perches <joe@perches.com> - 2016-01-15 04:10 +0100
    Re: [PATCH v2 06/11] lib/vsprintf: introduce %pl to print in human-readable form Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-01-18 22:00 +0100
    Re: [PATCH v2 06/11] lib/vsprintf: introduce %pl to print in  human-readable form "H. Peter Anvin" <hpa@zytor.com> - 2016-01-21 22:20 +0100
  [PATCH v2 09/11] lib/vsprintf: use precision field with %pl[From[To]] Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-01-14 23:30 +0100
    Re: [PATCH v2 09/11] lib/vsprintf: use precision field with %pl[From[To]] Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-01-18 23:30 +0100
  [PATCH v2 01/11] lib/vsprintf: introduce put_one_char() for 3 line idiom Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-01-14 23:30 +0100
    Re: [PATCH v2 01/11] lib/vsprintf: introduce put_one_char() for 3 line idiom Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-01-18 21:40 +0100
  Re: [PATCH v2 00/11] lib/vsprintf: refactor and introduce %pl  specifier Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-01-21 14:00 +0100

csiph-web