* [PATCH 1/2] mtd: Add __nand_calculate_ecc() to NAND ECC functions
@ 2009-10-19 6:11 Akinobu Mita
2009-10-19 6:11 ` [PATCH 2/2] MTD: Add nand_ecc test module Akinobu Mita
2009-10-20 12:58 ` [PATCH 1/2] mtd: Add __nand_calculate_ecc() to NAND ECC functions vimal singh
0 siblings, 2 replies; 9+ messages in thread
From: Akinobu Mita @ 2009-10-19 6:11 UTC (permalink / raw)
To: linux-mtd; +Cc: Artem Bityutskiy, David Woodhouse, Akinobu Mita
Add __nand_calculate_ecc() which does not take struct mtd_info.
The built-in 256/512 software ECC calculation and correction tester
will use it.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Cc: linux-mtd@lists.infradead.org
---
drivers/mtd/nand/nand_ecc.c | 25 ++++++++++++++++++++-----
include/linux/mtd/nand_ecc.h | 6 ++++++
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/nand/nand_ecc.c b/drivers/mtd/nand/nand_ecc.c
index db7ae9d..809fb53 100644
--- a/drivers/mtd/nand/nand_ecc.c
+++ b/drivers/mtd/nand/nand_ecc.c
@@ -150,20 +150,19 @@ static const char addressbits[256] = {
};
/**
- * nand_calculate_ecc - [NAND Interface] Calculate 3-byte ECC for 256/512-byte
+ * __nand_calculate_ecc - [NAND Interface] Calculate 3-byte ECC for 256/512-byte
* block
- * @mtd: MTD block structure
* @buf: input buffer with raw data
+ * @eccsize: data bytes per ecc step (256 or 512)
* @code: output buffer with ECC
*/
-int nand_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf,
+void __nand_calculate_ecc(const unsigned char *buf, unsigned int eccsize,
unsigned char *code)
{
int i;
const uint32_t *bp = (uint32_t *)buf;
/* 256 or 512 bytes/ecc */
- const uint32_t eccsize_mult =
- (((struct nand_chip *)mtd->priv)->ecc.size) >> 8;
+ const uint32_t eccsize_mult = eccsize >> 8;
uint32_t cur; /* current value in buffer */
/* rp0..rp15..rp17 are the various accumulated parities (per byte) */
uint32_t rp0, rp1, rp2, rp3, rp4, rp5, rp6, rp7;
@@ -412,6 +411,22 @@ int nand_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf,
(invparity[par & 0x55] << 2) |
(invparity[rp17] << 1) |
(invparity[rp16] << 0);
+}
+EXPORT_SYMBOL(__nand_calculate_ecc);
+
+/**
+ * nand_calculate_ecc - [NAND Interface] Calculate 3-byte ECC for 256/512-byte
+ * block
+ * @mtd: MTD block structure
+ * @buf: input buffer with raw data
+ * @code: output buffer with ECC
+ */
+int nand_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf,
+ unsigned char *code)
+{
+ __nand_calculate_ecc(buf,
+ ((struct nand_chip *)mtd->priv)->ecc.size, code);
+
return 0;
}
EXPORT_SYMBOL(nand_calculate_ecc);
diff --git a/include/linux/mtd/nand_ecc.h b/include/linux/mtd/nand_ecc.h
index 052ea8c..9cb10ff 100644
--- a/include/linux/mtd/nand_ecc.h
+++ b/include/linux/mtd/nand_ecc.h
@@ -16,6 +16,12 @@
struct mtd_info;
/*
+ * Calculate 3 byte ECC code for eccsize byte block
+ */
+void __nand_calculate_ecc(const u_char *dat, unsigned int eccsize,
+ u_char *ecc_code);
+
+/*
* Calculate 3 byte ECC code for 256 byte block
*/
int nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code);
--
1.5.4.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] MTD: Add nand_ecc test module
2009-10-19 6:11 [PATCH 1/2] mtd: Add __nand_calculate_ecc() to NAND ECC functions Akinobu Mita
@ 2009-10-19 6:11 ` Akinobu Mita
2009-10-19 6:15 ` Akinobu Mita
2009-10-20 11:50 ` [PATCH 2/2] " Artem Bityutskiy
2009-10-20 12:58 ` [PATCH 1/2] mtd: Add __nand_calculate_ecc() to NAND ECC functions vimal singh
1 sibling, 2 replies; 9+ messages in thread
From: Akinobu Mita @ 2009-10-19 6:11 UTC (permalink / raw)
To: linux-mtd; +Cc: Artem Bityutskiy, David Woodhouse, Akinobu Mita
This module tests NAND ECC functions.
The test is simple.
1. Create a 256 or 512 bytes block of data filled with random bytes (data)
2. Duplicate the data block and inject single bit error (error_data)
3. Try to correct error_data
4. Compare data and error_data
This test is added into new MTD test group called MTD NAND test
which requires MTD NAND device support.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org
Cc: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
drivers/mtd/Kconfig | 6 +++
drivers/mtd/tests/Makefile | 1 +
drivers/mtd/tests/nand_ecc-test.c | 88 +++++++++++++++++++++++++++++++++++++
3 files changed, 95 insertions(+), 0 deletions(-)
create mode 100644 drivers/mtd/tests/nand_ecc-test.c
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index ecf90f5..abe5c7f 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -33,6 +33,12 @@ config MTD_TESTS
should normally be compiled as kernel modules. The modules perform
various checks and verifications when loaded.
+config MTD_NAND_TESTS
+ tristate "MTD NAND tests support"
+ depends on MTD_TESTS && MTD_NAND
+ help
+ This option enables MTD tests which require NAND Device support.
+
config MTD_CONCAT
tristate "MTD concatenating support"
help
diff --git a/drivers/mtd/tests/Makefile b/drivers/mtd/tests/Makefile
index c1d5013..3994d5a 100644
--- a/drivers/mtd/tests/Makefile
+++ b/drivers/mtd/tests/Makefile
@@ -5,3 +5,4 @@ obj-$(CONFIG_MTD_TESTS) += mtd_speedtest.o
obj-$(CONFIG_MTD_TESTS) += mtd_stresstest.o
obj-$(CONFIG_MTD_TESTS) += mtd_subpagetest.o
obj-$(CONFIG_MTD_TESTS) += mtd_torturetest.o
+obj-$(CONFIG_MTD_NAND_TESTS) += nand_ecc-test.o
diff --git a/drivers/mtd/tests/nand_ecc-test.c b/drivers/mtd/tests/nand_ecc-test.c
new file mode 100644
index 0000000..54bbb4a
--- /dev/null
+++ b/drivers/mtd/tests/nand_ecc-test.c
@@ -0,0 +1,88 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/list.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+#include <linux/string.h>
+#include <linux/bitops.h>
+#include <linux/jiffies.h>
+
+void inject_single_bit_error(void *data, size_t size)
+{
+ unsigned long offset = random32() % (size * BITS_PER_BYTE);
+
+ __change_bit(offset, data);
+}
+
+#if defined(CONFIG_MTD_NAND) || defined(CONFIG_MTD_NAND_MODULE)
+
+#include <linux/mtd/nand_ecc.h>
+
+static unsigned char data[512];
+static unsigned char error_data[512];
+
+static int nand_ecc_test(const size_t size)
+{
+ unsigned char code[3];
+ unsigned char error_code[3];
+ char testname[30];
+
+ BUG_ON(sizeof(data) < size);
+
+ sprintf(testname, "nand-ecc-%zu", size);
+
+ get_random_bytes(data, size);
+
+ memcpy(error_data, data, size);
+ inject_single_bit_error(error_data, size);
+
+ __nand_calculate_ecc(data, size, code);
+ __nand_calculate_ecc(error_data, size, error_code);
+ __nand_correct_data(error_data, code, error_code, size);
+
+ if (!memcmp(data, error_data, size)) {
+ printk(KERN_INFO "nand_ecc-test: ok - %s\n", testname);
+ return 0;
+ }
+
+ printk(KERN_ERR "nand_ecc-test: not ok - %s\n", testname);
+
+ printk(KERN_DEBUG "hexdump of data:\n");
+ print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 4,
+ data, size, false);
+ printk(KERN_DEBUG "hexdump of error data:\n");
+ print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 4,
+ error_data, size, false);
+
+ return -1;
+}
+
+#else
+
+static int nand_ecc_test(const size_t size)
+{
+ return 0;
+}
+
+#endif
+
+static int __init ecc_test_init(void)
+{
+ srandom32(jiffies);
+
+ nand_ecc_test(256);
+ nand_ecc_test(512);
+
+ return 0;
+}
+
+static void __exit ecc_test_exit(void)
+{
+}
+
+module_init(ecc_test_init);
+module_exit(ecc_test_exit);
+
+MODULE_DESCRIPTION("ECC test module");
+MODULE_AUTHOR("Akinobu Mita");
+MODULE_LICENSE("GPL");
--
1.5.4.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] MTD: Add nand_ecc test module
2009-10-19 6:11 ` [PATCH 2/2] MTD: Add nand_ecc test module Akinobu Mita
@ 2009-10-19 6:15 ` Akinobu Mita
2009-10-19 6:36 ` [PATCH 2/2 -v2] " Akinobu Mita
2009-10-20 11:50 ` [PATCH 2/2] " Artem Bityutskiy
1 sibling, 1 reply; 9+ messages in thread
From: Akinobu Mita @ 2009-10-19 6:15 UTC (permalink / raw)
To: linux-mtd; +Cc: Artem Bityutskiy, David Woodhouse
On Mon, Oct 19, 2009 at 03:11:46PM +0900, Akinobu Mita wrote:
> This module tests NAND ECC functions.
>
> The test is simple.
>
> 1. Create a 256 or 512 bytes block of data filled with random bytes (data)
> 2. Duplicate the data block and inject single bit error (error_data)
> 3. Try to correct error_data
> 4. Compare data and error_data
>
> This test is added into new MTD test group called MTD NAND test
> which requires MTD NAND device support.
>
...
> +
> +#if defined(CONFIG_MTD_NAND) || defined(CONFIG_MTD_NAND_MODULE)
> +
Oops. I forgot to remove this ifdefs.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2 -v2] MTD: Add nand_ecc test module
2009-10-19 6:15 ` Akinobu Mita
@ 2009-10-19 6:36 ` Akinobu Mita
0 siblings, 0 replies; 9+ messages in thread
From: Akinobu Mita @ 2009-10-19 6:36 UTC (permalink / raw)
To: linux-mtd; +Cc: Artem Bityutskiy, David Woodhouse
* v2 changes
- remove ifdef
- make inject_single_bit_error static
This module tests NAND ECC functions.
The test is simple.
1. Create a 256 or 512 bytes block of data filled with random bytes (data)
2. Duplicate the data block and inject single bit error (error_data)
3. Try to correct error_data
4. Compare data and error_data
This test is added into new MTD test group called MTD NAND test
which requires MTD NAND device support.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org
Cc: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
drivers/mtd/Kconfig | 6 +++
drivers/mtd/tests/Makefile | 1 +
drivers/mtd/tests/nand_ecc-test.c | 76 +++++++++++++++++++++++++++++++++++++
3 files changed, 83 insertions(+), 0 deletions(-)
create mode 100644 drivers/mtd/tests/nand_ecc-test.c
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index ecf90f5..abe5c7f 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -33,6 +33,12 @@ config MTD_TESTS
should normally be compiled as kernel modules. The modules perform
various checks and verifications when loaded.
+config MTD_NAND_TESTS
+ tristate "MTD NAND tests support"
+ depends on MTD_TESTS && MTD_NAND
+ help
+ This option enables MTD tests which require NAND Device support.
+
config MTD_CONCAT
tristate "MTD concatenating support"
help
diff --git a/drivers/mtd/tests/Makefile b/drivers/mtd/tests/Makefile
index c1d5013..3994d5a 100644
--- a/drivers/mtd/tests/Makefile
+++ b/drivers/mtd/tests/Makefile
@@ -5,3 +5,4 @@ obj-$(CONFIG_MTD_TESTS) += mtd_speedtest.o
obj-$(CONFIG_MTD_TESTS) += mtd_stresstest.o
obj-$(CONFIG_MTD_TESTS) += mtd_subpagetest.o
obj-$(CONFIG_MTD_TESTS) += mtd_torturetest.o
+obj-$(CONFIG_MTD_NAND_TESTS) += nand_ecc-test.o
diff --git a/drivers/mtd/tests/nand_ecc-test.c b/drivers/mtd/tests/nand_ecc-test.c
new file mode 100644
index 0000000..6244f80
--- /dev/null
+++ b/drivers/mtd/tests/nand_ecc-test.c
@@ -0,0 +1,76 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/list.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+#include <linux/string.h>
+#include <linux/bitops.h>
+#include <linux/jiffies.h>
+#include <linux/mtd/nand_ecc.h>
+
+static void inject_single_bit_error(void *data, size_t size)
+{
+ unsigned long offset = random32() % (size * BITS_PER_BYTE);
+
+ __change_bit(offset, data);
+}
+
+static unsigned char data[512];
+static unsigned char error_data[512];
+
+static int nand_ecc_test(const size_t size)
+{
+ unsigned char code[3];
+ unsigned char error_code[3];
+ char testname[30];
+
+ BUG_ON(sizeof(data) < size);
+
+ sprintf(testname, "nand-ecc-%zu", size);
+
+ get_random_bytes(data, size);
+
+ memcpy(error_data, data, size);
+ inject_single_bit_error(error_data, size);
+
+ __nand_calculate_ecc(data, size, code);
+ __nand_calculate_ecc(error_data, size, error_code);
+ __nand_correct_data(error_data, code, error_code, size);
+
+ if (!memcmp(data, error_data, size)) {
+ printk(KERN_INFO "nand_ecc-test: ok - %s\n", testname);
+ return 0;
+ }
+
+ printk(KERN_ERR "nand_ecc-test: not ok - %s\n", testname);
+
+ printk(KERN_DEBUG "hexdump of data:\n");
+ print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 4,
+ data, size, false);
+ printk(KERN_DEBUG "hexdump of error data:\n");
+ print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 4,
+ error_data, size, false);
+
+ return -1;
+}
+
+static int __init ecc_test_init(void)
+{
+ srandom32(jiffies);
+
+ nand_ecc_test(256);
+ nand_ecc_test(512);
+
+ return 0;
+}
+
+static void __exit ecc_test_exit(void)
+{
+}
+
+module_init(ecc_test_init);
+module_exit(ecc_test_exit);
+
+MODULE_DESCRIPTION("ECC test module");
+MODULE_AUTHOR("Akinobu Mita");
+MODULE_LICENSE("GPL");
--
1.5.4.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] MTD: Add nand_ecc test module
2009-10-19 6:11 ` [PATCH 2/2] MTD: Add nand_ecc test module Akinobu Mita
2009-10-19 6:15 ` Akinobu Mita
@ 2009-10-20 11:50 ` Artem Bityutskiy
2009-10-20 12:01 ` Artem Bityutskiy
2009-10-21 4:46 ` Akinobu Mita
1 sibling, 2 replies; 9+ messages in thread
From: Artem Bityutskiy @ 2009-10-20 11:50 UTC (permalink / raw)
To: Akinobu Mita; +Cc: David Woodhouse, linux-mtd
On Mon, 2009-10-19 at 15:11 +0900, Akinobu Mita wrote:
> This module tests NAND ECC functions.
>
> The test is simple.
>
> 1. Create a 256 or 512 bytes block of data filled with random bytes (data)
> 2. Duplicate the data block and inject single bit error (error_data)
> 3. Try to correct error_data
> 4. Compare data and error_data
>
> This test is added into new MTD test group called MTD NAND test
> which requires MTD NAND device support.
>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: David Woodhouse <dwmw2@infradead.org>
> Cc: linux-mtd@lists.infradead.org
> Cc: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
> ---
> drivers/mtd/Kconfig | 6 +++
> drivers/mtd/tests/Makefile | 1 +
> drivers/mtd/tests/nand_ecc-test.c | 88 +++++++++++++++++++++++++++++++++++++
> 3 files changed, 95 insertions(+), 0 deletions(-)
> create mode 100644 drivers/mtd/tests/nand_ecc-test.c
>
> diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
> index ecf90f5..abe5c7f 100644
> --- a/drivers/mtd/Kconfig
> +++ b/drivers/mtd/Kconfig
> @@ -33,6 +33,12 @@ config MTD_TESTS
> should normally be compiled as kernel modules. The modules perform
> various checks and verifications when loaded.
>
> +config MTD_NAND_TESTS
> + tristate "MTD NAND tests support"
> + depends on MTD_TESTS && MTD_NAND
> + help
> + This option enables MTD tests which require NAND Device support.
> +
> config MTD_CONCAT
> tristate "MTD concatenating support"
> help
Could this please be a separate patch? Also, some of the existing tests
are NAND only as well, so could do corresponding Makefile changes in the
same patch and move the to the MTD_NAND_TESTS set? The tests are:
mtd_oobtest.c
mtd_pagetest.c
mtd_subpagetest.c
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] MTD: Add nand_ecc test module
2009-10-20 11:50 ` [PATCH 2/2] " Artem Bityutskiy
@ 2009-10-20 12:01 ` Artem Bityutskiy
2009-10-21 4:46 ` Akinobu Mita
1 sibling, 0 replies; 9+ messages in thread
From: Artem Bityutskiy @ 2009-10-20 12:01 UTC (permalink / raw)
To: Akinobu Mita; +Cc: linux-mtd, David Woodhouse
On Tue, 2009-10-20 at 14:50 +0300, Artem Bityutskiy wrote:
> On Mon, 2009-10-19 at 15:11 +0900, Akinobu Mita wrote:
> > This module tests NAND ECC functions.
> >
> > The test is simple.
> >
> > 1. Create a 256 or 512 bytes block of data filled with random bytes (data)
> > 2. Duplicate the data block and inject single bit error (error_data)
> > 3. Try to correct error_data
> > 4. Compare data and error_data
> >
> > This test is added into new MTD test group called MTD NAND test
> > which requires MTD NAND device support.
> >
> > Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> > Cc: David Woodhouse <dwmw2@infradead.org>
> > Cc: linux-mtd@lists.infradead.org
> > Cc: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
> > ---
> > drivers/mtd/Kconfig | 6 +++
> > drivers/mtd/tests/Makefile | 1 +
> > drivers/mtd/tests/nand_ecc-test.c | 88 +++++++++++++++++++++++++++++++++++++
> > 3 files changed, 95 insertions(+), 0 deletions(-)
> > create mode 100644 drivers/mtd/tests/nand_ecc-test.c
> >
> > diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
> > index ecf90f5..abe5c7f 100644
> > --- a/drivers/mtd/Kconfig
> > +++ b/drivers/mtd/Kconfig
> > @@ -33,6 +33,12 @@ config MTD_TESTS
> > should normally be compiled as kernel modules. The modules perform
> > various checks and verifications when loaded.
> >
> > +config MTD_NAND_TESTS
> > + tristate "MTD NAND tests support"
> > + depends on MTD_TESTS && MTD_NAND
> > + help
> > + This option enables MTD tests which require NAND Device support.
> > +
> > config MTD_CONCAT
> > tristate "MTD concatenating support"
> > help
>
> Could this please be a separate patch? Also, some of the existing tests
> are NAND only as well, so could do corresponding Makefile changes in the
> same patch and move the to the MTD_NAND_TESTS set? The tests are:
>
> mtd_oobtest.c
> mtd_pagetest.c
> mtd_subpagetest.c
Err, and of course this patch has to be the _last_ in the series, to
preserve bisectability.
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] mtd: Add __nand_calculate_ecc() to NAND ECC functions
2009-10-19 6:11 [PATCH 1/2] mtd: Add __nand_calculate_ecc() to NAND ECC functions Akinobu Mita
2009-10-19 6:11 ` [PATCH 2/2] MTD: Add nand_ecc test module Akinobu Mita
@ 2009-10-20 12:58 ` vimal singh
1 sibling, 0 replies; 9+ messages in thread
From: vimal singh @ 2009-10-20 12:58 UTC (permalink / raw)
To: Akinobu Mita; +Cc: Artem Bityutskiy, linux-mtd, David Woodhouse
On Mon, Oct 19, 2009 at 11:41 AM, Akinobu Mita <akinobu.mita@gmail.com> wrote:
> Add __nand_calculate_ecc() which does not take struct mtd_info.
> The built-in 256/512 software ECC calculation and correction tester
> will use it.
>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: David Woodhouse <dwmw2@infradead.org>
> Cc: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
> Cc: linux-mtd@lists.infradead.org
> ---
> drivers/mtd/nand/nand_ecc.c | 25 ++++++++++++++++++++-----
> include/linux/mtd/nand_ecc.h | 6 ++++++
> 2 files changed, 26 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mtd/nand/nand_ecc.c b/drivers/mtd/nand/nand_ecc.c
> index db7ae9d..809fb53 100644
> --- a/drivers/mtd/nand/nand_ecc.c
> +++ b/drivers/mtd/nand/nand_ecc.c
> @@ -150,20 +150,19 @@ static const char addressbits[256] = {
> };
>
> /**
> - * nand_calculate_ecc - [NAND Interface] Calculate 3-byte ECC for 256/512-byte
> + * __nand_calculate_ecc - [NAND Interface] Calculate 3-byte ECC for 256/512-byte
> * block
> - * @mtd: MTD block structure
> * @buf: input buffer with raw data
> + * @eccsize: data bytes per ecc step (256 or 512)
> * @code: output buffer with ECC
> */
> -int nand_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf,
> +void __nand_calculate_ecc(const unsigned char *buf, unsigned int eccsize,
> unsigned char *code)
> {
> int i;
> const uint32_t *bp = (uint32_t *)buf;
> /* 256 or 512 bytes/ecc */
> - const uint32_t eccsize_mult =
> - (((struct nand_chip *)mtd->priv)->ecc.size) >> 8;
> + const uint32_t eccsize_mult = eccsize >> 8;
> uint32_t cur; /* current value in buffer */
> /* rp0..rp15..rp17 are the various accumulated parities (per byte) */
> uint32_t rp0, rp1, rp2, rp3, rp4, rp5, rp6, rp7;
> @@ -412,6 +411,22 @@ int nand_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf,
> (invparity[par & 0x55] << 2) |
> (invparity[rp17] << 1) |
> (invparity[rp16] << 0);
> +}
> +EXPORT_SYMBOL(__nand_calculate_ecc);
> +
> +/**
> + * nand_calculate_ecc - [NAND Interface] Calculate 3-byte ECC for 256/512-byte
> + * block
> + * @mtd: MTD block structure
> + * @buf: input buffer with raw data
> + * @code: output buffer with ECC
> + */
> +int nand_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf,
> + unsigned char *code)
> +{
> + __nand_calculate_ecc(buf,
> + ((struct nand_chip *)mtd->priv)->ecc.size, code);
> +
> return 0;
> }
> EXPORT_SYMBOL(nand_calculate_ecc);
> diff --git a/include/linux/mtd/nand_ecc.h b/include/linux/mtd/nand_ecc.h
> index 052ea8c..9cb10ff 100644
> --- a/include/linux/mtd/nand_ecc.h
> +++ b/include/linux/mtd/nand_ecc.h
> @@ -16,6 +16,12 @@
> struct mtd_info;
>
> /*
> + * Calculate 3 byte ECC code for eccsize byte block
> + */
> +void __nand_calculate_ecc(const u_char *dat, unsigned int eccsize,
> + u_char *ecc_code);
> +
> +/*
> * Calculate 3 byte ECC code for 256 byte block
> */
Could you please correct above comment too?
--
Regards,
Vimal Singh
> int nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code);
> --
> 1.5.4.3
>
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] MTD: Add nand_ecc test module
2009-10-20 11:50 ` [PATCH 2/2] " Artem Bityutskiy
2009-10-20 12:01 ` Artem Bityutskiy
@ 2009-10-21 4:46 ` Akinobu Mita
2009-10-21 6:52 ` Artem Bityutskiy
1 sibling, 1 reply; 9+ messages in thread
From: Akinobu Mita @ 2009-10-21 4:46 UTC (permalink / raw)
To: Artem Bityutskiy; +Cc: David Woodhouse, linux-mtd
On Tue, Oct 20, 2009 at 02:50:01PM +0300, Artem Bityutskiy wrote:
> > diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
> > index ecf90f5..abe5c7f 100644
> > --- a/drivers/mtd/Kconfig
> > +++ b/drivers/mtd/Kconfig
> > @@ -33,6 +33,12 @@ config MTD_TESTS
> > should normally be compiled as kernel modules. The modules perform
> > various checks and verifications when loaded.
> >
> > +config MTD_NAND_TESTS
> > + tristate "MTD NAND tests support"
> > + depends on MTD_TESTS && MTD_NAND
> > + help
> > + This option enables MTD tests which require NAND Device support.
> > +
> > config MTD_CONCAT
> > tristate "MTD concatenating support"
> > help
>
> Could this please be a separate patch? Also, some of the existing tests
> are NAND only as well, so could do corresponding Makefile changes in the
> same patch and move the to the MTD_NAND_TESTS set? The tests are:
>
> mtd_oobtest.c
> mtd_pagetest.c
> mtd_subpagetest.c
Should these MTD NAND tests support OneNAND device, too?
If so, the config with !CONFIG_MTD_NAND && MTD_ONENAND=m cannot select
this new MTD_NAND_TESTS. So Kconfig dependency should be:
config MTD_NAND_TESTS
tristate "MTD NAND tests support"
depends on MTD_TEST
depends on MTD_NAND || MTD_ONENAND
But nand_ecc-test obviously needs CONFIG_MTD_NAND and cannot exist
in the same group.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] MTD: Add nand_ecc test module
2009-10-21 4:46 ` Akinobu Mita
@ 2009-10-21 6:52 ` Artem Bityutskiy
0 siblings, 0 replies; 9+ messages in thread
From: Artem Bityutskiy @ 2009-10-21 6:52 UTC (permalink / raw)
To: Akinobu Mita; +Cc: David Woodhouse, linux-mtd@lists.infradead.org
On Wed, 2009-10-21 at 06:46 +0200, ext Akinobu Mita wrote:
> On Tue, Oct 20, 2009 at 02:50:01PM +0300, Artem Bityutskiy wrote:
> > > diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
> > > index ecf90f5..abe5c7f 100644
> > > --- a/drivers/mtd/Kconfig
> > > +++ b/drivers/mtd/Kconfig
> > > @@ -33,6 +33,12 @@ config MTD_TESTS
> > > should normally be compiled as kernel modules. The modules perform
> > > various checks and verifications when loaded.
> > >
> > > +config MTD_NAND_TESTS
> > > + tristate "MTD NAND tests support"
> > > + depends on MTD_TESTS && MTD_NAND
> > > + help
> > > + This option enables MTD tests which require NAND Device support.
> > > +
> > > config MTD_CONCAT
> > > tristate "MTD concatenating support"
> > > help
> >
> > Could this please be a separate patch? Also, some of the existing tests
> > are NAND only as well, so could do corresponding Makefile changes in the
> > same patch and move the to the MTD_NAND_TESTS set? The tests are:
> >
> > mtd_oobtest.c
> > mtd_pagetest.c
> > mtd_subpagetest.c
>
> Should these MTD NAND tests support OneNAND device, too?
>
> If so, the config with !CONFIG_MTD_NAND && MTD_ONENAND=m cannot select
> this new MTD_NAND_TESTS. So Kconfig dependency should be:
>
> config MTD_NAND_TESTS
> tristate "MTD NAND tests support"
> depends on MTD_TEST
> depends on MTD_NAND || MTD_ONENAND
>
> But nand_ecc-test obviously needs CONFIG_MTD_NAND and cannot exist
> in the same group.
Oh, I see. May be your original idea with ifdefs in the code was not
bad at all :-) ?
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-10-21 6:52 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-19 6:11 [PATCH 1/2] mtd: Add __nand_calculate_ecc() to NAND ECC functions Akinobu Mita
2009-10-19 6:11 ` [PATCH 2/2] MTD: Add nand_ecc test module Akinobu Mita
2009-10-19 6:15 ` Akinobu Mita
2009-10-19 6:36 ` [PATCH 2/2 -v2] " Akinobu Mita
2009-10-20 11:50 ` [PATCH 2/2] " Artem Bityutskiy
2009-10-20 12:01 ` Artem Bityutskiy
2009-10-21 4:46 ` Akinobu Mita
2009-10-21 6:52 ` Artem Bityutskiy
2009-10-20 12:58 ` [PATCH 1/2] mtd: Add __nand_calculate_ecc() to NAND ECC functions vimal singh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox