public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: samoutin@hotbox.ru (Alex Samoutin)
To: linux-mtd@lists.infradead.org
Subject: A couple of bugs in nand_write_ecc()
Date: Fri, 14 Feb 2003 09:43:58 -0800	[thread overview]
Message-ID: <001301c2d450$aa1a07a0$1a00a8c0@itc.intrinsyc.com> (raw)

I've  found a couple of bugs in nand.c driver, or may be I just don't
understand how it should works. Please, take a look.
Function nand_write_ecc() mast write buffer to NAND with any length  and
starting with any byte. But when the last byte
not finished at sector border   nand_write_ecc() write extra bytes out of
buffer :
 /*
                * Check, if we have a full page write, then we can
                * use the given buffer, else we have to copy
                */

               if (!col && ((len - written) >= mtd->oobblock))  {
                       this->data_poi = (u_char*) &buf[written];
                       cnt = mtd->oobblock;
               } else {
                       cnt = 0;
>>>>>>>>>>>                    for (i = col; i < len && i < mtd->oobblock;
i++) {
                               this->data_buf[i] = buf[written + i];
                               cnt++;
                       }
                       this->data_poi = this->data_buf;
               }


Market line should be
for (i = col; i < (len-written) && i < mtd->oobblock; i++) {

Then we invoke    nand_write_page() function

               if (eccbuf) {
                       ret = nand_write_page (mtd, this, page, col, cnt
,&eccbuf[oob], oobsel);
                       oob += mtd->oobsize;
               } else
                       ret = nand_write_page (mtd, this, page, col, cnt,
NULL, oobsel);

Where the "col" is offset form page start and "cnt" is leght of data. But
nand_write_page ()
defined as:

static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this,
                           int page, int col, int last, u_char *oob_buf, int
oobsel)

where "col" mean the same, but "last" is offset of last byte of data!

So, we have to use:

   ret = nand_write_page (mtd, this, page, col, col+cnt, NULL, oobsel)

Am I right?

Alex.

             reply	other threads:[~2003-02-14 17:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-14 17:43 Alex Samoutin [this message]
2003-02-14 23:01 ` A couple of bugs in nand_write_ecc() Thomas Gleixner
2003-02-15  1:05   ` Alex Samoutin
2003-02-15  7:48     ` Thomas Gleixner
2003-02-15 11:30     ` Thomas Gleixner

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='001301c2d450$aa1a07a0$1a00a8c0@itc.intrinsyc.com' \
    --to=samoutin@hotbox.ru \
    --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