[1/2] mtd: tests: don't use mtd0 as a default

Submitted by Wolfram Sang on Oct. 25, 2011, 9:09 a.m.

Details

Message ID 1319533791-32605-1-git-send-email-w.sang@pengutronix.de
State Superseded
Headers show

Commit Message

Wolfram Sang Oct. 25, 2011, 9:09 a.m.
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>
---
 drivers/mtd/tests/mtd_oobtest.c     |    2 +-
 drivers/mtd/tests/mtd_pagetest.c    |    2 +-
 drivers/mtd/tests/mtd_readtest.c    |    2 +-
 drivers/mtd/tests/mtd_speedtest.c   |    2 +-
 drivers/mtd/tests/mtd_stresstest.c  |    2 +-
 drivers/mtd/tests/mtd_subpagetest.c |    2 +-
 drivers/mtd/tests/mtd_torturetest.c |    2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

Comments

Artem Bityutskiy Oct. 25, 2011, 11:34 a.m.
On Tue, 2011-10-25 at 11:09 +0200, Wolfram Sang wrote:
> 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>
> ---
>  drivers/mtd/tests/mtd_oobtest.c     |    2 +-
>  drivers/mtd/tests/mtd_pagetest.c    |    2 +-
>  drivers/mtd/tests/mtd_readtest.c    |    2 +-
>  drivers/mtd/tests/mtd_speedtest.c   |    2 +-
>  drivers/mtd/tests/mtd_stresstest.c  |    2 +-
>  drivers/mtd/tests/mtd_subpagetest.c |    2 +-
>  drivers/mtd/tests/mtd_torturetest.c |    2 +-
>  7 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mtd/tests/mtd_oobtest.c b/drivers/mtd/tests/mtd_oobtest.c
> index dec92ae..ff77b8e 100644
> --- a/drivers/mtd/tests/mtd_oobtest.c
> +++ b/drivers/mtd/tests/mtd_oobtest.c
> @@ -30,7 +30,7 @@
>  
>  #define PRINT_PREF KERN_INFO "mtd_oobtest: "
>  
> -static int dev;
> +static int dev = -1;
>  module_param(dev, int, S_IRUGO);
>  MODULE_PARM_DESC(dev, "MTD device number to use");

How about adding something like:

if (dev == -1) {
	printk(KERN_WARN "Please, specify the test MTD device\n");
	printk(KERN_WARN "WARNING: this test destroys the test MTD device's data\n");
	return -1;
}

Of course for the readtest the warning should not be printed.
Artem Bityutskiy Oct. 29, 2011, 8:25 p.m.
On Tue, 2011-10-25 at 11:09 +0200, Wolfram Sang wrote:
> 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>

Note, I've pushed this patch to l2-mtd-2.6.git, thanks!

Artem.
Wolfram Sang Oct. 29, 2011, 8:28 p.m.
On Sat, Oct 29, 2011 at 11:25:07PM +0300, Artem Bityutskiy wrote:
> On Tue, 2011-10-25 at 11:09 +0200, Wolfram Sang wrote:
> > 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>
> 
> Note, I've pushed this patch to l2-mtd-2.6.git, thanks!

Ah, I am just about to test V2 of this patch :)

You didn't like PATCH 2/2?
Artem Bityutskiy Oct. 29, 2011, 8:35 p.m.
On Sat, 2011-10-29 at 22:28 +0200, Wolfram Sang wrote:
> On Sat, Oct 29, 2011 at 11:25:07PM +0300, Artem Bityutskiy wrote:
> > On Tue, 2011-10-25 at 11:09 +0200, Wolfram Sang wrote:
> > > 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>
> > 
> > Note, I've pushed this patch to l2-mtd-2.6.git, thanks!
> 
> Ah, I am just about to test V2 of this patch :)

I thought we need to have a fix faster so decided to push your patch as
it is, and then add some printks on top of that.

> You didn't like PATCH 2/2?

Just replied - I am not sure about the EXPERIMENTAL dependency you add.

Artem.
Roland Nov. 2, 2011, 10:11 p.m.
Thanks for all your efforts !

--------------------------------------------------
From: "Artem Bityutskiy" <dedekind1@gmail.com>
Sent: Saturday, October 29, 2011 9:25 PM
To: "Wolfram Sang" <w.sang@pengutronix.de>
Cc: <linux-mtd@lists.infradead.org>; "Roland Kletzing" <devzero@web.de>
Subject: Re: [PATCH 1/2] mtd: tests: don't use mtd0 as a default

