public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* Bug in nand_select_chip?
@ 2004-03-17 15:44 llandre
  2004-03-17 15:54 ` David Woodhouse
  2004-03-17 16:05 ` Thomas Gleixner
  0 siblings, 2 replies; 9+ messages in thread
From: llandre @ 2004-03-17 15:44 UTC (permalink / raw)
  To: linux-mtd; +Cc: Andrea Scian, tglx, Matteo Bortolin

Hi,

I have a question about the nand_select_chip function. I wrote a driver for 
a Samsung NAND
Flash device (K9F5608U0C - 32MB). Everything worked fine with old MTD 
sources (July 2003).
After updating the MTD with latest CVS (2004-03-17) and applying the ilookup
patch 
(http://www.infradead.org/cgi-bin/cvsweb.cgi/~checkout~/mtd/patches/ilookup-2.4.23.patch?rev=1.1),
the same driver did not work anymore.
Then I had a look at the new sources and I noted that the nand_select_chip 
changed completely.

The old function, with chip==0, sets the nCE pin low:

static void nand_select_chip(struct mtd_info *mtd, int chip)
{
         struct nand_chip *this = mtd->priv;
         if (chip)
                 this->hwcontrol(mtd, NAND_CTL_SETNCE);
         else
                 this->hwcontrol(mtd, NAND_CTL_CLRNCE);

}


The new function, with chip==0, sets the nCE pin high:

static void nand_select_chip(struct mtd_info *mtd, int chip)
{
         struct nand_chip *this = mtd->priv;
         switch(chip) {
         case -1:
                 this->hwcontrol(mtd, NAND_CTL_CLRNCE);
                 break;
         case 0:
                 this->hwcontrol(mtd, NAND_CTL_SETNCE);
                 break;

         default:
                 BUG();
         }
}

For this reason the chip was clearly not detected at all.
After changing the new function as follows, everything works fine again:

static void nand_select_chip(struct mtd_info *mtd, int chip)
{
         struct nand_chip *this = mtd->priv;
         switch(chip) {
         case -1:
                 /* llandre - inverted default behaviour */
                 this->hwcontrol(mtd, NAND_CTL_SETNCE);
                 break;
         case 0:
                 /* llandre - inverted default behaviour */
                 this->hwcontrol(mtd, NAND_CTL_CLRNCE);
                 break;

         default:
                 BUG();
         }
}


1) Why did the code change this way?
2) I think the best way to overcome the problem is to define a proprietary 
nand_select_chip function
in the low-level driver and to make the select_chip pointer in the struct 
nand_chip to point to it. Correct?





Many thanks in advance,

llandre 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-03-18 11:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-17 15:44 Bug in nand_select_chip? llandre
2004-03-17 15:54 ` David Woodhouse
2004-03-17 16:51   ` llandre
2004-03-17 17:03     ` Thomas Gleixner
2004-03-18  8:11       ` llandre
2004-03-18  9:15         ` Thomas Gleixner
2004-03-18  9:56           ` llandre
2004-03-18 10:56             ` Thomas Gleixner
2004-03-17 16:05 ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox