* [PATCH 2/2] mtd/nand: Fix tmio_nand ecc correction
@ 2009-07-28 14:53 Atsushi Nemoto
2009-07-28 17:12 ` Ian molton
0 siblings, 1 reply; 3+ messages in thread
From: Atsushi Nemoto @ 2009-07-28 14:53 UTC (permalink / raw)
To: linux-mtd; +Cc: Dmitry Eremin-Solenikov, dwmw2, vimal singh
This driver may be reading 512 bytes at a times, but still calculates
256-byte sector ECC. So the nand_correct_data() is not appropriate
for this driver. Implement its ecc.correct function calling
__nand_correct_data() twice.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Acked-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Acked-by: Vimal Singh <vimalsingh@ti.com>
---
drivers/mtd/nand/tmio_nand.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/drivers/mtd/nand/tmio_nand.c b/drivers/mtd/nand/tmio_nand.c
index daa6a4c..92c7334 100644
--- a/drivers/mtd/nand/tmio_nand.c
+++ b/drivers/mtd/nand/tmio_nand.c
@@ -301,6 +301,21 @@ static int tmio_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
return 0;
}
+static int tmio_nand_correct_data(struct mtd_info *mtd, unsigned char *buf,
+ unsigned char *read_ecc, unsigned char *calc_ecc)
+{
+ int r0, r1;
+
+ /* assume ecc.size = 512 and ecc.bytes = 6 */
+ r0 = __nand_correct_data(buf, read_ecc, calc_ecc, 256);
+ if (r0 < 0)
+ return r0;
+ r1 = __nand_correct_data(buf + 256, read_ecc + 3, calc_ecc + 3, 256);
+ if (r1 < 0)
+ return r1;
+ return r0 + r1;
+}
+
static int tmio_hw_init(struct platform_device *dev, struct tmio_nand *tmio)
{
struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data;
@@ -424,7 +439,7 @@ static int tmio_probe(struct platform_device *dev)
nand_chip->ecc.bytes = 6;
nand_chip->ecc.hwctl = tmio_nand_enable_hwecc;
nand_chip->ecc.calculate = tmio_nand_calculate_ecc;
- nand_chip->ecc.correct = nand_correct_data;
+ nand_chip->ecc.correct = tmio_nand_correct_data;
if (data)
nand_chip->badblock_pattern = data->badblock_pattern;
--
1.5.6.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] mtd/nand: Fix tmio_nand ecc correction
2009-07-28 14:53 [PATCH 2/2] mtd/nand: Fix tmio_nand ecc correction Atsushi Nemoto
@ 2009-07-28 17:12 ` Ian molton
2009-07-30 23:54 ` Atsushi Nemoto
0 siblings, 1 reply; 3+ messages in thread
From: Ian molton @ 2009-07-28 17:12 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: Dmitry Eremin-Solenikov, dwmw2, linux-mtd, vimal singh
Atsushi Nemoto wrote:
This looks fine to me, but as I said, wouldnt it be better to implement
the 6-byte ecc in the core if theres more than one chip that can use it?
no point in duplicating code...
-Ian
> This driver may be reading 512 bytes at a times, but still calculates
> 256-byte sector ECC. So the nand_correct_data() is not appropriate
> for this driver. Implement its ecc.correct function calling
> __nand_correct_data() twice.
>
> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> Acked-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> Acked-by: Vimal Singh <vimalsingh@ti.com>
> ---
> drivers/mtd/nand/tmio_nand.c | 17 ++++++++++++++++-
> 1 files changed, 16 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mtd/nand/tmio_nand.c b/drivers/mtd/nand/tmio_nand.c
> index daa6a4c..92c7334 100644
> --- a/drivers/mtd/nand/tmio_nand.c
> +++ b/drivers/mtd/nand/tmio_nand.c
> @@ -301,6 +301,21 @@ static int tmio_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
> return 0;
> }
>
> +static int tmio_nand_correct_data(struct mtd_info *mtd, unsigned char *buf,
> + unsigned char *read_ecc, unsigned char *calc_ecc)
> +{
> + int r0, r1;
> +
> + /* assume ecc.size = 512 and ecc.bytes = 6 */
> + r0 = __nand_correct_data(buf, read_ecc, calc_ecc, 256);
> + if (r0 < 0)
> + return r0;
> + r1 = __nand_correct_data(buf + 256, read_ecc + 3, calc_ecc + 3, 256);
> + if (r1 < 0)
> + return r1;
> + return r0 + r1;
> +}
> +
> static int tmio_hw_init(struct platform_device *dev, struct tmio_nand *tmio)
> {
> struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data;
> @@ -424,7 +439,7 @@ static int tmio_probe(struct platform_device *dev)
> nand_chip->ecc.bytes = 6;
> nand_chip->ecc.hwctl = tmio_nand_enable_hwecc;
> nand_chip->ecc.calculate = tmio_nand_calculate_ecc;
> - nand_chip->ecc.correct = nand_correct_data;
> + nand_chip->ecc.correct = tmio_nand_correct_data;
>
> if (data)
> nand_chip->badblock_pattern = data->badblock_pattern;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] mtd/nand: Fix tmio_nand ecc correction
2009-07-28 17:12 ` Ian molton
@ 2009-07-30 23:54 ` Atsushi Nemoto
0 siblings, 0 replies; 3+ messages in thread
From: Atsushi Nemoto @ 2009-07-30 23:54 UTC (permalink / raw)
To: ian, spyro; +Cc: dbaryshkov, dwmw2, linux-mtd, vimal.newwork
On Tue, 28 Jul 2009 18:12:40 +0100, Ian molton <spyro@f2s.com> wrote:
> This looks fine to me, but as I said, wouldnt it be better to implement
> the 6-byte ecc in the core if theres more than one chip that can use it?
>
> no point in duplicating code...
Yes, but I wonder how popular 6-byte ecc per 512 byte block compared
to other combinations. For now, keep tmio_nand_correct_data in
tmio_nand driver would be reasonable.
If many (well, two might not be enough :-)) xxx_nand_correct_data do
same thing, we can refactor them easily.
---
Atsushi Nemoto
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-07-30 23:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-28 14:53 [PATCH 2/2] mtd/nand: Fix tmio_nand ecc correction Atsushi Nemoto
2009-07-28 17:12 ` Ian molton
2009-07-30 23:54 ` Atsushi Nemoto
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.