提交 cd66a2df 编写于 作者: V Vikram Narayanan 提交者: Artem Bityutskiy

mtd: tests: mtd_subpagetest: replace printk with pr_{info,crit,err}

Use pr_fmt instead of PRINT_PREF macro
Signed-off-by: NVikram Narayanan <vikram186@gmail.com>
Signed-off-by: NArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
上级 2c70d292
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
* *
*/ */
#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_subpagetest: "
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");
...@@ -82,12 +82,12 @@ static int erase_eraseblock(int ebnum) ...@@ -82,12 +82,12 @@ static int erase_eraseblock(int ebnum)
err = mtd_erase(mtd, &ei); err = mtd_erase(mtd, &ei);
if (err) { if (err) {
printk(PRINT_PREF "error %d while erasing EB %d\n", err, ebnum); pr_err("error %d while erasing EB %d\n", err, ebnum);
return err; return err;
} }
if (ei.state == MTD_ERASE_FAILED) { if (ei.state == MTD_ERASE_FAILED) {
printk(PRINT_PREF "some erase error occurred at EB %d\n", pr_err("some erase error occurred at EB %d\n",
ebnum); ebnum);
return -EIO; return -EIO;
} }
...@@ -100,7 +100,7 @@ static int erase_whole_device(void) ...@@ -100,7 +100,7 @@ static int erase_whole_device(void)
int err; int err;
unsigned int i; unsigned int i;
printk(PRINT_PREF "erasing whole device\n"); pr_info("erasing whole device\n");
for (i = 0; i < ebcnt; ++i) { for (i = 0; i < ebcnt; ++i) {
if (bbt[i]) if (bbt[i])
continue; continue;
...@@ -109,7 +109,7 @@ static int erase_whole_device(void) ...@@ -109,7 +109,7 @@ static int erase_whole_device(void)
return err; return err;
cond_resched(); cond_resched();
} }
printk(PRINT_PREF "erased %u eraseblocks\n", i); pr_info("erased %u eraseblocks\n", i);
return 0; return 0;
} }
...@@ -122,11 +122,11 @@ static int write_eraseblock(int ebnum) ...@@ -122,11 +122,11 @@ static int write_eraseblock(int ebnum)
set_random_data(writebuf, subpgsize); set_random_data(writebuf, subpgsize);
err = mtd_write(mtd, addr, subpgsize, &written, writebuf); err = mtd_write(mtd, addr, subpgsize, &written, writebuf);
if (unlikely(err || written != subpgsize)) { if (unlikely(err || written != subpgsize)) {
printk(PRINT_PREF "error: write failed at %#llx\n", pr_err("error: write failed at %#llx\n",
(long long)addr); (long long)addr);
if (written != subpgsize) { if (written != subpgsize) {
printk(PRINT_PREF " write size: %#x\n", subpgsize); pr_err(" write size: %#x\n", subpgsize);
printk(PRINT_PREF " written: %#zx\n", written); pr_err(" written: %#zx\n", written);
} }
return err ? err : -1; return err ? err : -1;
} }
...@@ -136,11 +136,11 @@ static int write_eraseblock(int ebnum) ...@@ -136,11 +136,11 @@ static int write_eraseblock(int ebnum)
set_random_data(writebuf, subpgsize); set_random_data(writebuf, subpgsize);
err = mtd_write(mtd, addr, subpgsize, &written, writebuf); err = mtd_write(mtd, addr, subpgsize, &written, writebuf);
if (unlikely(err || written != subpgsize)) { if (unlikely(err || written != subpgsize)) {
printk(PRINT_PREF "error: write failed at %#llx\n", pr_err("error: write failed at %#llx\n",
(long long)addr); (long long)addr);
if (written != subpgsize) { if (written != subpgsize) {
printk(PRINT_PREF " write size: %#x\n", subpgsize); pr_err(" write size: %#x\n", subpgsize);
printk(PRINT_PREF " written: %#zx\n", written); pr_err(" written: %#zx\n", written);
} }
return err ? err : -1; return err ? err : -1;
} }
...@@ -160,12 +160,12 @@ static int write_eraseblock2(int ebnum) ...@@ -160,12 +160,12 @@ static int write_eraseblock2(int ebnum)
set_random_data(writebuf, subpgsize * k); set_random_data(writebuf, subpgsize * k);
err = mtd_write(mtd, addr, subpgsize * k, &written, writebuf); err = mtd_write(mtd, addr, subpgsize * k, &written, writebuf);
if (unlikely(err || written != subpgsize * k)) { if (unlikely(err || written != subpgsize * k)) {
printk(PRINT_PREF "error: write failed at %#llx\n", pr_err("error: write failed at %#llx\n",
(long long)addr); (long long)addr);
if (written != subpgsize) { if (written != subpgsize) {
printk(PRINT_PREF " write size: %#x\n", pr_err(" write size: %#x\n",
subpgsize * k); subpgsize * k);
printk(PRINT_PREF " written: %#08zx\n", pr_err(" written: %#08zx\n",
written); written);
} }
return err ? err : -1; return err ? err : -1;
...@@ -198,23 +198,23 @@ static int verify_eraseblock(int ebnum) ...@@ -198,23 +198,23 @@ static int verify_eraseblock(int ebnum)
err = mtd_read(mtd, addr, subpgsize, &read, readbuf); err = mtd_read(mtd, addr, subpgsize, &read, readbuf);
if (unlikely(err || read != subpgsize)) { if (unlikely(err || read != subpgsize)) {
if (mtd_is_bitflip(err) && read == subpgsize) { if (mtd_is_bitflip(err) && read == subpgsize) {
printk(PRINT_PREF "ECC correction at %#llx\n", pr_info("ECC correction at %#llx\n",
(long long)addr); (long long)addr);
err = 0; err = 0;
} else { } else {
printk(PRINT_PREF "error: read failed at %#llx\n", pr_err("error: read failed at %#llx\n",
(long long)addr); (long long)addr);
return err ? err : -1; return err ? err : -1;
} }
} }
if (unlikely(memcmp(readbuf, writebuf, subpgsize))) { if (unlikely(memcmp(readbuf, writebuf, subpgsize))) {
printk(PRINT_PREF "error: verify failed at %#llx\n", pr_err("error: verify failed at %#llx\n",
(long long)addr); (long long)addr);
printk(PRINT_PREF "------------- written----------------\n"); pr_info("------------- written----------------\n");
print_subpage(writebuf); print_subpage(writebuf);
printk(PRINT_PREF "------------- read ------------------\n"); pr_info("------------- read ------------------\n");
print_subpage(readbuf); print_subpage(readbuf);
printk(PRINT_PREF "-------------------------------------\n"); pr_info("-------------------------------------\n");
errcnt += 1; errcnt += 1;
} }
...@@ -225,23 +225,23 @@ static int verify_eraseblock(int ebnum) ...@@ -225,23 +225,23 @@ static int verify_eraseblock(int ebnum)
err = mtd_read(mtd, addr, subpgsize, &read, readbuf); err = mtd_read(mtd, addr, subpgsize, &read, readbuf);
if (unlikely(err || read != subpgsize)) { if (unlikely(err || read != subpgsize)) {
if (mtd_is_bitflip(err) && read == subpgsize) { if (mtd_is_bitflip(err) && read == subpgsize) {
printk(PRINT_PREF "ECC correction at %#llx\n", pr_info("ECC correction at %#llx\n",
(long long)addr); (long long)addr);
err = 0; err = 0;
} else { } else {
printk(PRINT_PREF "error: read failed at %#llx\n", pr_err("error: read failed at %#llx\n",
(long long)addr); (long long)addr);
return err ? err : -1; return err ? err : -1;
} }
} }
if (unlikely(memcmp(readbuf, writebuf, subpgsize))) { if (unlikely(memcmp(readbuf, writebuf, subpgsize))) {
printk(PRINT_PREF "error: verify failed at %#llx\n", pr_info("error: verify failed at %#llx\n",
(long long)addr); (long long)addr);
printk(PRINT_PREF "------------- written----------------\n"); pr_info("------------- written----------------\n");
print_subpage(writebuf); print_subpage(writebuf);
printk(PRINT_PREF "------------- read ------------------\n"); pr_info("------------- read ------------------\n");
print_subpage(readbuf); print_subpage(readbuf);
printk(PRINT_PREF "-------------------------------------\n"); pr_info("-------------------------------------\n");
errcnt += 1; errcnt += 1;
} }
...@@ -262,17 +262,17 @@ static int verify_eraseblock2(int ebnum) ...@@ -262,17 +262,17 @@ static int verify_eraseblock2(int ebnum)
err = mtd_read(mtd, addr, subpgsize * k, &read, readbuf); err = mtd_read(mtd, addr, subpgsize * k, &read, readbuf);
if (unlikely(err || read != subpgsize * k)) { if (unlikely(err || read != subpgsize * k)) {
if (mtd_is_bitflip(err) && read == subpgsize * k) { if (mtd_is_bitflip(err) && read == subpgsize * k) {
printk(PRINT_PREF "ECC correction at %#llx\n", pr_info("ECC correction at %#llx\n",
(long long)addr); (long long)addr);
err = 0; err = 0;
} else { } else {
printk(PRINT_PREF "error: read failed at " pr_err("error: read failed at "
"%#llx\n", (long long)addr); "%#llx\n", (long long)addr);
return err ? err : -1; return err ? err : -1;
} }
} }
if (unlikely(memcmp(readbuf, writebuf, subpgsize * k))) { if (unlikely(memcmp(readbuf, writebuf, subpgsize * k))) {
printk(PRINT_PREF "error: verify failed at %#llx\n", pr_err("error: verify failed at %#llx\n",
(long long)addr); (long long)addr);
errcnt += 1; errcnt += 1;
} }
...@@ -295,17 +295,17 @@ static int verify_eraseblock_ff(int ebnum) ...@@ -295,17 +295,17 @@ static int verify_eraseblock_ff(int ebnum)
err = mtd_read(mtd, addr, subpgsize, &read, readbuf); err = mtd_read(mtd, addr, subpgsize, &read, readbuf);
if (unlikely(err || read != subpgsize)) { if (unlikely(err || read != subpgsize)) {
if (mtd_is_bitflip(err) && read == subpgsize) { if (mtd_is_bitflip(err) && read == subpgsize) {
printk(PRINT_PREF "ECC correction at %#llx\n", pr_info("ECC correction at %#llx\n",
(long long)addr); (long long)addr);
err = 0; err = 0;
} else { } else {
printk(PRINT_PREF "error: read failed at " pr_err("error: read failed at "
"%#llx\n", (long long)addr); "%#llx\n", (long long)addr);
return err ? err : -1; return err ? err : -1;
} }
} }
if (unlikely(memcmp(readbuf, writebuf, subpgsize))) { if (unlikely(memcmp(readbuf, writebuf, subpgsize))) {
printk(PRINT_PREF "error: verify 0xff failed at " pr_err("error: verify 0xff failed at "
"%#llx\n", (long long)addr); "%#llx\n", (long long)addr);
errcnt += 1; errcnt += 1;
} }
...@@ -320,7 +320,7 @@ static int verify_all_eraseblocks_ff(void) ...@@ -320,7 +320,7 @@ static int verify_all_eraseblocks_ff(void)
int err; int err;
unsigned int i; unsigned int i;
printk(PRINT_PREF "verifying all eraseblocks for 0xff\n"); pr_info("verifying all eraseblocks for 0xff\n");
for (i = 0; i < ebcnt; ++i) { for (i = 0; i < ebcnt; ++i) {
if (bbt[i]) if (bbt[i])
continue; continue;
...@@ -328,10 +328,10 @@ static int verify_all_eraseblocks_ff(void) ...@@ -328,10 +328,10 @@ static int verify_all_eraseblocks_ff(void)
if (err) if (err)
return err; return err;
if (i % 256 == 0) if (i % 256 == 0)
printk(PRINT_PREF "verified up to eraseblock %u\n", i); pr_info("verified up to eraseblock %u\n", i);
cond_resched(); cond_resched();
} }
printk(PRINT_PREF "verified %u eraseblocks\n", i); pr_info("verified %u eraseblocks\n", i);
return 0; return 0;
} }
...@@ -342,7 +342,7 @@ static int is_block_bad(int ebnum) ...@@ -342,7 +342,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;
} }
...@@ -352,18 +352,18 @@ static int scan_for_bad_eraseblocks(void) ...@@ -352,18 +352,18 @@ 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;
} }
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;
} }
...@@ -377,22 +377,22 @@ static int __init mtd_subpagetest_init(void) ...@@ -377,22 +377,22 @@ static int __init mtd_subpagetest_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");
printk(KERN_CRIT "CAREFUL: This test wipes all data on the specified MTD device!\n"); pr_crit("CAREFUL: This test wipes all data on the specified MTD device!\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->type != MTD_NANDFLASH) { if (mtd->type != MTD_NANDFLASH) {
printk(PRINT_PREF "this test requires NAND flash\n"); pr_info("this test requires NAND flash\n");
goto out; goto out;
} }
...@@ -402,7 +402,7 @@ static int __init mtd_subpagetest_init(void) ...@@ -402,7 +402,7 @@ static int __init mtd_subpagetest_init(void)
ebcnt = tmp; ebcnt = tmp;
pgcnt = mtd->erasesize / mtd->writesize; pgcnt = mtd->erasesize / mtd->writesize;
printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, " pr_info("MTD device size %llu, eraseblock size %u, "
"page size %u, subpage size %u, count of eraseblocks %u, " "page size %u, subpage size %u, count of eraseblocks %u, "
"pages per eraseblock %u, OOB size %u\n", "pages per eraseblock %u, OOB size %u\n",
(unsigned long long)mtd->size, mtd->erasesize, (unsigned long long)mtd->size, mtd->erasesize,
...@@ -412,12 +412,12 @@ static int __init mtd_subpagetest_init(void) ...@@ -412,12 +412,12 @@ static int __init mtd_subpagetest_init(void)
bufsize = subpgsize * 32; bufsize = subpgsize * 32;
writebuf = kmalloc(bufsize, GFP_KERNEL); writebuf = kmalloc(bufsize, GFP_KERNEL);
if (!writebuf) { if (!writebuf) {
printk(PRINT_PREF "error: cannot allocate memory\n"); pr_info("error: cannot allocate memory\n");
goto out; goto out;
} }
readbuf = kmalloc(bufsize, GFP_KERNEL); readbuf = kmalloc(bufsize, GFP_KERNEL);
if (!readbuf) { if (!readbuf) {
printk(PRINT_PREF "error: cannot allocate memory\n"); pr_info("error: cannot allocate memory\n");
goto out; goto out;
} }
...@@ -429,7 +429,7 @@ static int __init mtd_subpagetest_init(void) ...@@ -429,7 +429,7 @@ static int __init mtd_subpagetest_init(void)
if (err) if (err)
goto out; goto out;
printk(PRINT_PREF "writing whole device\n"); pr_info("writing whole device\n");
simple_srand(1); simple_srand(1);
for (i = 0; i < ebcnt; ++i) { for (i = 0; i < ebcnt; ++i) {
if (bbt[i]) if (bbt[i])
...@@ -438,13 +438,13 @@ static int __init mtd_subpagetest_init(void) ...@@ -438,13 +438,13 @@ static int __init mtd_subpagetest_init(void)
if (unlikely(err)) if (unlikely(err))
goto out; goto out;
if (i % 256 == 0) if (i % 256 == 0)
printk(PRINT_PREF "written up to eraseblock %u\n", i); pr_info("written up to eraseblock %u\n", i);
cond_resched(); cond_resched();
} }
printk(PRINT_PREF "written %u eraseblocks\n", i); pr_info("written %u eraseblocks\n", i);
simple_srand(1); simple_srand(1);
printk(PRINT_PREF "verifying all eraseblocks\n"); pr_info("verifying all eraseblocks\n");
for (i = 0; i < ebcnt; ++i) { for (i = 0; i < ebcnt; ++i) {
if (bbt[i]) if (bbt[i])
continue; continue;
...@@ -452,10 +452,10 @@ static int __init mtd_subpagetest_init(void) ...@@ -452,10 +452,10 @@ static int __init mtd_subpagetest_init(void)
if (unlikely(err)) if (unlikely(err))
goto out; goto out;
if (i % 256 == 0) if (i % 256 == 0)
printk(PRINT_PREF "verified up to eraseblock %u\n", i); pr_info("verified up to eraseblock %u\n", i);
cond_resched(); cond_resched();
} }
printk(PRINT_PREF "verified %u eraseblocks\n", i); pr_info("verified %u eraseblocks\n", i);
err = erase_whole_device(); err = erase_whole_device();
if (err) if (err)
...@@ -467,7 +467,7 @@ static int __init mtd_subpagetest_init(void) ...@@ -467,7 +467,7 @@ static int __init mtd_subpagetest_init(void)
/* Write all eraseblocks */ /* Write all eraseblocks */
simple_srand(3); simple_srand(3);
printk(PRINT_PREF "writing whole device\n"); pr_info("writing whole device\n");
for (i = 0; i < ebcnt; ++i) { for (i = 0; i < ebcnt; ++i) {
if (bbt[i]) if (bbt[i])
continue; continue;
...@@ -475,14 +475,14 @@ static int __init mtd_subpagetest_init(void) ...@@ -475,14 +475,14 @@ static int __init mtd_subpagetest_init(void)
if (unlikely(err)) if (unlikely(err))
goto out; goto out;
if (i % 256 == 0) if (i % 256 == 0)
printk(PRINT_PREF "written up to eraseblock %u\n", i); pr_info("written up to eraseblock %u\n", i);
cond_resched(); cond_resched();
} }
printk(PRINT_PREF "written %u eraseblocks\n", i); pr_info("written %u eraseblocks\n", i);
/* Check all eraseblocks */ /* Check all eraseblocks */
simple_srand(3); simple_srand(3);
printk(PRINT_PREF "verifying all eraseblocks\n"); pr_info("verifying all eraseblocks\n");
for (i = 0; i < ebcnt; ++i) { for (i = 0; i < ebcnt; ++i) {
if (bbt[i]) if (bbt[i])
continue; continue;
...@@ -490,10 +490,10 @@ static int __init mtd_subpagetest_init(void) ...@@ -490,10 +490,10 @@ static int __init mtd_subpagetest_init(void)
if (unlikely(err)) if (unlikely(err))
goto out; goto out;
if (i % 256 == 0) if (i % 256 == 0)
printk(PRINT_PREF "verified up to eraseblock %u\n", i); pr_info("verified up to eraseblock %u\n", i);
cond_resched(); cond_resched();
} }
printk(PRINT_PREF "verified %u eraseblocks\n", i); pr_info("verified %u eraseblocks\n", i);
err = erase_whole_device(); err = erase_whole_device();
if (err) if (err)
...@@ -503,7 +503,7 @@ static int __init mtd_subpagetest_init(void) ...@@ -503,7 +503,7 @@ static int __init mtd_subpagetest_init(void)
if (err) if (err)
goto out; goto out;
printk(PRINT_PREF "finished with %d errors\n", errcnt); pr_info("finished with %d errors\n", errcnt);
out: out:
kfree(bbt); kfree(bbt);
...@@ -511,7 +511,7 @@ static int __init mtd_subpagetest_init(void) ...@@ -511,7 +511,7 @@ static int __init mtd_subpagetest_init(void)
kfree(writebuf); kfree(writebuf);
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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册