mirror of https://gitee.com/openkylin/linux.git
mtd: tests: mtd_torturetest: Replace printk with pr_{info,crit}
Use pr_fmt instead of PRINT_PREF macro Signed-off-by: Vikram Narayanan <vikram186@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
This commit is contained in:
parent
cd66a2df7c
commit
95637c3a0e
|
@ -23,6 +23,8 @@
|
||||||
* damage caused by this program.
|
* damage caused by this program.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#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>
|
||||||
|
@ -31,7 +33,6 @@
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
|
|
||||||
#define PRINT_PREF KERN_INFO "mtd_torturetest: "
|
|
||||||
#define RETRIES 3
|
#define RETRIES 3
|
||||||
|
|
||||||
static int eb = 8;
|
static int eb = 8;
|
||||||
|
@ -107,12 +108,12 @@ static inline 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;
|
||||||
}
|
}
|
||||||
|
@ -139,40 +140,40 @@ static inline int check_eraseblock(int ebnum, unsigned char *buf)
|
||||||
retry:
|
retry:
|
||||||
err = mtd_read(mtd, addr, len, &read, check_buf);
|
err = mtd_read(mtd, addr, len, &read, check_buf);
|
||||||
if (mtd_is_bitflip(err))
|
if (mtd_is_bitflip(err))
|
||||||
printk(PRINT_PREF "single bit flip occurred at EB %d "
|
pr_err("single bit flip occurred at EB %d "
|
||||||
"MTD reported that it was fixed.\n", ebnum);
|
"MTD reported that it was fixed.\n", ebnum);
|
||||||
else if (err) {
|
else if (err) {
|
||||||
printk(PRINT_PREF "error %d while reading EB %d, "
|
pr_err("error %d while reading EB %d, "
|
||||||
"read %zd\n", err, ebnum, read);
|
"read %zd\n", err, ebnum, read);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read != len) {
|
if (read != len) {
|
||||||
printk(PRINT_PREF "failed to read %zd bytes from EB %d, "
|
pr_err("failed to read %zd bytes from EB %d, "
|
||||||
"read only %zd, but no error reported\n",
|
"read only %zd, but no error reported\n",
|
||||||
len, ebnum, read);
|
len, ebnum, read);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(buf, check_buf, len)) {
|
if (memcmp(buf, check_buf, len)) {
|
||||||
printk(PRINT_PREF "read wrong data from EB %d\n", ebnum);
|
pr_err("read wrong data from EB %d\n", ebnum);
|
||||||
report_corrupt(check_buf, buf);
|
report_corrupt(check_buf, buf);
|
||||||
|
|
||||||
if (retries++ < RETRIES) {
|
if (retries++ < RETRIES) {
|
||||||
/* Try read again */
|
/* Try read again */
|
||||||
yield();
|
yield();
|
||||||
printk(PRINT_PREF "re-try reading data from EB %d\n",
|
pr_info("re-try reading data from EB %d\n",
|
||||||
ebnum);
|
ebnum);
|
||||||
goto retry;
|
goto retry;
|
||||||
} else {
|
} else {
|
||||||
printk(PRINT_PREF "retried %d times, still errors, "
|
pr_info("retried %d times, still errors, "
|
||||||
"give-up\n", RETRIES);
|
"give-up\n", RETRIES);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retries != 0)
|
if (retries != 0)
|
||||||
printk(PRINT_PREF "only attempt number %d was OK (!!!)\n",
|
pr_info("only attempt number %d was OK (!!!)\n",
|
||||||
retries);
|
retries);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -191,12 +192,12 @@ static inline int write_pattern(int ebnum, void *buf)
|
||||||
}
|
}
|
||||||
err = mtd_write(mtd, addr, len, &written, buf);
|
err = mtd_write(mtd, addr, len, &written, buf);
|
||||||
if (err) {
|
if (err) {
|
||||||
printk(PRINT_PREF "error %d while writing EB %d, written %zd"
|
pr_err("error %d while writing EB %d, written %zd"
|
||||||
" bytes\n", err, ebnum, written);
|
" bytes\n", err, ebnum, written);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (written != len) {
|
if (written != len) {
|
||||||
printk(PRINT_PREF "written only %zd bytes of %zd, but no error"
|
pr_info("written only %zd bytes of %zd, but no error"
|
||||||
" reported\n", written, len);
|
" reported\n", written, len);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
@ -211,64 +212,64 @@ static int __init tort_init(void)
|
||||||
|
|
||||||
printk(KERN_INFO "\n");
|
printk(KERN_INFO "\n");
|
||||||
printk(KERN_INFO "=================================================\n");
|
printk(KERN_INFO "=================================================\n");
|
||||||
printk(PRINT_PREF "Warning: this program is trying to wear out your "
|
pr_info("Warning: this program is trying to wear out your "
|
||||||
"flash, stop it if this is not wanted.\n");
|
"flash, stop it if this is not wanted.\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);
|
||||||
printk(PRINT_PREF "torture %d eraseblocks (%d-%d) of mtd%d\n",
|
pr_info("torture %d eraseblocks (%d-%d) of mtd%d\n",
|
||||||
ebcnt, eb, eb + ebcnt - 1, dev);
|
ebcnt, eb, eb + ebcnt - 1, dev);
|
||||||
if (pgcnt)
|
if (pgcnt)
|
||||||
printk(PRINT_PREF "torturing just %d pages per eraseblock\n",
|
pr_info("torturing just %d pages per eraseblock\n",
|
||||||
pgcnt);
|
pgcnt);
|
||||||
printk(PRINT_PREF "write verify %s\n", check ? "enabled" : "disabled");
|
pr_info("write verify %s\n", check ? "enabled" : "disabled");
|
||||||
|
|
||||||
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
|
||||||
pgsize = mtd->writesize;
|
pgsize = mtd->writesize;
|
||||||
|
|
||||||
if (pgcnt && (pgcnt > mtd->erasesize / pgsize || pgcnt < 0)) {
|
if (pgcnt && (pgcnt > mtd->erasesize / pgsize || pgcnt < 0)) {
|
||||||
printk(PRINT_PREF "error: invalid pgcnt value %d\n", pgcnt);
|
pr_err("error: invalid pgcnt value %d\n", pgcnt);
|
||||||
goto out_mtd;
|
goto out_mtd;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
patt_5A5 = kmalloc(mtd->erasesize, GFP_KERNEL);
|
patt_5A5 = kmalloc(mtd->erasesize, GFP_KERNEL);
|
||||||
if (!patt_5A5) {
|
if (!patt_5A5) {
|
||||||
printk(PRINT_PREF "error: cannot allocate memory\n");
|
pr_err("error: cannot allocate memory\n");
|
||||||
goto out_mtd;
|
goto out_mtd;
|
||||||
}
|
}
|
||||||
|
|
||||||
patt_A5A = kmalloc(mtd->erasesize, GFP_KERNEL);
|
patt_A5A = kmalloc(mtd->erasesize, GFP_KERNEL);
|
||||||
if (!patt_A5A) {
|
if (!patt_A5A) {
|
||||||
printk(PRINT_PREF "error: cannot allocate memory\n");
|
pr_err("error: cannot allocate memory\n");
|
||||||
goto out_patt_5A5;
|
goto out_patt_5A5;
|
||||||
}
|
}
|
||||||
|
|
||||||
patt_FF = kmalloc(mtd->erasesize, GFP_KERNEL);
|
patt_FF = kmalloc(mtd->erasesize, GFP_KERNEL);
|
||||||
if (!patt_FF) {
|
if (!patt_FF) {
|
||||||
printk(PRINT_PREF "error: cannot allocate memory\n");
|
pr_err("error: cannot allocate memory\n");
|
||||||
goto out_patt_A5A;
|
goto out_patt_A5A;
|
||||||
}
|
}
|
||||||
|
|
||||||
check_buf = kmalloc(mtd->erasesize, GFP_KERNEL);
|
check_buf = kmalloc(mtd->erasesize, GFP_KERNEL);
|
||||||
if (!check_buf) {
|
if (!check_buf) {
|
||||||
printk(PRINT_PREF "error: cannot allocate memory\n");
|
pr_err("error: cannot allocate memory\n");
|
||||||
goto out_patt_FF;
|
goto out_patt_FF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,13 +296,13 @@ static int __init tort_init(void)
|
||||||
err = mtd_block_isbad(mtd, (loff_t)i * mtd->erasesize);
|
err = mtd_block_isbad(mtd, (loff_t)i * mtd->erasesize);
|
||||||
|
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
printk(PRINT_PREF "block_isbad() returned %d "
|
pr_info("block_isbad() returned %d "
|
||||||
"for EB %d\n", err, i);
|
"for EB %d\n", err, i);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
printk("EB %d is bad. Skip it.\n", i);
|
pr_err("EB %d is bad. Skip it.\n", i);
|
||||||
bad_ebs[i - eb] = 1;
|
bad_ebs[i - eb] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -329,7 +330,7 @@ static int __init tort_init(void)
|
||||||
continue;
|
continue;
|
||||||
err = check_eraseblock(i, patt_FF);
|
err = check_eraseblock(i, patt_FF);
|
||||||
if (err) {
|
if (err) {
|
||||||
printk(PRINT_PREF "verify failed"
|
pr_info("verify failed"
|
||||||
" for 0xFF... pattern\n");
|
" for 0xFF... pattern\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -362,7 +363,7 @@ static int __init tort_init(void)
|
||||||
patt = patt_A5A;
|
patt = patt_A5A;
|
||||||
err = check_eraseblock(i, patt);
|
err = check_eraseblock(i, patt);
|
||||||
if (err) {
|
if (err) {
|
||||||
printk(PRINT_PREF "verify failed for %s"
|
pr_info("verify failed for %s"
|
||||||
" pattern\n",
|
" pattern\n",
|
||||||
((eb + erase_cycles) & 1) ?
|
((eb + erase_cycles) & 1) ?
|
||||||
"0x55AA55..." : "0xAA55AA...");
|
"0x55AA55..." : "0xAA55AA...");
|
||||||
|
@ -380,7 +381,7 @@ static int __init tort_init(void)
|
||||||
stop_timing();
|
stop_timing();
|
||||||
ms = (finish.tv_sec - start.tv_sec) * 1000 +
|
ms = (finish.tv_sec - start.tv_sec) * 1000 +
|
||||||
(finish.tv_usec - start.tv_usec) / 1000;
|
(finish.tv_usec - start.tv_usec) / 1000;
|
||||||
printk(PRINT_PREF "%08u erase cycles done, took %lu "
|
pr_info("%08u erase cycles done, took %lu "
|
||||||
"milliseconds (%lu seconds)\n",
|
"milliseconds (%lu seconds)\n",
|
||||||
erase_cycles, ms, ms / 1000);
|
erase_cycles, ms, ms / 1000);
|
||||||
start_timing();
|
start_timing();
|
||||||
|
@ -391,7 +392,7 @@ static int __init tort_init(void)
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
|
|
||||||
printk(PRINT_PREF "finished after %u erase cycles\n",
|
pr_info("finished after %u erase cycles\n",
|
||||||
erase_cycles);
|
erase_cycles);
|
||||||
kfree(check_buf);
|
kfree(check_buf);
|
||||||
out_patt_FF:
|
out_patt_FF:
|
||||||
|
@ -403,7 +404,7 @@ static int __init tort_init(void)
|
||||||
out_mtd:
|
out_mtd:
|
||||||
put_mtd_device(mtd);
|
put_mtd_device(mtd);
|
||||||
if (err)
|
if (err)
|
||||||
printk(PRINT_PREF "error %d occurred during torturing\n", err);
|
pr_info("error %d occurred during torturing\n", err);
|
||||||
printk(KERN_INFO "=================================================\n");
|
printk(KERN_INFO "=================================================\n");
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -441,9 +442,9 @@ static void report_corrupt(unsigned char *read, unsigned char *written)
|
||||||
&bits) >= 0)
|
&bits) >= 0)
|
||||||
pages++;
|
pages++;
|
||||||
|
|
||||||
printk(PRINT_PREF "verify fails on %d pages, %d bytes/%d bits\n",
|
pr_info("verify fails on %d pages, %d bytes/%d bits\n",
|
||||||
pages, bytes, bits);
|
pages, bytes, bits);
|
||||||
printk(PRINT_PREF "The following is a list of all differences between"
|
pr_info("The following is a list of all differences between"
|
||||||
" what was read from flash and what was expected\n");
|
" what was read from flash and what was expected\n");
|
||||||
|
|
||||||
for (i = 0; i < check_len; i += pgsize) {
|
for (i = 0; i < check_len; i += pgsize) {
|
||||||
|
@ -457,7 +458,7 @@ static void report_corrupt(unsigned char *read, unsigned char *written)
|
||||||
printk("-------------------------------------------------------"
|
printk("-------------------------------------------------------"
|
||||||
"----------------------------------\n");
|
"----------------------------------\n");
|
||||||
|
|
||||||
printk(PRINT_PREF "Page %zd has %d bytes/%d bits failing verify,"
|
pr_info("Page %zd has %d bytes/%d bits failing verify,"
|
||||||
" starting at offset 0x%x\n",
|
" starting at offset 0x%x\n",
|
||||||
(mtd->erasesize - check_len + i) / pgsize,
|
(mtd->erasesize - check_len + i) / pgsize,
|
||||||
bytes, bits, first);
|
bytes, bits, first);
|
||||||
|
|
Loading…
Reference in New Issue