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

From: Andy Shevchenko
Date: Thu Jan 14 2016 - 17:24:03 EST


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@xxxxxxxxxxxxxxx>
---
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