summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/tests/mtd_readtest.c
diff options
context:
space:
mode:
authorWolfram Sang <w.sang@pengutronix.de>2011-10-30 00:11:53 +0200
committerArtem Bityutskiy <Artem.Bityutskiy@intel.com>2011-10-30 14:31:04 +0200
commit7406060e292c389fe6f38bd23493de9b57f2f4fc (patch)
tree1b88dfc908c3be01a86d74685a4329c69d2f9348 /drivers/mtd/tests/mtd_readtest.c
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/mtd/tests/mtd_readtest.c')
-rw-r--r--drivers/mtd/tests/mtd_readtest.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/mtd/tests/mtd_readtest.c b/drivers/mtd/tests/mtd_readtest.c
index 756045345f0..550fe51225a 100644
--- a/drivers/mtd/tests/mtd_readtest.c
+++ b/drivers/mtd/tests/mtd_readtest.c
@@ -29,7 +29,7 @@
#define PRINT_PREF KERN_INFO "mtd_readtest: "
-static int dev;
+static int dev = -EINVAL;
module_param(dev, int, S_IRUGO);
MODULE_PARM_DESC(dev, "MTD device number to use");
@@ -170,6 +170,12 @@ static int __init mtd_readtest_init(void)
printk(KERN_INFO "\n");
printk(KERN_INFO "=================================================\n");
+
+ if (dev < 0) {
+ printk(PRINT_PREF "Please specify a valid mtd-device via module paramter\n");
+ return -EINVAL;
+ }
+
printk(PRINT_PREF "MTD device: %d\n", dev);
mtd = get_mtd_device(NULL, dev);