> On Tue, 2011-10-25 at 11:09 +0200, Wolfram Sang wrote:
>> 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>
> 
> Note, I've pushed this patch to l2-mtd-2.6.git, thanks!
> 
> Artem.
>

Patch hide | download patch | download mbox

diff --git a/drivers/mtd/tests/mtd_oobtest.c b/drivers/mtd/tests/mtd_oobtest.c
index dec92ae..ff77b8e 100644
--- a/drivers/mtd/tests/mtd_oobtest.c
+++ b/drivers/mtd/tests/mtd_oobtest.c
@@ -30,7 +30,7 @@ 
 
 #define PRINT_PREF KERN_INFO "mtd_oobtest: "
 
-static int dev;
+static int dev = -1;
 module_param(dev, int, S_IRUGO);
 MODULE_PARM_DESC(dev, "MTD device number to use");
 
diff --git a/drivers/mtd/tests/mtd_pagetest.c b/drivers/mtd/tests/mtd_pagetest.c
index 00b937e..0b4db4e 100644
--- a/drivers/mtd/tests/mtd_pagetest.c
+++ b/drivers/mtd/tests/mtd_pagetest.c
@@ -30,7 +30,7 @@ 
 
 #define PRINT_PREF KERN_INFO "mtd_pagetest: "
 
-static int dev;
+static int dev = -1;
 module_param(dev, int, S_IRUGO);
 MODULE_PARM_DESC(dev, "MTD device number to use");
 
diff --git a/drivers/mtd/tests/mtd_readtest.c b/drivers/mtd/tests/mtd_readtest.c
index afe71aa..1a285c4 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 = -1;
 module_param(dev, int, S_IRUGO);
 MODULE_PARM_DESC(dev, "MTD device number to use");
 
diff --git a/drivers/mtd/tests/mtd_speedtest.c b/drivers/mtd/tests/mtd_speedtest.c
index 627d4e2..71c9457 100644
--- a/drivers/mtd/tests/mtd_speedtest.c
+++ b/drivers/mtd/tests/mtd_speedtest.c
@@ -29,7 +29,7 @@ 
 
 #define PRINT_PREF KERN_INFO "mtd_speedtest: "
 
-static int dev;
+static int dev = -1;
 module_param(dev, int, S_IRUGO);
 MODULE_PARM_DESC(dev, "MTD device number to use");
 
diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c
index 531625f..38bba93 100644
--- a/drivers/mtd/tests/mtd_stresstest.c
+++ b/drivers/mtd/tests/mtd_stresstest.c
@@ -30,7 +30,7 @@ 
 
 #define PRINT_PREF KERN_INFO "mtd_stresstest: "
 
-static int dev;
+static int dev = -1;
 module_param(dev, int, S_IRUGO);
 MODULE_PARM_DESC(dev, "MTD device number to use");
 
diff --git a/drivers/mtd/tests/mtd_subpagetest.c b/drivers/mtd/tests/mtd_subpagetest.c
index 334eae5..6140be7 100644
--- a/drivers/mtd/tests/mtd_subpagetest.c
+++ b/drivers/mtd/tests/mtd_subpagetest.c
@@ -29,7 +29,7 @@ 
 
 #define PRINT_PREF KERN_INFO "mtd_subpagetest: "
 
-static int dev;
+static int dev = -1;
 module_param(dev, int, S_IRUGO);
 MODULE_PARM_DESC(dev, "MTD device number to use");
 
diff --git a/drivers/mtd/tests/mtd_torturetest.c b/drivers/mtd/tests/mtd_torturetest.c
index 5c6c3d2..f339185 100644
--- a/drivers/mtd/tests/mtd_torturetest.c
+++ b/drivers/mtd/tests/mtd_torturetest.c
@@ -46,7 +46,7 @@  static int pgcnt;
 module_param(pgcnt, int, S_IRUGO);
 MODULE_PARM_DESC(pgcnt, "number of pages per eraseblock to torture (0 => all)");
 
-static int dev;
+static int dev = -1;
 module_param(dev, int, S_IRUGO);
 MODULE_PARM_DESC(dev, "MTD device number to use");