aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikram Narayanan <vikram186@gmail.com>2012-10-10 13:40:22 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-11-15 08:37:49 -0500
commitae0086cfeef14ec2b5aef625cb9be1d625aac33b (patch)
tree5f71f3b8f28a16ff97b4f618e16b52cb33b53a97
parente45048a6a232de1dc6978f2f4df6369beafa79c0 (diff)
mtd: tests: mtd_stresstest: Replace printk with pr_{info,crit,err}
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>
-rw-r--r--drivers/mtd/tests/mtd_stresstest.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c
index cb268cebf01a..fea1dd78ccbe 100644
--- a/drivers/mtd/tests/mtd_stresstest.c
+++ b/drivers/mtd/tests/mtd_stresstest.c
@@ -19,6 +19,8 @@
19 * Author: Adrian Hunter <ext-adrian.hunter@nokia.com> 19 * Author: Adrian Hunter <ext-adrian.hunter@nokia.com>
20 */ 20 */
21 21
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23
22#include <linux/init.h> 24#include <linux/init.h>
23#include <linux/module.h> 25#include <linux/module.h>
24#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
@@ -29,8 +31,6 @@
29#include <linux/vmalloc.h> 31#include <linux/vmalloc.h>
30#include <linux/random.h> 32#include <linux/random.h>
31 33
32#define PRINT_PREF KERN_INFO "mtd_stresstest: "
33
34static int dev = -EINVAL; 34static int dev = -EINVAL;
35module_param(dev, int, S_IRUGO); 35module_param(dev, int, S_IRUGO);
36MODULE_PARM_DESC(dev, "MTD device number to use"); 36MODULE_PARM_DESC(dev, "MTD device number to use");
@@ -94,12 +94,12 @@ static int erase_eraseblock(int ebnum)
94 94
95 err = mtd_erase(mtd, &ei); 95 err = mtd_erase(mtd, &ei);
96 if (unlikely(err)) { 96 if (unlikely(err)) {
97 printk(PRINT_PREF "error %d while erasing EB %d\n", err, ebnum); 97 pr_err("error %d while erasing EB %d\n", err, ebnum);
98 return err; 98 return err;
99 } 99 }
100 100
101 if (unlikely(ei.state == MTD_ERASE_FAILED)) { 101 if (unlikely(ei.state == MTD_ERASE_FAILED)) {
102 printk(PRINT_PREF "some erase error occurred at EB %d\n", 102 pr_err("some erase error occurred at EB %d\n",
103 ebnum); 103 ebnum);
104 return -EIO; 104 return -EIO;
105 } 105 }
@@ -114,7 +114,7 @@ static int is_block_bad(int ebnum)
114 114
115 ret = mtd_block_isbad(mtd, addr); 115 ret = mtd_block_isbad(mtd, addr);
116 if (ret) 116 if (ret)
117 printk(PRINT_PREF "block %d is bad\n", ebnum); 117 pr_info("block %d is bad\n", ebnum);
118 return ret; 118 return ret;
119} 119}
120 120
@@ -137,7 +137,7 @@ static int do_read(void)
137 if (mtd_is_bitflip(err)) 137 if (mtd_is_bitflip(err))
138 err = 0; 138 err = 0;
139 if (unlikely(err || read != len)) { 139 if (unlikely(err || read != len)) {
140 printk(PRINT_PREF "error: read failed at 0x%llx\n", 140 pr_err("error: read failed at 0x%llx\n",
141 (long long)addr); 141 (long long)addr);
142 if (!err) 142 if (!err)
143 err = -EINVAL; 143 err = -EINVAL;
@@ -174,7 +174,7 @@ static int do_write(void)
174 addr = eb * mtd->erasesize + offs; 174 addr = eb * mtd->erasesize + offs;
175 err = mtd_write(mtd, addr, len, &written, writebuf); 175 err = mtd_write(mtd, addr, len, &written, writebuf);
176 if (unlikely(err || written != len)) { 176 if (unlikely(err || written != len)) {
177 printk(PRINT_PREF "error: write failed at 0x%llx\n", 177 pr_err("error: write failed at 0x%llx\n",
178 (long long)addr); 178 (long long)addr);
179 if (!err) 179 if (!err)
180 err = -EINVAL; 180 err = -EINVAL;
@@ -203,21 +203,21 @@ static int scan_for_bad_eraseblocks(void)
203 203
204 bbt = kzalloc(ebcnt, GFP_KERNEL); 204 bbt = kzalloc(ebcnt, GFP_KERNEL);
205 if (!bbt) { 205 if (!bbt) {
206 printk(PRINT_PREF "error: cannot allocate memory\n"); 206 pr_err("error: cannot allocate memory\n");
207 return -ENOMEM; 207 return -ENOMEM;
208 } 208 }
209 209
210 if (!mtd_can_have_bb(mtd)) 210 if (!mtd_can_have_bb(mtd))
211 return 0; 211 return 0;
212 212
213 printk(PRINT_PREF "scanning for bad eraseblocks\n"); 213 pr_info("scanning for bad eraseblocks\n");
214 for (i = 0; i < ebcnt; ++i) { 214 for (i = 0; i < ebcnt; ++i) {
215 bbt[i] = is_block_bad(i) ? 1 : 0; 215 bbt[i] = is_block_bad(i) ? 1 : 0;
216 if (bbt[i]) 216 if (bbt[i])
217 bad += 1; 217 bad += 1;
218 cond_resched(); 218 cond_resched();
219 } 219 }
220 printk(PRINT_PREF "scanned %d eraseblocks, %d are bad\n", i, bad); 220 pr_info("scanned %d eraseblocks, %d are bad\n", i, bad);
221 return 0; 221 return 0;
222} 222}
223 223
@@ -231,22 +231,22 @@ static int __init mtd_stresstest_init(void)
231 printk(KERN_INFO "=================================================\n"); 231 printk(KERN_INFO "=================================================\n");
232 232
233 if (dev < 0) { 233 if (dev < 0) {
234 printk(PRINT_PREF "Please specify a valid mtd-device via module paramter\n"); 234 pr_info("Please specify a valid mtd-device via module paramter\n");
235 printk(KERN_CRIT "CAREFUL: This test wipes all data on the specified MTD device!\n"); 235 pr_crit("CAREFUL: This test wipes all data on the specified MTD device!\n");
236 return -EINVAL; 236 return -EINVAL;
237 } 237 }
238 238
239 printk(PRINT_PREF "MTD device: %d\n", dev); 239 pr_info("MTD device: %d\n", dev);
240 240
241 mtd = get_mtd_device(NULL, dev); 241 mtd = get_mtd_device(NULL, dev);
242 if (IS_ERR(mtd)) { 242 if (IS_ERR(mtd)) {
243 err = PTR_ERR(mtd); 243 err = PTR_ERR(mtd);
244 printk(PRINT_PREF "error: cannot get MTD device\n"); 244 pr_err("error: cannot get MTD device\n");
245 return err; 245 return err;
246 } 246 }
247 247
248 if (mtd->writesize == 1) { 248 if (mtd->writesize == 1) {
249 printk(PRINT_PREF "not NAND flash, assume page size is 512 " 249 pr_info("not NAND flash, assume page size is 512 "
250 "bytes.\n"); 250 "bytes.\n");
251 pgsize = 512; 251 pgsize = 512;
252 } else 252 } else
@@ -257,14 +257,14 @@ static int __init mtd_stresstest_init(void)
257 ebcnt = tmp; 257 ebcnt = tmp;
258 pgcnt = mtd->erasesize / pgsize; 258 pgcnt = mtd->erasesize / pgsize;
259 259
260 printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, " 260 pr_info("MTD device size %llu, eraseblock size %u, "
261 "page size %u, count of eraseblocks %u, pages per " 261 "page size %u, count of eraseblocks %u, pages per "
262 "eraseblock %u, OOB size %u\n", 262 "eraseblock %u, OOB size %u\n",
263 (unsigned long long)mtd->size, mtd->erasesize, 263 (unsigned long long)mtd->size, mtd->erasesize,
264 pgsize, ebcnt, pgcnt, mtd->oobsize); 264 pgsize, ebcnt, pgcnt, mtd->oobsize);
265 265
266 if (ebcnt < 2) { 266 if (ebcnt < 2) {
267 printk(PRINT_PREF "error: need at least 2 eraseblocks\n"); 267 pr_err("error: need at least 2 eraseblocks\n");
268 err = -ENOSPC; 268 err = -ENOSPC;
269 goto out_put_mtd; 269 goto out_put_mtd;
270 } 270 }
@@ -277,7 +277,7 @@ static int __init mtd_stresstest_init(void)
277 writebuf = vmalloc(bufsize); 277 writebuf = vmalloc(bufsize);
278 offsets = kmalloc(ebcnt * sizeof(int), GFP_KERNEL); 278 offsets = kmalloc(ebcnt * sizeof(int), GFP_KERNEL);
279 if (!readbuf || !writebuf || !offsets) { 279 if (!readbuf || !writebuf || !offsets) {
280 printk(PRINT_PREF "error: cannot allocate memory\n"); 280 pr_err("error: cannot allocate memory\n");
281 goto out; 281 goto out;
282 } 282 }
283 for (i = 0; i < ebcnt; i++) 283 for (i = 0; i < ebcnt; i++)
@@ -290,16 +290,16 @@ static int __init mtd_stresstest_init(void)
290 goto out; 290 goto out;
291 291
292 /* Do operations */ 292 /* Do operations */
293 printk(PRINT_PREF "doing operations\n"); 293 pr_info("doing operations\n");
294 for (op = 0; op < count; op++) { 294 for (op = 0; op < count; op++) {
295 if ((op & 1023) == 0) 295 if ((op & 1023) == 0)
296 printk(PRINT_PREF "%d operations done\n", op); 296 pr_info("%d operations done\n", op);
297 err = do_operation(); 297 err = do_operation();
298 if (err) 298 if (err)
299 goto out; 299 goto out;
300 cond_resched(); 300 cond_resched();
301 } 301 }
302 printk(PRINT_PREF "finished, %d operations done\n", op); 302 pr_info("finished, %d operations done\n", op);
303 303
304out: 304out:
305 kfree(offsets); 305 kfree(offsets);
@@ -309,7 +309,7 @@ out:
309out_put_mtd: 309out_put_mtd:
310 put_mtd_device(mtd); 310 put_mtd_device(mtd);
311 if (err) 311 if (err)
312 printk(PRINT_PREF "error %d occurred\n", err); 312 pr_info("error %d occurred\n", err);
313 printk(KERN_INFO "=================================================\n"); 313 printk(KERN_INFO "=================================================\n");
314 return err; 314 return err;
315} 315}