diff options
author | Vikram Narayanan <vikram186@gmail.com> | 2012-10-10 13:34:41 -0400 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2012-11-15 08:37:48 -0500 |
commit | 600ed67562e5349be92867825ab5505526eac139 (patch) | |
tree | 9300b16e5a79cd8adc6b8f55d4b01e00084f1a05 /drivers/mtd/tests | |
parent | a90019e25e0caed04d3704235b5ea984aaa28da8 (diff) |
mtd: tests: mtd_nandbiterrs: replace msg macro with pr_{info,err}
Use pr_fmt instead of msg macro
Signed-off-by: Vikram Narayanan <vikram186@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd/tests')
-rw-r--r-- | drivers/mtd/tests/mtd_nandbiterrs.c | 73 |
1 files changed, 37 insertions, 36 deletions
diff --git a/drivers/mtd/tests/mtd_nandbiterrs.c b/drivers/mtd/tests/mtd_nandbiterrs.c index cc8d62cb280c..207bf9a9972f 100644 --- a/drivers/mtd/tests/mtd_nandbiterrs.c +++ b/drivers/mtd/tests/mtd_nandbiterrs.c | |||
@@ -39,6 +39,9 @@ | |||
39 | * this program; see the file COPYING. If not, write to the Free Software | 39 | * this program; see the file COPYING. If not, write to the Free Software |
40 | * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 40 | * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
41 | */ | 41 | */ |
42 | |||
43 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
44 | |||
42 | #include <linux/init.h> | 45 | #include <linux/init.h> |
43 | #include <linux/module.h> | 46 | #include <linux/module.h> |
44 | #include <linux/moduleparam.h> | 47 | #include <linux/moduleparam.h> |
@@ -47,8 +50,6 @@ | |||
47 | #include <linux/mtd/nand.h> | 50 | #include <linux/mtd/nand.h> |
48 | #include <linux/slab.h> | 51 | #include <linux/slab.h> |
49 | 52 | ||
50 | #define msg(FMT, VA...) pr_info("mtd_nandbiterrs: "FMT, ##VA) | ||
51 | |||
52 | static int dev; | 53 | static int dev; |
53 | module_param(dev, int, S_IRUGO); | 54 | module_param(dev, int, S_IRUGO); |
54 | MODULE_PARM_DESC(dev, "MTD device number to use"); | 55 | MODULE_PARM_DESC(dev, "MTD device number to use"); |
@@ -103,7 +104,7 @@ static int erase_block(void) | |||
103 | struct erase_info ei; | 104 | struct erase_info ei; |
104 | loff_t addr = eraseblock * mtd->erasesize; | 105 | loff_t addr = eraseblock * mtd->erasesize; |
105 | 106 | ||
106 | msg("erase_block\n"); | 107 | pr_info("erase_block\n"); |
107 | 108 | ||
108 | memset(&ei, 0, sizeof(struct erase_info)); | 109 | memset(&ei, 0, sizeof(struct erase_info)); |
109 | ei.mtd = mtd; | 110 | ei.mtd = mtd; |
@@ -112,7 +113,7 @@ static int erase_block(void) | |||
112 | 113 | ||
113 | err = mtd_erase(mtd, &ei); | 114 | err = mtd_erase(mtd, &ei); |
114 | if (err || ei.state == MTD_ERASE_FAILED) { | 115 | if (err || ei.state == MTD_ERASE_FAILED) { |
115 | msg("error %d while erasing\n", err); | 116 | pr_err("error %d while erasing\n", err); |
116 | if (!err) | 117 | if (!err) |
117 | err = -EIO; | 118 | err = -EIO; |
118 | return err; | 119 | return err; |
@@ -128,11 +129,11 @@ static int write_page(int log) | |||
128 | size_t written; | 129 | size_t written; |
129 | 130 | ||
130 | if (log) | 131 | if (log) |
131 | msg("write_page\n"); | 132 | pr_info("write_page\n"); |
132 | 133 | ||
133 | err = mtd_write(mtd, offset, mtd->writesize, &written, wbuffer); | 134 | err = mtd_write(mtd, offset, mtd->writesize, &written, wbuffer); |
134 | if (err || written != mtd->writesize) { | 135 | if (err || written != mtd->writesize) { |
135 | msg("error: write failed at %#llx\n", (long long)offset); | 136 | pr_err("error: write failed at %#llx\n", (long long)offset); |
136 | if (!err) | 137 | if (!err) |
137 | err = -EIO; | 138 | err = -EIO; |
138 | } | 139 | } |
@@ -147,7 +148,7 @@ static int rewrite_page(int log) | |||
147 | struct mtd_oob_ops ops; | 148 | struct mtd_oob_ops ops; |
148 | 149 | ||
149 | if (log) | 150 | if (log) |
150 | msg("rewrite page\n"); | 151 | pr_info("rewrite page\n"); |
151 | 152 | ||
152 | ops.mode = MTD_OPS_RAW; /* No ECC */ | 153 | ops.mode = MTD_OPS_RAW; /* No ECC */ |
153 | ops.len = mtd->writesize; | 154 | ops.len = mtd->writesize; |
@@ -160,7 +161,7 @@ static int rewrite_page(int log) | |||
160 | 161 | ||
161 | err = mtd_write_oob(mtd, offset, &ops); | 162 | err = mtd_write_oob(mtd, offset, &ops); |
162 | if (err || ops.retlen != mtd->writesize) { | 163 | if (err || ops.retlen != mtd->writesize) { |
163 | msg("error: write_oob failed (%d)\n", err); | 164 | pr_err("error: write_oob failed (%d)\n", err); |
164 | if (!err) | 165 | if (!err) |
165 | err = -EIO; | 166 | err = -EIO; |
166 | } | 167 | } |
@@ -177,7 +178,7 @@ static int read_page(int log) | |||
177 | struct mtd_ecc_stats oldstats; | 178 | struct mtd_ecc_stats oldstats; |
178 | 179 | ||
179 | if (log) | 180 | if (log) |
180 | msg("read_page\n"); | 181 | pr_info("read_page\n"); |
181 | 182 | ||
182 | /* Saving last mtd stats */ | 183 | /* Saving last mtd stats */ |
183 | memcpy(&oldstats, &mtd->ecc_stats, sizeof(oldstats)); | 184 | memcpy(&oldstats, &mtd->ecc_stats, sizeof(oldstats)); |
@@ -187,7 +188,7 @@ static int read_page(int log) | |||
187 | err = mtd->ecc_stats.corrected - oldstats.corrected; | 188 | err = mtd->ecc_stats.corrected - oldstats.corrected; |
188 | 189 | ||
189 | if (err < 0 || read != mtd->writesize) { | 190 | if (err < 0 || read != mtd->writesize) { |
190 | msg("error: read failed at %#llx\n", (long long)offset); | 191 | pr_err("error: read failed at %#llx\n", (long long)offset); |
191 | if (err >= 0) | 192 | if (err >= 0) |
192 | err = -EIO; | 193 | err = -EIO; |
193 | } | 194 | } |
@@ -201,11 +202,11 @@ static int verify_page(int log) | |||
201 | unsigned i, errs = 0; | 202 | unsigned i, errs = 0; |
202 | 203 | ||
203 | if (log) | 204 | if (log) |
204 | msg("verify_page\n"); | 205 | pr_info("verify_page\n"); |
205 | 206 | ||
206 | for (i = 0; i < mtd->writesize; i++) { | 207 | for (i = 0; i < mtd->writesize; i++) { |
207 | if (rbuffer[i] != hash(i+seed)) { | 208 | if (rbuffer[i] != hash(i+seed)) { |
208 | msg("Error: page offset %u, expected %02x, got %02x\n", | 209 | pr_err("Error: page offset %u, expected %02x, got %02x\n", |
209 | i, hash(i+seed), rbuffer[i]); | 210 | i, hash(i+seed), rbuffer[i]); |
210 | errs++; | 211 | errs++; |
211 | } | 212 | } |
@@ -230,13 +231,13 @@ static int insert_biterror(unsigned byte) | |||
230 | for (bit = 7; bit >= 0; bit--) { | 231 | for (bit = 7; bit >= 0; bit--) { |
231 | if (CBIT(wbuffer[byte], bit)) { | 232 | if (CBIT(wbuffer[byte], bit)) { |
232 | BCLR(wbuffer[byte], bit); | 233 | BCLR(wbuffer[byte], bit); |
233 | msg("Inserted biterror @ %u/%u\n", byte, bit); | 234 | pr_info("Inserted biterror @ %u/%u\n", byte, bit); |
234 | return 0; | 235 | return 0; |
235 | } | 236 | } |
236 | } | 237 | } |
237 | byte++; | 238 | byte++; |
238 | } | 239 | } |
239 | msg("biterror: Failed to find a '1' bit\n"); | 240 | pr_err("biterror: Failed to find a '1' bit\n"); |
240 | return -EIO; | 241 | return -EIO; |
241 | } | 242 | } |
242 | 243 | ||
@@ -248,7 +249,7 @@ static int incremental_errors_test(void) | |||
248 | unsigned i; | 249 | unsigned i; |
249 | unsigned errs_per_subpage = 0; | 250 | unsigned errs_per_subpage = 0; |
250 | 251 | ||
251 | msg("incremental biterrors test\n"); | 252 | pr_info("incremental biterrors test\n"); |
252 | 253 | ||
253 | for (i = 0; i < mtd->writesize; i++) | 254 | for (i = 0; i < mtd->writesize; i++) |
254 | wbuffer[i] = hash(i+seed); | 255 | wbuffer[i] = hash(i+seed); |
@@ -265,9 +266,9 @@ static int incremental_errors_test(void) | |||
265 | 266 | ||
266 | err = read_page(1); | 267 | err = read_page(1); |
267 | if (err > 0) | 268 | if (err > 0) |
268 | msg("Read reported %d corrected bit errors\n", err); | 269 | pr_info("Read reported %d corrected bit errors\n", err); |
269 | if (err < 0) { | 270 | if (err < 0) { |
270 | msg("After %d biterrors per subpage, read reported error %d\n", | 271 | pr_err("After %d biterrors per subpage, read reported error %d\n", |
271 | errs_per_subpage, err); | 272 | errs_per_subpage, err); |
272 | err = 0; | 273 | err = 0; |
273 | goto exit; | 274 | goto exit; |
@@ -275,11 +276,11 @@ static int incremental_errors_test(void) | |||
275 | 276 | ||
276 | err = verify_page(1); | 277 | err = verify_page(1); |
277 | if (err) { | 278 | if (err) { |
278 | msg("ECC failure, read data is incorrect despite read success\n"); | 279 | pr_err("ECC failure, read data is incorrect despite read success\n"); |
279 | goto exit; | 280 | goto exit; |
280 | } | 281 | } |
281 | 282 | ||
282 | msg("Successfully corrected %d bit errors per subpage\n", | 283 | pr_info("Successfully corrected %d bit errors per subpage\n", |
283 | errs_per_subpage); | 284 | errs_per_subpage); |
284 | 285 | ||
285 | for (i = 0; i < subcount; i++) { | 286 | for (i = 0; i < subcount; i++) { |
@@ -311,7 +312,7 @@ static int overwrite_test(void) | |||
311 | 312 | ||
312 | memset(bitstats, 0, sizeof(bitstats)); | 313 | memset(bitstats, 0, sizeof(bitstats)); |
313 | 314 | ||
314 | msg("overwrite biterrors test\n"); | 315 | pr_info("overwrite biterrors test\n"); |
315 | 316 | ||
316 | for (i = 0; i < mtd->writesize; i++) | 317 | for (i = 0; i < mtd->writesize; i++) |
317 | wbuffer[i] = hash(i+seed); | 318 | wbuffer[i] = hash(i+seed); |
@@ -329,18 +330,18 @@ static int overwrite_test(void) | |||
329 | err = read_page(0); | 330 | err = read_page(0); |
330 | if (err >= 0) { | 331 | if (err >= 0) { |
331 | if (err >= MAXBITS) { | 332 | if (err >= MAXBITS) { |
332 | msg("Implausible number of bit errors corrected\n"); | 333 | pr_info("Implausible number of bit errors corrected\n"); |
333 | err = -EIO; | 334 | err = -EIO; |
334 | break; | 335 | break; |
335 | } | 336 | } |
336 | bitstats[err]++; | 337 | bitstats[err]++; |
337 | if (err > max_corrected) { | 338 | if (err > max_corrected) { |
338 | max_corrected = err; | 339 | max_corrected = err; |
339 | msg("Read reported %d corrected bit errors\n", | 340 | pr_info("Read reported %d corrected bit errors\n", |
340 | err); | 341 | err); |
341 | } | 342 | } |
342 | } else { /* err < 0 */ | 343 | } else { /* err < 0 */ |
343 | msg("Read reported error %d\n", err); | 344 | pr_info("Read reported error %d\n", err); |
344 | err = 0; | 345 | err = 0; |
345 | break; | 346 | break; |
346 | } | 347 | } |
@@ -348,7 +349,7 @@ static int overwrite_test(void) | |||
348 | err = verify_page(0); | 349 | err = verify_page(0); |
349 | if (err) { | 350 | if (err) { |
350 | bitstats[max_corrected] = opno; | 351 | bitstats[max_corrected] = opno; |
351 | msg("ECC failure, read data is incorrect despite read success\n"); | 352 | pr_info("ECC failure, read data is incorrect despite read success\n"); |
352 | break; | 353 | break; |
353 | } | 354 | } |
354 | 355 | ||
@@ -357,9 +358,9 @@ static int overwrite_test(void) | |||
357 | 358 | ||
358 | /* At this point bitstats[0] contains the number of ops with no bit | 359 | /* At this point bitstats[0] contains the number of ops with no bit |
359 | * errors, bitstats[1] the number of ops with 1 bit error, etc. */ | 360 | * errors, bitstats[1] the number of ops with 1 bit error, etc. */ |
360 | msg("Bit error histogram (%d operations total):\n", opno); | 361 | pr_info("Bit error histogram (%d operations total):\n", opno); |
361 | for (i = 0; i < max_corrected; i++) | 362 | for (i = 0; i < max_corrected; i++) |
362 | msg("Page reads with %3d corrected bit errors: %d\n", | 363 | pr_info("Page reads with %3d corrected bit errors: %d\n", |
363 | i, bitstats[i]); | 364 | i, bitstats[i]); |
364 | 365 | ||
365 | exit: | 366 | exit: |
@@ -370,36 +371,36 @@ static int __init mtd_nandbiterrs_init(void) | |||
370 | { | 371 | { |
371 | int err = 0; | 372 | int err = 0; |
372 | 373 | ||
373 | msg("\n"); | 374 | printk("\n"); |
374 | msg("==================================================\n"); | 375 | printk(KERN_INFO "==================================================\n"); |
375 | msg("MTD device: %d\n", dev); | 376 | pr_info("MTD device: %d\n", dev); |
376 | 377 | ||
377 | mtd = get_mtd_device(NULL, dev); | 378 | mtd = get_mtd_device(NULL, dev); |
378 | if (IS_ERR(mtd)) { | 379 | if (IS_ERR(mtd)) { |
379 | err = PTR_ERR(mtd); | 380 | err = PTR_ERR(mtd); |
380 | msg("error: cannot get MTD device\n"); | 381 | pr_err("error: cannot get MTD device\n"); |
381 | goto exit_mtddev; | 382 | goto exit_mtddev; |
382 | } | 383 | } |
383 | 384 | ||
384 | if (mtd->type != MTD_NANDFLASH) { | 385 | if (mtd->type != MTD_NANDFLASH) { |
385 | msg("this test requires NAND flash\n"); | 386 | pr_info("this test requires NAND flash\n"); |
386 | err = -ENODEV; | 387 | err = -ENODEV; |
387 | goto exit_nand; | 388 | goto exit_nand; |
388 | } | 389 | } |
389 | 390 | ||
390 | msg("MTD device size %llu, eraseblock=%u, page=%u, oob=%u\n", | 391 | pr_info("MTD device size %llu, eraseblock=%u, page=%u, oob=%u\n", |
391 | (unsigned long long)mtd->size, mtd->erasesize, | 392 | (unsigned long long)mtd->size, mtd->erasesize, |
392 | mtd->writesize, mtd->oobsize); | 393 | mtd->writesize, mtd->oobsize); |
393 | 394 | ||
394 | subsize = mtd->writesize >> mtd->subpage_sft; | 395 | subsize = mtd->writesize >> mtd->subpage_sft; |
395 | subcount = mtd->writesize / subsize; | 396 | subcount = mtd->writesize / subsize; |
396 | 397 | ||
397 | msg("Device uses %d subpages of %d bytes\n", subcount, subsize); | 398 | pr_info("Device uses %d subpages of %d bytes\n", subcount, subsize); |
398 | 399 | ||
399 | offset = page_offset * mtd->writesize; | 400 | offset = page_offset * mtd->writesize; |
400 | eraseblock = mtd_div_by_eb(offset, mtd); | 401 | eraseblock = mtd_div_by_eb(offset, mtd); |
401 | 402 | ||
402 | msg("Using page=%u, offset=%llu, eraseblock=%u\n", | 403 | pr_info("Using page=%u, offset=%llu, eraseblock=%u\n", |
403 | page_offset, offset, eraseblock); | 404 | page_offset, offset, eraseblock); |
404 | 405 | ||
405 | wbuffer = kmalloc(mtd->writesize, GFP_KERNEL); | 406 | wbuffer = kmalloc(mtd->writesize, GFP_KERNEL); |
@@ -432,8 +433,8 @@ static int __init mtd_nandbiterrs_init(void) | |||
432 | goto exit_error; | 433 | goto exit_error; |
433 | 434 | ||
434 | err = -EIO; | 435 | err = -EIO; |
435 | msg("finished successfully.\n"); | 436 | pr_info("finished successfully.\n"); |
436 | msg("==================================================\n"); | 437 | printk(KERN_INFO "==================================================\n"); |
437 | 438 | ||
438 | exit_error: | 439 | exit_error: |
439 | kfree(rbuffer); | 440 | kfree(rbuffer); |