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

Artem Bityutskiy
2011-10-25T11:35:29Z

[-- Attachment #1: Type: text/plain, Size: 1577 bytes --]

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.

--
Best Regards,
Artem Bityutskiy

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]