aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorWolfram Sang <w.sang@pengutronix.de>2011-10-29 18:11:53 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@intel.com>2011-10-30 08:31:04 -0400
commit7406060e292c389fe6f38bd23493de9b57f2f4fc (patch)
tree1b88dfc908c3be01a86d74685a4329c69d2f9348 /drivers
parent6be55f79a216ccb9f364476b12e5b151a5f6bdb6 (diff)
mtd: tests: don't use mtd0 as a default
mtd tests may erase the mtd device, so force the user to specify which mtd device to test by using the module parameter. Disable the default (using mtd0) since this may destroy a vital part of the flash if the module is inserted accidently or carelessly. Reported-by: Roland Kletzing <devzero@web.de> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/tests/mtd_oobtest.c9
-rw-r--r--drivers/mtd/tests/mtd_pagetest.c9
-rw-r--r--drivers/mtd/tests/mtd_readtest.c8
-rw-r--r--drivers/mtd/tests/mtd_speedtest.c9
-rw-r--r--drivers/mtd/tests/mtd_stresstest.c9
-rw-r--r--drivers/mtd/tests/mtd_subpagetest.c9
-rw-r--r--drivers/mtd/tests/mtd_torturetest.c9
7 files changed, 55 insertions, 7 deletions
diff --git a/drivers/mtd/tests/mtd_oobtest.c b/drivers/mtd/tests/mtd_oobtest.c
index 6bcff42296a9..933f7e5f32d3 100644
--- a/drivers/mtd/tests/mtd_oobtest.c
+++ b/drivers/mtd/tests/mtd_oobtest.c
@@ -30,7 +30,7 @@
30 30
31#define PRINT_PREF KERN_INFO "mtd_oobtest: " 31#define PRINT_PREF KERN_INFO "mtd_oobtest: "
32 32
33static int dev; 33static int dev = -EINVAL;
34module_param(dev, int, S_IRUGO); 34module_param(dev, int, S_IRUGO);
35MODULE_PARM_DESC(dev, "MTD device number to use"); 35MODULE_PARM_DESC(dev, "MTD device number to use");
36 36
@@ -366,6 +366,13 @@ static int __init mtd_oobtest_init(void)
366 366
367 printk(KERN_INFO "\n"); 367 printk(KERN_INFO "\n");
368 printk(KERN_INFO "=================================================\n"); 368 printk(KERN_INFO "=================================================\n");
369
370 if (dev < 0) {
371 printk(PRINT_PREF "Please specify a valid mtd-device via module paramter\n");
372 printk(KERN_CRIT "CAREFUL: This test wipes all data on the specified MTD device!\n");
373 return -EINVAL;
374 }
375
369 printk(PRINT_PREF "MTD device: %d\n", dev); 376 printk(PRINT_PREF "MTD device: %d\n", dev);
370 377
371 mtd = get_mtd_device(NULL, dev); 378 mtd = get_mtd_device(NULL, dev);
diff --git a/drivers/mtd/tests/mtd_pagetest.c b/drivers/mtd/tests/mtd_pagetest.c
index 186b14c02307..afafb6935fd0 100644
--- a/drivers/mtd/tests/mtd_pagetest.c
+++ b/drivers/mtd/tests/mtd_pagetest.c
@@ -30,7 +30,7 @@
30 30
31#define PRINT_PREF KERN_INFO "mtd_pagetest: " 31#define PRINT_PREF KERN_INFO "mtd_pagetest: "
32 32
33static int dev; 33static int dev = -EINVAL;
34module_param(dev, int, S_IRUGO); 34module_param(dev, int, S_IRUGO);
35MODULE_PARM_DESC(dev, "MTD device number to use"); 35MODULE_PARM_DESC(dev, "MTD device number to use");
36 36
@@ -504,6 +504,13 @@ static int __init mtd_pagetest_init(void)
504 504
505 printk(KERN_INFO "\n"); 505 printk(KERN_INFO "\n");
506 printk(KERN_INFO "=================================================\n"); 506 printk(KERN_INFO "=================================================\n");
507
508 if (dev < 0) {
509 printk(PRINT_PREF "Please specify a valid mtd-device via module paramter\n");
510 printk(KERN_CRIT "CAREFUL: This test wipes all data on the specified MTD device!\n");
511 return -EINVAL;
512 }
513
507 printk(PRINT_PREF "MTD device: %d\n", dev); 514 printk(PRINT_PREF "MTD device: %d\n", dev);
508 515
509 mtd = get_mtd_device(NULL, dev); 516 mtd = get_mtd_device(NULL, dev);
diff --git a/drivers/mtd/tests/mtd_readtest.c b/drivers/mtd/tests/mtd_readtest.c
index 756045345f00..550fe51225a7 100644
--- a/drivers/mtd/tests/mtd_readtest.c
+++ b/drivers/mtd/tests/mtd_readtest.c
@@ -29,7 +29,7 @@
29 29
30#define PRINT_PREF KERN_INFO "mtd_readtest: " 30#define PRINT_PREF KERN_INFO "mtd_readtest: "
31 31
32static int dev; 32static int dev = -EINVAL;
33module_param(dev, int, S_IRUGO); 33module_param(dev, int, S_IRUGO);
34MODULE_PARM_DESC(dev, "MTD device number to use"); 34MODULE_PARM_DESC(dev, "MTD device number to use");
35 35
@@ -170,6 +170,12 @@ static int __init mtd_readtest_init(void)
170 170
171 printk(KERN_INFO "\n"); 171 printk(KERN_INFO "\n");
172 printk(KERN_INFO "=================================================\n"); 172 printk(KERN_INFO "=================================================\n");
173
174 if (dev < 0) {
175 printk(PRINT_PREF "Please specify a valid mtd-device via module paramter\n");
176 return -EINVAL;
177 }
178
173 printk(PRINT_PREF "MTD device: %d\n", dev); 179 printk(PRINT_PREF "MTD device: %d\n", dev);
174 180
175 mtd = get_mtd_device(NULL, dev); 181 mtd = get_mtd_device(NULL, dev);
diff --git a/drivers/mtd/tests/mtd_speedtest.c b/drivers/mtd/tests/mtd_speedtest.c
index 79d53ee62295..493b367bdd35 100644
--- a/drivers/mtd/tests/mtd_speedtest.c
+++ b/drivers/mtd/tests/mtd_speedtest.c
@@ -29,7 +29,7 @@
29 29
30#define PRINT_PREF KERN_INFO "mtd_speedtest: " 30#define PRINT_PREF KERN_INFO "mtd_speedtest: "
31 31
32static int dev; 32static int dev = -EINVAL;
33module_param(dev, int, S_IRUGO); 33module_param(dev, int, S_IRUGO);
34MODULE_PARM_DESC(dev, "MTD device number to use"); 34MODULE_PARM_DESC(dev, "MTD device number to use");
35 35
@@ -361,6 +361,13 @@ static int __init mtd_speedtest_init(void)
361 361
362 printk(KERN_INFO "\n"); 362 printk(KERN_INFO "\n");
363 printk(KERN_INFO "=================================================\n"); 363 printk(KERN_INFO "=================================================\n");
364
365 if (dev < 0) {
366 printk(PRINT_PREF "Please specify a valid mtd-device via module paramter\n");
367 printk(KERN_CRIT "CAREFUL: This test wipes all data on the specified MTD device!\n");
368 return -EINVAL;
369 }
370
364 if (count) 371 if (count)
365 printk(PRINT_PREF "MTD device: %d count: %d\n", dev, count); 372 printk(PRINT_PREF "MTD device: %d count: %d\n", dev, count);
366 else 373 else
diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c
index 3c9008adbe3b..52ffd9120e0d 100644
--- a/drivers/mtd/tests/mtd_stresstest.c
+++ b/drivers/mtd/tests/mtd_stresstest.c
@@ -30,7 +30,7 @@
30 30
31#define PRINT_PREF KERN_INFO "mtd_stresstest: " 31#define PRINT_PREF KERN_INFO "mtd_stresstest: "
32 32
33static int dev; 33static int dev = -EINVAL;
34module_param(dev, int, S_IRUGO); 34module_param(dev, int, S_IRUGO);
35MODULE_PARM_DESC(dev, "MTD device number to use"); 35MODULE_PARM_DESC(dev, "MTD device number to use");
36 36
@@ -250,6 +250,13 @@ static int __init mtd_stresstest_init(void)
250 250
251 printk(KERN_INFO "\n"); 251 printk(KERN_INFO "\n");
252 printk(KERN_INFO "=================================================\n"); 252 printk(KERN_INFO "=================================================\n");
253
254 if (dev < 0) {
255 printk(PRINT_PREF "Please specify a valid mtd-device via module paramter\n");
256 printk(KERN_CRIT "CAREFUL: This test wipes all data on the specified MTD device!\n");
257 return -EINVAL;
258 }
259
253 printk(PRINT_PREF "MTD device: %d\n", dev); 260 printk(PRINT_PREF "MTD device: %d\n", dev);
254 261
255 mtd = get_mtd_device(NULL, dev); 262 mtd = get_mtd_device(NULL, dev);
diff --git a/drivers/mtd/tests/mtd_subpagetest.c b/drivers/mtd/tests/mtd_subpagetest.c
index 2b51842d08fa..1a05bfac4eee 100644
--- a/drivers/mtd/tests/mtd_subpagetest.c
+++ b/drivers/mtd/tests/mtd_subpagetest.c
@@ -29,7 +29,7 @@
29 29
30#define PRINT_PREF KERN_INFO "mtd_subpagetest: " 30#define PRINT_PREF KERN_INFO "mtd_subpagetest: "
31 31
32static int dev; 32static int dev = -EINVAL;
33module_param(dev, int, S_IRUGO); 33module_param(dev, int, S_IRUGO);
34MODULE_PARM_DESC(dev, "MTD device number to use"); 34MODULE_PARM_DESC(dev, "MTD device number to use");
35 35
@@ -379,6 +379,13 @@ static int __init mtd_subpagetest_init(void)
379 379
380 printk(KERN_INFO "\n"); 380 printk(KERN_INFO "\n");
381 printk(KERN_INFO "=================================================\n"); 381 printk(KERN_INFO "=================================================\n");
382
383 if (dev < 0) {
384 printk(PRINT_PREF "Please specify a valid mtd-device via module paramter\n");
385 printk(KERN_CRIT "CAREFUL: This test wipes all data on the specified MTD device!\n");
386 return -EINVAL;
387 }
388
382 printk(PRINT_PREF "MTD device: %d\n", dev); 389 printk(PRINT_PREF "MTD device: %d\n", dev);
383 390
384 mtd = get_mtd_device(NULL, dev); 391 mtd = get_mtd_device(NULL, dev);
diff --git a/drivers/mtd/tests/mtd_torturetest.c b/drivers/mtd/tests/mtd_torturetest.c
index 25786ce97c8e..03ab649a6964 100644
--- a/drivers/mtd/tests/mtd_torturetest.c
+++ b/drivers/mtd/tests/mtd_torturetest.c
@@ -46,7 +46,7 @@ static int pgcnt;
46module_param(pgcnt, int, S_IRUGO); 46module_param(pgcnt, int, S_IRUGO);
47MODULE_PARM_DESC(pgcnt, "number of pages per eraseblock to torture (0 => all)"); 47MODULE_PARM_DESC(pgcnt, "number of pages per eraseblock to torture (0 => all)");
48 48
49static int dev; 49static int dev = -EINVAL;
50module_param(dev, int, S_IRUGO); 50module_param(dev, int, S_IRUGO);
51MODULE_PARM_DESC(dev, "MTD device number to use"); 51MODULE_PARM_DESC(dev, "MTD device number to use");
52 52
@@ -213,6 +213,13 @@ static int __init tort_init(void)
213 printk(KERN_INFO "=================================================\n"); 213 printk(KERN_INFO "=================================================\n");
214 printk(PRINT_PREF "Warning: this program is trying to wear out your " 214 printk(PRINT_PREF "Warning: this program is trying to wear out your "
215 "flash, stop it if this is not wanted.\n"); 215 "flash, stop it if this is not wanted.\n");
216
217 if (dev < 0) {
218 printk(PRINT_PREF "Please specify a valid mtd-device via module paramter\n");
219 printk(KERN_CRIT "CAREFUL: This test wipes all data on the specified MTD device!\n");
220 return -EINVAL;
221 }
222
216 printk(PRINT_PREF "MTD device: %d\n", dev); 223 printk(PRINT_PREF "MTD device: %d\n", dev);
217 printk(PRINT_PREF "torture %d eraseblocks (%d-%d) of mtd%d\n", 224 printk(PRINT_PREF "torture %d eraseblocks (%d-%d) of mtd%d\n",
218 ebcnt, eb, eb + ebcnt - 1, dev); 225 ebcnt, eb, eb + ebcnt - 1, dev);