Commit e45048a6 authored by Vikram Narayanan's avatar Vikram Narayanan Committed by Artem Bityutskiy

mtd: tests: mtd_readtest: Replace printk with pr_{info,err}

Use pr_fmt instead of PRINT_PREF macro
Signed-off-by: default avatarVikram Narayanan <vikram186@gmail.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
parent bb998419
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
* Author: Adrian Hunter <ext-adrian.hunter@nokia.com> * Author: Adrian Hunter <ext-adrian.hunter@nokia.com>
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
...@@ -27,8 +29,6 @@ ...@@ -27,8 +29,6 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/sched.h> #include <linux/sched.h>
#define PRINT_PREF KERN_INFO "mtd_readtest: "
static int dev = -EINVAL; static int dev = -EINVAL;
module_param(dev, int, S_IRUGO); module_param(dev, int, S_IRUGO);
MODULE_PARM_DESC(dev, "MTD device number to use"); MODULE_PARM_DESC(dev, "MTD device number to use");
...@@ -56,7 +56,7 @@ static int read_eraseblock_by_page(int ebnum) ...@@ -56,7 +56,7 @@ static int read_eraseblock_by_page(int ebnum)
if (ret == -EUCLEAN) if (ret == -EUCLEAN)
ret = 0; ret = 0;
if (ret || read != pgsize) { if (ret || read != pgsize) {
printk(PRINT_PREF "error: read failed at %#llx\n", pr_err("error: read failed at %#llx\n",
(long long)addr); (long long)addr);
if (!err) if (!err)
err = ret; err = ret;
...@@ -77,7 +77,7 @@ static int read_eraseblock_by_page(int ebnum) ...@@ -77,7 +77,7 @@ static int read_eraseblock_by_page(int ebnum)
ret = mtd_read_oob(mtd, addr, &ops); ret = mtd_read_oob(mtd, addr, &ops);
if ((ret && !mtd_is_bitflip(ret)) || if ((ret && !mtd_is_bitflip(ret)) ||
ops.oobretlen != mtd->oobsize) { ops.oobretlen != mtd->oobsize) {
printk(PRINT_PREF "error: read oob failed at " pr_err("error: read oob failed at "
"%#llx\n", (long long)addr); "%#llx\n", (long long)addr);
if (!err) if (!err)
err = ret; err = ret;
...@@ -99,7 +99,7 @@ static void dump_eraseblock(int ebnum) ...@@ -99,7 +99,7 @@ static void dump_eraseblock(int ebnum)
char line[128]; char line[128];
int pg, oob; int pg, oob;
printk(PRINT_PREF "dumping eraseblock %d\n", ebnum); pr_info("dumping eraseblock %d\n", ebnum);
n = mtd->erasesize; n = mtd->erasesize;
for (i = 0; i < n;) { for (i = 0; i < n;) {
char *p = line; char *p = line;
...@@ -112,7 +112,7 @@ static void dump_eraseblock(int ebnum) ...@@ -112,7 +112,7 @@ static void dump_eraseblock(int ebnum)
} }
if (!mtd->oobsize) if (!mtd->oobsize)
return; return;
printk(PRINT_PREF "dumping oob from eraseblock %d\n", ebnum); pr_info("dumping oob from eraseblock %d\n", ebnum);
n = mtd->oobsize; n = mtd->oobsize;
for (pg = 0, i = 0; pg < pgcnt; pg++) for (pg = 0, i = 0; pg < pgcnt; pg++)
for (oob = 0; oob < n;) { for (oob = 0; oob < n;) {
...@@ -134,7 +134,7 @@ static int is_block_bad(int ebnum) ...@@ -134,7 +134,7 @@ static int is_block_bad(int ebnum)
ret = mtd_block_isbad(mtd, addr); ret = mtd_block_isbad(mtd, addr);
if (ret) if (ret)
printk(PRINT_PREF "block %d is bad\n", ebnum); pr_info("block %d is bad\n", ebnum);
return ret; return ret;
} }
...@@ -144,21 +144,21 @@ static int scan_for_bad_eraseblocks(void) ...@@ -144,21 +144,21 @@ static int scan_for_bad_eraseblocks(void)
bbt = kzalloc(ebcnt, GFP_KERNEL); bbt = kzalloc(ebcnt, GFP_KERNEL);
if (!bbt) { if (!bbt) {
printk(PRINT_PREF "error: cannot allocate memory\n"); pr_err("error: cannot allocate memory\n");
return -ENOMEM; return -ENOMEM;
} }
if (!mtd_can_have_bb(mtd)) if (!mtd_can_have_bb(mtd))
return 0; return 0;
printk(PRINT_PREF "scanning for bad eraseblocks\n"); pr_info("scanning for bad eraseblocks\n");
for (i = 0; i < ebcnt; ++i) { for (i = 0; i < ebcnt; ++i) {
bbt[i] = is_block_bad(i) ? 1 : 0; bbt[i] = is_block_bad(i) ? 1 : 0;
if (bbt[i]) if (bbt[i])
bad += 1; bad += 1;
cond_resched(); cond_resched();
} }
printk(PRINT_PREF "scanned %d eraseblocks, %d are bad\n", i, bad); pr_info("scanned %d eraseblocks, %d are bad\n", i, bad);
return 0; return 0;
} }
...@@ -171,21 +171,21 @@ static int __init mtd_readtest_init(void) ...@@ -171,21 +171,21 @@ static int __init mtd_readtest_init(void)
printk(KERN_INFO "=================================================\n"); printk(KERN_INFO "=================================================\n");
if (dev < 0) { if (dev < 0) {
printk(PRINT_PREF "Please specify a valid mtd-device via module paramter\n"); pr_info("Please specify a valid mtd-device via module paramter\n");
return -EINVAL; return -EINVAL;
} }
printk(PRINT_PREF "MTD device: %d\n", dev); pr_info("MTD device: %d\n", dev);
mtd = get_mtd_device(NULL, dev); mtd = get_mtd_device(NULL, dev);
if (IS_ERR(mtd)) { if (IS_ERR(mtd)) {
err = PTR_ERR(mtd); err = PTR_ERR(mtd);
printk(PRINT_PREF "error: Cannot get MTD device\n"); pr_err("error: Cannot get MTD device\n");
return err; return err;
} }
if (mtd->writesize == 1) { if (mtd->writesize == 1) {
printk(PRINT_PREF "not NAND flash, assume page size is 512 " pr_info("not NAND flash, assume page size is 512 "
"bytes.\n"); "bytes.\n");
pgsize = 512; pgsize = 512;
} else } else
...@@ -196,7 +196,7 @@ static int __init mtd_readtest_init(void) ...@@ -196,7 +196,7 @@ static int __init mtd_readtest_init(void)
ebcnt = tmp; ebcnt = tmp;
pgcnt = mtd->erasesize / pgsize; pgcnt = mtd->erasesize / pgsize;
printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, " pr_info("MTD device size %llu, eraseblock size %u, "
"page size %u, count of eraseblocks %u, pages per " "page size %u, count of eraseblocks %u, pages per "
"eraseblock %u, OOB size %u\n", "eraseblock %u, OOB size %u\n",
(unsigned long long)mtd->size, mtd->erasesize, (unsigned long long)mtd->size, mtd->erasesize,
...@@ -205,12 +205,12 @@ static int __init mtd_readtest_init(void) ...@@ -205,12 +205,12 @@ static int __init mtd_readtest_init(void)
err = -ENOMEM; err = -ENOMEM;
iobuf = kmalloc(mtd->erasesize, GFP_KERNEL); iobuf = kmalloc(mtd->erasesize, GFP_KERNEL);
if (!iobuf) { if (!iobuf) {
printk(PRINT_PREF "error: cannot allocate memory\n"); pr_err("error: cannot allocate memory\n");
goto out; goto out;
} }
iobuf1 = kmalloc(mtd->erasesize, GFP_KERNEL); iobuf1 = kmalloc(mtd->erasesize, GFP_KERNEL);
if (!iobuf1) { if (!iobuf1) {
printk(PRINT_PREF "error: cannot allocate memory\n"); pr_err("error: cannot allocate memory\n");
goto out; goto out;
} }
...@@ -219,7 +219,7 @@ static int __init mtd_readtest_init(void) ...@@ -219,7 +219,7 @@ static int __init mtd_readtest_init(void)
goto out; goto out;
/* Read all eraseblocks 1 page at a time */ /* Read all eraseblocks 1 page at a time */
printk(PRINT_PREF "testing page read\n"); pr_info("testing page read\n");
for (i = 0; i < ebcnt; ++i) { for (i = 0; i < ebcnt; ++i) {
int ret; int ret;
...@@ -235,9 +235,9 @@ static int __init mtd_readtest_init(void) ...@@ -235,9 +235,9 @@ static int __init mtd_readtest_init(void)
} }
if (err) if (err)
printk(PRINT_PREF "finished with errors\n"); pr_info("finished with errors\n");
else else
printk(PRINT_PREF "finished\n"); pr_info("finished\n");
out: out:
...@@ -246,7 +246,7 @@ static int __init mtd_readtest_init(void) ...@@ -246,7 +246,7 @@ static int __init mtd_readtest_init(void)
kfree(bbt); kfree(bbt);
put_mtd_device(mtd); put_mtd_device(mtd);
if (err) if (err)
printk(PRINT_PREF "error %d occurred\n", err); pr_info("error %d occurred\n", err);
printk(KERN_INFO "=================================================\n"); printk(KERN_INFO "=================================================\n");
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment