public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind1@gmail.com>
To: Wolfram Sang <w.sang@pengutronix.de>
Cc: Roland Kletzing <devzero@web.de>, linux-mtd@lists.infradead.org
Subject: Re: [PATCH 1/2] mtd: tests: don't use mtd0 as a default
Date: Sat, 29 Oct 2011 23:28:14 +0300	[thread overview]
Message-ID: <1319920098.2126.17.camel@koala> (raw)
In-Reply-To: <1319533791-32605-1-git-send-email-w.sang@pengutronix.de>

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>

On top of this I've added the following patch:

>From 16a50bac6deb68e56c49d64d18952ba9ce5621d1 Mon Sep 17 00:00:00 2001
From: Artem Bityutskiy <Artem.Bityutskiy@intel.com>
Date: Sat, 29 Oct 2011 23:20:34 +0300
Subject: [PATCH] mtd: add a scary warning

The MTD tests require mtd device number to be specified. If the user
does not specify it, print a message and warn that the tests are
destructive and will wipe whole MTD device. This is a measure to make
sure we do not have more reports from unhappy users accidentally losing
their data.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@intel.com>
---
 drivers/mtd/tests/mtd_oobtest.c     |    6 ++++++
 drivers/mtd/tests/mtd_pagetest.c    |    6 ++++++
 drivers/mtd/tests/mtd_readtest.c    |    5 +++++
 drivers/mtd/tests/mtd_speedtest.c   |    6 ++++++
 drivers/mtd/tests/mtd_stresstest.c  |    6 ++++++
 drivers/mtd/tests/mtd_subpagetest.c |    6 ++++++
 drivers/mtd/tests/mtd_torturetest.c |    6 ++++++
 7 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/tests/mtd_oobtest.c b/drivers/mtd/tests/mtd_oobtest.c
index f253acb..673f3d1 100644
--- a/drivers/mtd/tests/mtd_oobtest.c
+++ b/drivers/mtd/tests/mtd_oobtest.c
@@ -364,6 +364,12 @@ static int __init mtd_oobtest_init(void)
 	struct mtd_oob_ops ops;
 	loff_t addr = 0, addr0;
 
+	if (dev == -1) {
+		printk(KERN_ERR "Please, specify the MTD device\n");
+		printk(KERN_ALERT "Careful! This test will wipe the MTD device!\n");
+		return -EINVAL;
+	}
+
 	printk(KERN_INFO "\n");
 	printk(KERN_INFO "=================================================\n");
 	printk(PRINT_PREF "MTD device: %d\n", dev);
diff --git a/drivers/mtd/tests/mtd_pagetest.c b/drivers/mtd/tests/mtd_pagetest.c
index f27b196..e4c263d 100644
--- a/drivers/mtd/tests/mtd_pagetest.c
+++ b/drivers/mtd/tests/mtd_pagetest.c
@@ -502,6 +502,12 @@ static int __init mtd_pagetest_init(void)
 	uint64_t tmp;
 	uint32_t i;
 
+	if (dev == -1) {
+		printk(KERN_ERR "Please, specify the MTD device\n");
+		printk(KERN_ALERT "Careful! This test will wipe the MTD device!\n");
+		return -EINVAL;
+	}
+
 	printk(KERN_INFO "\n");
 	printk(KERN_INFO "=================================================\n");
 	printk(PRINT_PREF "MTD device: %d\n", dev);
diff --git a/drivers/mtd/tests/mtd_readtest.c b/drivers/mtd/tests/mtd_readtest.c
index a40d860..7b44d57 100644
--- a/drivers/mtd/tests/mtd_readtest.c
+++ b/drivers/mtd/tests/mtd_readtest.c
@@ -168,6 +168,11 @@ static int __init mtd_readtest_init(void)
 	uint64_t tmp;
 	int err, i;
 
+	if (dev == -1) {
+		printk(KERN_ERR "Please, specify the MTD device\n");
+		return -EINVAL;
+	}
+
 	printk(KERN_INFO "\n");
 	printk(KERN_INFO "=================================================\n");
 	printk(PRINT_PREF "MTD device: %d\n", dev);
diff --git a/drivers/mtd/tests/mtd_speedtest.c b/drivers/mtd/tests/mtd_speedtest.c
index 7ce07f9..a82ac11 100644
--- a/drivers/mtd/tests/mtd_speedtest.c
+++ b/drivers/mtd/tests/mtd_speedtest.c
@@ -359,6 +359,12 @@ static int __init mtd_speedtest_init(void)
 	long speed;
 	uint64_t tmp;
 
+	if (dev == -1) {
+		printk(KERN_ERR "Please, specify the MTD device\n");
+		printk(KERN_ALERT "Careful! This test will wipe the MTD device!\n");
+		return -EINVAL;
+	}
+
 	printk(KERN_INFO "\n");
 	printk(KERN_INFO "=================================================\n");
 	if (count)
diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c
index b4f8879..376fd16 100644
--- a/drivers/mtd/tests/mtd_stresstest.c
+++ b/drivers/mtd/tests/mtd_stresstest.c
@@ -248,6 +248,12 @@ static int __init mtd_stresstest_init(void)
 	int i, op;
 	uint64_t tmp;
 
+	if (dev == -1) {
+		printk(KERN_ERR "Please, specify the MTD device\n");
+		printk(KERN_ALERT "Careful! This test will wipe the MTD device!\n");
+		return -EINVAL;
+	}
+
 	printk(KERN_INFO "\n");
 	printk(KERN_INFO "=================================================\n");
 	printk(PRINT_PREF "MTD device: %d\n", dev);
diff --git a/drivers/mtd/tests/mtd_subpagetest.c b/drivers/mtd/tests/mtd_subpagetest.c
index 85a86a7..d6f983f 100644
--- a/drivers/mtd/tests/mtd_subpagetest.c
+++ b/drivers/mtd/tests/mtd_subpagetest.c
@@ -377,6 +377,12 @@ static int __init mtd_subpagetest_init(void)
 	uint32_t i;
 	uint64_t tmp;
 
+	if (dev == -1) {
+		printk(KERN_ERR "Please, specify the MTD device\n");
+		printk(KERN_ALERT "Careful! This test will wipe the MTD device!\n");
+		return -EINVAL;
+	}
+
 	printk(KERN_INFO "\n");
 	printk(KERN_INFO "=================================================\n");
 	printk(PRINT_PREF "MTD device: %d\n", dev);
diff --git a/drivers/mtd/tests/mtd_torturetest.c b/drivers/mtd/tests/mtd_torturetest.c
index fb3b903..a08c3cd 100644
--- a/drivers/mtd/tests/mtd_torturetest.c
+++ b/drivers/mtd/tests/mtd_torturetest.c
@@ -209,6 +209,12 @@ static int __init tort_init(void)
 	int err = 0, i, infinite = !cycles_count;
 	int bad_ebs[ebcnt];
 
+	if (dev == -1) {
+		printk(KERN_ERR "Please, specify the MTD device\n");
+		printk(KERN_ALERT "Careful! This test will wipe the MTD device!\n");
+		return -EINVAL;
+	}
+
 	printk(KERN_INFO "\n");
 	printk(KERN_INFO "=================================================\n");
 	printk(PRINT_PREF "Warning: this program is trying to wear out your "
-- 
1.7.6

      parent reply	other threads:[~2011-10-29 20:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-25  9:09 [PATCH 1/2] mtd: tests: don't use mtd0 as a default Wolfram Sang
2011-10-25  9:09 ` [PATCH 2/2] mtd: mark tests EXPERIMENTAL Wolfram Sang
2011-10-29 20:30   ` Artem Bityutskiy
2011-10-29 20:40     ` Wolfram Sang
2011-10-30 12:29       ` Artem Bityutskiy
2011-10-30 16:28         ` [PATCH V2 2/2] mtd: tests: annotate as DANGEROUS in Kconfig Wolfram Sang
2011-10-30 20:34           ` Artem Bityutskiy
2011-10-30 20:37             ` Wolfram Sang
2011-10-31 17:00               ` Brian Norris
2011-11-08 20:35                 ` Artem Bityutskiy
2011-10-25 11:34 ` [PATCH 1/2] mtd: tests: don't use mtd0 as a default Artem Bityutskiy
2011-10-29 20:25 ` Artem Bityutskiy
2011-10-29 20:28   ` Wolfram Sang
2011-10-29 20:35     ` Artem Bityutskiy
2011-10-29 20:56       ` [PATCH V2 " Wolfram Sang
2011-10-29 21:12         ` Artem Bityutskiy
2011-10-29 22:11           ` [PATCH V3 " Wolfram Sang
2011-10-30 12:32             ` Artem Bityutskiy
2011-10-30 12:24         ` [PATCH V2 " Artem Bityutskiy
2011-11-02 22:11   ` [PATCH " Roland Kletzing
2011-10-29 20:28 ` Artem Bityutskiy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1319920098.2126.17.camel@koala \
    --to=dedekind1@gmail.com \
    --cc=devzero@web.de \
    --cc=linux-mtd@lists.infradead.org \
    --cc=w.sang@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox