linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <ffainelli@freebox.fr>
To: linux-mtd@lists.infradead.org
Cc: David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <norris@broadcom.com>,
	Matthieu CASTET <matthieu.castet@parrot.com>
Subject: Re: [PATCH 3/3] NAND: add support for reading ONFI parameters from NAND device
Date: Fri, 13 Aug 2010 11:00:38 +0200	[thread overview]
Message-ID: <201008131100.38707.ffainelli@freebox.fr> (raw)
In-Reply-To: <4C64F34F.8020402@parrot.com>

Hello,

On Friday 13 August 2010 09:25:03 Matthieu CASTET wrote:
> Hello,
> 
> Florian Fainelli a écrit :
> > Hello Brian,
> > 
> > Le Thursday 12 August 2010 20:57:42, Brian Norris a écrit :
> >> Hello,
> >> 
> >> I've got a few comments and a patch; I cannot test them, though,
> >> just build.
> >> 
> >> On 08/12/2010 05:53 AM, Florian Fainelli wrote:
> >>> +static u16 onfi_crc(u16 crc, unsigned char const *p, size_t len)
> >>> +{
> >>> +   int i;
> >>> +   while (len--) {
> >>> +           crc ^= *p++<<  8;
> >>> +           for (i = 0; i<  8; i++)
> >>> +                   crc = (crc<<  1) ^ ((crc&  0x8000) ? 0x8005 : 0);
> >>> +   }
> >>> +   return crc;
> >>> +}
> >> 
> >> Can this function safely be replaced by the library function crc16?
> >> #include <linux/crc16.h>
> >> u16 crc16(u16 crc, u8 const *buffer, size_t len);
> > 
> > Certainly, thanks for noticing.
> 
> No it is not the same crc16 endianness, one is big the other is little.

Maybe we should add a crc16_le to lib/crc16.c?

> 
> >>> +
> >>> +   chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);
> >>> +
> >>> +   /* Read entire ID string */
> >>> +
> >>> +   for (i = 0; i<  8; i++)
> >>> +           id_data[i] = chip->read_byte(mtd);
> >>> +
> >>> 
> >>>     if (!type->name)
> >>>     
> >>>             return ERR_PTR(-ENODEV);
> >> 
> >> Do we really need a third chance to read the ID bytes? It seems like we
> >> can just read the whole string the second time instead of shortening it
> >> to two bytes and waiting to reread all 8 bytes until after the ONFI
> >> scan.
> 
> Well onfi define only 2 bytes for id string, I though it was safer to
> not read beyond specification for onfi nand.
> 
> >>> +                                   if (val&  (1<<  1))
> >>> +                                           chip->onfi_version = 10;
> >>> +                                   else if (val&  (1<<  2))
> >>> +                                           chip->onfi_version = 20;
> >>> +                                   else if (val&  (1<<  3))
> >>> +                                           chip->onfi_version = 21;
> >>> +                                   else
> >>> +                                           chip->onfi_version = 22;
> >> 
> >> I cannot currently test ONFI on a real chip, but shouldn't the order of
> >> these conditionals be switched? It seems possible that the bits could be
> >> set high for more the one version (e.g., a chip supports 1.0 and 2.0, so
> >> we have val = 00000110 (binary), so the current logic would succeed at
> >> 1.0, not realizing that it supports 2.0. Again, I don't know about the
> >> actual behavior in a real chip, but anyway, it seems harmless to
> >> reverse this.
> > 
> > I think you are right about this. We only have ONFI 1.0 compliant chips
> > right now, so we can't know for sure, but as you say, this is harmless.
> 
> ok
> 
> 
> Matthieu
> 
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/

      reply	other threads:[~2010-08-13  9:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-12 12:53 [PATCH 3/3] NAND: add support for reading ONFI parameters from NAND device Florian Fainelli
2010-08-12 18:57 ` Brian Norris
2010-08-12 19:47   ` Florian Fainelli
2010-08-12 23:06     ` Brian Norris
2010-08-13  9:01       ` Florian Fainelli
2010-08-13  7:25     ` Matthieu CASTET
2010-08-13  9:00       ` Florian Fainelli [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=201008131100.38707.ffainelli@freebox.fr \
    --to=ffainelli@freebox.fr \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=matthieu.castet@parrot.com \
    --cc=norris@broadcom.com \
    /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;
as well as URLs for NNTP newsgroup(s).