Bug in nand_select_chip?

llandre r&d at wawnet.biz
Wed Mar 17 10:44:30 EST 2004


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 




More information about the linux-mtd mailing list