[U-Boot] [PATCH 2/5] NetStar: Fix NAND

Ladislav Michl
2009-03-17T19:50:53Z

On Tue, Mar 17, 2009 at 12:17:30PM -0500, Scott Wood wrote:
> On Mon, Mar 16, 2009 at 11:28:24PM +0100, Ladislav Michl wrote:
> > Fix NAND support broken during new NAND code merge. Move those few lines of
> > code to board/netstar/netstar.c
>
> What was the breakage?

Blocks being considered bad during read. I did not make any deeper analysis,
just copied proven code.

> > +static void netstar_nand_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
> > +{
> > + struct nand_chip *chip = mtd->priv;
> > + unsigned long mask;
> > +
> > + if (cmd == NAND_CMD_NONE)
> > + return;
> > +
> > + mask = (ctrl & NAND_CLE) ? 0x02 : 0;
> > + if (ctrl & NAND_ALE)
> > + mask |= 0x04;
> > + writeb(cmd, (unsigned long)chip->IO_ADDR_W | mask);
> > +}
>
> Do not pass integers as addresses.
>
> The new function looks functionally identical to the old one (except that
> it ignores the interface in a couple of ways that it didn't before, but
> which don't really matter). Why the change? Why the difference between
> CLE using ?: and ALE using an if-statement?

The code above is identical to that found in linux driver. I'm considering
useful to keep it in sync for sake of easier future upgrades.
Sure it could be written as
if (ctrl & NAND_CLE)
mask = 0x02;
else
mask = 0;
if (ctrl & NAND_ALE)
mask |= 0x04;
but the former is a bit shorter.

Best regards,
ladis