From: vimal singh <vimal.newwork@gmail.com>
To: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: dbaryshkov@gmail.com, linux-mtd@lists.infradead.org
Subject: Re: abuse of nand_correct_data in tmio_nand driver
Date: Thu, 23 Jul 2009 12:34:43 +0530 [thread overview]
Message-ID: <ce9ab5790907230004g103af356s1b44cda2d64bbc55@mail.gmail.com> (raw)
In-Reply-To: <20090723.001338.27942898.anemo@mba.ocn.ne.jp>
On Wed, Jul 22, 2009 at 8:43 PM, Atsushi Nemoto<anemo@mba.ocn.ne.jp> wrote:
> On Wed, 22 Jul 2009 14:13:30 +0530, vimal singh <vimal.newwork@gmail.com> wrote:
>> >> This can be handled by overriding 'chip->ecc.correct' in driver. You
>> >> may reuse 'nand_correct_data()' code in the driver of 256 byte sector
>> >> ECC.
>> >
>> > Yes, the driver can reuse nand_ecc code to implement its own
>> > nand_correct rountine.
>> >
>> > Or how about adding support for 6byte-ecc/512byte-data to nand_ecc.c
>> > to avoid code duplication?
>> >
>> > I mean something like this. If it looks acceptable, I will prepare a
>> > patch including similer change to nand_calculate_ecc.
>>
>> I personally do not like any HW specific implementation going into the
>> generic part
>> of the code. This particular issue is specific to your HW, so better
>> handle it in the
>> driver only.
>
> OK, but I still feel duplicating nand_ecc code is not so good. How
> about splitting nand_correct_data into two parts? A pure calculation
> function and a wrapper for mtd interface. Like this:
But I do not see any thing extra, which you achieve from this
wrapper... Is this a prototype, and you want to handle above scenario
in this wrapper (calling 'nand_correct_data' multiple times based on
something, probably 'ecc.bytes')?
>
> diff --git a/drivers/mtd/nand/nand_ecc.c b/drivers/mtd/nand/nand_ecc.c
> index c0cb87d..3920896 100644
> --- a/drivers/mtd/nand/nand_ecc.c
> +++ b/drivers/mtd/nand/nand_ecc.c
> @@ -425,14 +425,14 @@ EXPORT_SYMBOL(nand_calculate_ecc);
> *
> * Detect and correct a 1 bit error for 256/512 byte block
> */
> -int nand_correct_data(struct mtd_info *mtd, unsigned char *buf,
> - unsigned char *read_ecc, unsigned char *calc_ecc)
> +int __nand_correct_data(unsigned char *buf,
> + unsigned char *read_ecc, unsigned char *calc_ecc,
> + unsigned int eccsize)
> {
> unsigned char b0, b1, b2, bit_addr;
> unsigned int byte_addr;
> /* 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;
>
> /*
> * b0 to b2 indicate which bit is faulty (if any)
> @@ -495,6 +495,16 @@ int nand_correct_data(struct mtd_info *mtd, unsigned char *buf,
> printk(KERN_ERR "uncorrectable error : ");
> return -1;
> }
> +EXPORT_SYMBOL(__nand_correct_data);
> +
> +int nand_correct_data(struct mtd_info *mtd, unsigned char *buf,
> + unsigned char *read_ecc, unsigned char *calc_ecc)
> +{
> + const uint32_t eccsize_mult =
> + (((struct nand_chip *)mtd->priv)->ecc.size) >> 8;
> + return __nand_correct_data(buf, read_ecc, calc_ecc,
> + ((struct nand_chip *)mtd->priv)->ecc.size);
> +}
> EXPORT_SYMBOL(nand_correct_data);
>
> MODULE_LICENSE("GPL");
>
>
> There is a little bonus: the STANDALONE macro in nand_ecc.c can be
> more useful with this change ;)
>
> ---
> Atsushi Nemoto
>
--
---
Regards,
\/ | |\/| /-\ |_
____ __o
------ -\<,
----- ( )/ ( )
next prev parent reply other threads:[~2009-07-23 7:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-14 14:05 abuse of nand_correct_data in tmio_nand driver Atsushi Nemoto
2009-07-19 0:11 ` Dmitry Eremin-Solenikov
2009-07-19 15:14 ` Atsushi Nemoto
2009-07-19 16:08 ` Dmitry Eremin-Solenikov
2009-07-20 5:15 ` vimal singh
2009-07-21 15:20 ` Atsushi Nemoto
2009-07-22 8:43 ` vimal singh
2009-07-22 15:13 ` Atsushi Nemoto
2009-07-23 7:04 ` vimal singh [this message]
2009-07-23 15:11 ` Atsushi Nemoto
2009-07-24 17:24 ` Dmitry Eremin-Solenikov
2009-07-26 13:03 ` vimal singh
2009-07-28 13:57 ` Ian molton
2009-07-28 14:11 ` Atsushi Nemoto
2009-07-28 14:35 ` Ian Molton
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=ce9ab5790907230004g103af356s1b44cda2d64bbc55@mail.gmail.com \
--to=vimal.newwork@gmail.com \
--cc=anemo@mba.ocn.ne.jp \
--cc=dbaryshkov@gmail.com \
--cc=linux-mtd@lists.infradead.org \
/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