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

mtd: tests: mtd_nandbiterrs: replace msg macro with pr_{info,err}

Use pr_fmt instead of msg macro
Signed-off-by: NVikram Narayanan <vikram186@gmail.com>
Signed-off-by: NArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
上级 a90019e2
...@@ -39,6 +39,9 @@ ...@@ -39,6 +39,9 @@
* this program; see the file COPYING. If not, write to the Free Software * this program; see the file COPYING. If not, write to the Free Software
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#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>
...@@ -47,8 +50,6 @@ ...@@ -47,8 +50,6 @@
#include <linux/mtd/nand.h> #include <linux/mtd/nand.h>
#include <linux/slab.h> #include <linux/slab.h>
#define msg(FMT, VA...) pr_info("mtd_nandbiterrs: "FMT, ##VA)
static int dev; static int dev;
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");
...@@ -103,7 +104,7 @@ static int erase_block(void) ...@@ -103,7 +104,7 @@ static int erase_block(void)
struct erase_info ei; struct erase_info ei;
loff_t addr = eraseblock * mtd->erasesize; loff_t addr = eraseblock * mtd->erasesize;
msg("erase_block\n"); pr_info("erase_block\n");
memset(&ei, 0, sizeof(struct erase_info)); memset(&ei, 0, sizeof(struct erase_info));
ei.mtd = mtd; ei.mtd = mtd;
...@@ -112,7 +113,7 @@ static int erase_block(void) ...@@ -112,7 +113,7 @@ static int erase_block(void)
err = mtd_erase(mtd, &ei); err = mtd_erase(mtd, &ei);
if (err || ei.state == MTD_ERASE_FAILED) { if (err || ei.state == MTD_ERASE_FAILED) {
msg("error %d while erasing\n", err); pr_err("error %d while erasing\n", err);
if (!err) if (!err)
err = -EIO; err = -EIO;
return err; return err;
...@@ -128,11 +129,11 @@ static int write_page(int log) ...@@ -128,11 +129,11 @@ static int write_page(int log)
size_t written; size_t written;
if (log) if (log)
msg("write_page\n"); pr_info("write_page\n");
err = mtd_write(mtd, offset, mtd->writesize, &written, wbuffer); err = mtd_write(mtd, offset, mtd->writesize, &written, wbuffer);
if (err || written != mtd->writesize) { if (err || written != mtd->writesize) {
msg("error: write failed at %#llx\n", (long long)offset); pr_err("error: write failed at %#llx\n", (long long)offset);
if (!err) if (!err)
err = -EIO; err = -EIO;
} }
...@@ -147,7 +148,7 @@ static int rewrite_page(int log) ...@@ -147,7 +148,7 @@ static int rewrite_page(int log)
struct mtd_oob_ops ops; struct mtd_oob_ops ops;
if (log) if (log)
msg("rewrite page\n"); pr_info("rewrite page\n");
ops.mode = MTD_OPS_RAW; /* No ECC */ ops.mode = MTD_OPS_RAW; /* No ECC */
ops.len = mtd->writesize; ops.len = mtd->writesize;
...@@ -160,7 +161,7 @@ static int rewrite_page(int log) ...@@ -160,7 +161,7 @@ static int rewrite_page(int log)
err = mtd_write_oob(mtd, offset, &ops); err = mtd_write_oob(mtd, offset, &ops);
if (err || ops.retlen != mtd->writesize) { if (err || ops.retlen != mtd->writesize) {
msg("error: write_oob failed (%d)\n", err); pr_err("error: write_oob failed (%d)\n", err);
if (!err) if (!err)
err = -EIO; err = -EIO;
} }
...@@ -177,7 +178,7 @@ static int read_page(int log) ...@@ -177,7 +178,7 @@ static int read_page(int log)
struct mtd_ecc_stats oldstats; struct mtd_ecc_stats oldstats;
if (log) if (log)
msg("read_page\n"); pr_info("read_page\n");
/* Saving last mtd stats */ /* Saving last mtd stats */
memcpy(&oldstats, &mtd->ecc_stats, sizeof(oldstats)); memcpy(&oldstats, &mtd->ecc_stats, sizeof(oldstats));
...@@ -187,7 +188,7 @@ static int read_page(int log) ...@@ -187,7 +188,7 @@ static int read_page(int log)
err = mtd->ecc_stats.corrected - oldstats.corrected; err = mtd->ecc_stats.corrected - oldstats.corrected;
if (err < 0 || read != mtd->writesize) { if (err < 0 || read != mtd->writesize) {
msg("error: read failed at %#llx\n", (long long)offset); pr_err("error: read failed at %#llx\n", (long long)offset);
if (err >= 0) if (err >= 0)
err = -EIO; err = -EIO;
} }
...@@ -201,11 +202,11 @@ static int verify_page(int log) ...@@ -201,11 +202,11 @@ static int verify_page(int log)
unsigned i, errs = 0; unsigned i, errs = 0;
if (log) if (log)
msg("verify_page\n"); pr_info("verify_page\n");
for (i = 0; i < mtd->writesize; i++) { for (i = 0; i < mtd->writesize; i++) {
if (rbuffer[i] != hash(i+seed)) { if (rbuffer[i] != hash(i+seed)) {
msg("Error: page offset %u, expected %02x, got %02x\n", pr_err("Error: page offset %u, expected %02x, got %02x\n",
i, hash(i+seed), rbuffer[i]); i, hash(i+seed), rbuffer[i]);
errs++; errs++;
} }
...@@ -230,13 +231,13 @@ static int insert_biterror(unsigned byte) ...@@ -230,13 +231,13 @@ static int insert_biterror(unsigned byte)
for (bit = 7; bit >= 0; bit--) { for (bit = 7; bit >= 0; bit--) {
if (CBIT(wbuffer[byte], bit)) { if (CBIT(wbuffer[byte], bit)) {
BCLR(wbuffer[byte], bit); BCLR(wbuffer[byte], bit);
msg("Inserted biterror @ %u/%u\n", byte, bit); pr_info("Inserted biterror @ %u/%u\n", byte, bit);
return 0; return 0;
} }
} }
byte++; byte++;
} }
msg("biterror: Failed to find a '1' bit\n"); pr_err("biterror: Failed to find a '1' bit\n");
return -EIO; return -EIO;
} }
...@@ -248,7 +249,7 @@ static int incremental_errors_test(void) ...@@ -248,7 +249,7 @@ static int incremental_errors_test(void)
unsigned i; unsigned i;
unsigned errs_per_subpage = 0; unsigned errs_per_subpage = 0;
msg("incremental biterrors test\n"); pr_info("incremental biterrors test\n");
for (i = 0; i < mtd->writesize; i++) for (i = 0; i < mtd->writesize; i++)
wbuffer[i] = hash(i+seed); wbuffer[i] = hash(i+seed);
...@@ -265,9 +266,9 @@ static int incremental_errors_test(void) ...@@ -265,9 +266,9 @@ static int incremental_errors_test(void)
err = read_page(1); err = read_page(1);
if (err > 0) if (err > 0)
msg("Read reported %d corrected bit errors\n", err); pr_info("Read reported %d corrected bit errors\n", err);
if (err < 0) { if (err < 0) {
msg("After %d biterrors per subpage, read reported error %d\n", pr_err("After %d biterrors per subpage, read reported error %d\n",
errs_per_subpage, err); errs_per_subpage, err);
err = 0; err = 0;
goto exit; goto exit;
...@@ -275,11 +276,11 @@ static int incremental_errors_test(void) ...@@ -275,11 +276,11 @@ static int incremental_errors_test(void)
err = verify_page(1); err = verify_page(1);
if (err) { if (err) {
msg("ECC failure, read data is incorrect despite read success\n"); pr_err("ECC failure, read data is incorrect despite read success\n");
goto exit; goto exit;
} }
msg("Successfully corrected %d bit errors per subpage\n", pr_info("Successfully corrected %d bit errors per subpage\n",
errs_per_subpage); errs_per_subpage);
for (i = 0; i < subcount; i++) { for (i = 0; i < subcount; i++) {
...@@ -311,7 +312,7 @@ static int overwrite_test(void) ...@@ -311,7 +312,7 @@ static int overwrite_test(void)
memset(bitstats, 0, sizeof(bitstats)); memset(bitstats, 0, sizeof(bitstats));
msg("overwrite biterrors test\n"); pr_info("overwrite biterrors test\n");
for (i = 0; i < mtd->writesize; i++) for (i = 0; i < mtd->writesize; i++)
wbuffer[i] = hash(i+seed); wbuffer[i] = hash(i+seed);
...@@ -329,18 +330,18 @@ static int overwrite_test(void) ...@@ -329,18 +330,18 @@ static int overwrite_test(void)
err = read_page(0); err = read_page(0);
if (err >= 0) { if (err >= 0) {
if (err >= MAXBITS) { if (err >= MAXBITS) {
msg("Implausible number of bit errors corrected\n"); pr_info("Implausible number of bit errors corrected\n");
err = -EIO; err = -EIO;
break; break;
} }
bitstats[err]++; bitstats[err]++;
if (err > max_corrected) { if (err > max_corrected) {
max_corrected = err; max_corrected = err;
msg("Read reported %d corrected bit errors\n", pr_info("Read reported %d corrected bit errors\n",
err); err);
} }
} else { /* err < 0 */ } else { /* err < 0 */
msg("Read reported error %d\n", err); pr_info("Read reported error %d\n", err);
err = 0; err = 0;
break; break;
} }
...@@ -348,7 +349,7 @@ static int overwrite_test(void) ...@@ -348,7 +349,7 @@ static int overwrite_test(void)
err = verify_page(0); err = verify_page(0);
if (err) { if (err) {
bitstats[max_corrected] = opno; bitstats[max_corrected] = opno;
msg("ECC failure, read data is incorrect despite read success\n"); pr_info("ECC failure, read data is incorrect despite read success\n");
break; break;
} }
...@@ -357,9 +358,9 @@ static int overwrite_test(void) ...@@ -357,9 +358,9 @@ static int overwrite_test(void)
/* At this point bitstats[0] contains the number of ops with no bit /* At this point bitstats[0] contains the number of ops with no bit
* errors, bitstats[1] the number of ops with 1 bit error, etc. */ * errors, bitstats[1] the number of ops with 1 bit error, etc. */
msg("Bit error histogram (%d operations total):\n", opno); pr_info("Bit error histogram (%d operations total):\n", opno);
for (i = 0; i < max_corrected; i++) for (i = 0; i < max_corrected; i++)
msg("Page reads with %3d corrected bit errors: %d\n", pr_info("Page reads with %3d corrected bit errors: %d\n",
i, bitstats[i]); i, bitstats[i]);
exit: exit:
...@@ -370,36 +371,36 @@ static int __init mtd_nandbiterrs_init(void) ...@@ -370,36 +371,36 @@ static int __init mtd_nandbiterrs_init(void)
{ {
int err = 0; int err = 0;
msg("\n"); printk("\n");
msg("==================================================\n"); printk(KERN_INFO "==================================================\n");
msg("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);
msg("error: cannot get MTD device\n"); pr_err("error: cannot get MTD device\n");
goto exit_mtddev; goto exit_mtddev;
} }
if (mtd->type != MTD_NANDFLASH) { if (mtd->type != MTD_NANDFLASH) {
msg("this test requires NAND flash\n"); pr_info("this test requires NAND flash\n");
err = -ENODEV; err = -ENODEV;
goto exit_nand; goto exit_nand;
} }
msg("MTD device size %llu, eraseblock=%u, page=%u, oob=%u\n", pr_info("MTD device size %llu, eraseblock=%u, page=%u, oob=%u\n",
(unsigned long long)mtd->size, mtd->erasesize, (unsigned long long)mtd->size, mtd->erasesize,
mtd->writesize, mtd->oobsize); mtd->writesize, mtd->oobsize);
subsize = mtd->writesize >> mtd->subpage_sft; subsize = mtd->writesize >> mtd->subpage_sft;
subcount = mtd->writesize / subsize; subcount = mtd->writesize / subsize;
msg("Device uses %d subpages of %d bytes\n", subcount, subsize); pr_info("Device uses %d subpages of %d bytes\n", subcount, subsize);
offset = page_offset * mtd->writesize; offset = page_offset * mtd->writesize;
eraseblock = mtd_div_by_eb(offset, mtd); eraseblock = mtd_div_by_eb(offset, mtd);
msg("Using page=%u, offset=%llu, eraseblock=%u\n", pr_info("Using page=%u, offset=%llu, eraseblock=%u\n",
page_offset, offset, eraseblock); page_offset, offset, eraseblock);
wbuffer = kmalloc(mtd->writesize, GFP_KERNEL); wbuffer = kmalloc(mtd->writesize, GFP_KERNEL);
...@@ -432,8 +433,8 @@ static int __init mtd_nandbiterrs_init(void) ...@@ -432,8 +433,8 @@ static int __init mtd_nandbiterrs_init(void)
goto exit_error; goto exit_error;
err = -EIO; err = -EIO;
msg("finished successfully.\n"); pr_info("finished successfully.\n");
msg("==================================================\n"); printk(KERN_INFO "==================================================\n");
exit_error: exit_error:
kfree(rbuffer); kfree(rbuffer);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册