[U-Boot-Users] [PATCH 4/5] OneNAND support

Kyungmin Park kmpark at infradead.org
Mon Sep 10 03:19:43 CEST 2007


> > + */
> > +static int check_short_pattern(uint8_t * buf, int len, int paglen,
> > +			       struct nand_bbt_descr *td)
> > +{
> > +	int i;
> > +	uint8_t *p = buf;
> > +
> > +	/* Compare the pattern */
> > +	for (i = 0; i < td->len; i++) {
> > +		if (p[i] != td->pattern[i])
> > +			return -1;
> > +	}
> > +	return 0;
> > +}
> 
> This should probably be replaced by a call to memmem() ?
> 
> > +/**
> > + * onenand_memory_bbt - [GENERIC] create a memory based bad block table
> > + * @param mtd		MTD device structure
> > + * @param bd		descriptor for the good/bad block search pattern
> > + *
> > + * The function creates a memory based bbt by scanning the device
> > + * for manufacturer / software marked good / bad blocks
> > + */
> > +static inline int onenand_memory_bbt(struct mtd_info *mtd,
> > +				     struct nand_bbt_descr *bd)
> > +{
> > +	unsigned char data_buf[MAX_ONENAND_PAGESIZE];
> > +
> > +	bd->options &= ~NAND_BBT_SCANEMPTY;
> > +	return create_bbt(mtd, data_buf, bd, -1);
> > +}
> 
> This scares me. What is data_buf[] being used for? You are aware that
> it goes out of scope when that function returns?

This BBT code is not yet implemented.
It's only scan the full blocks at boot time and display the bad blocks.

It's also next time work.

It will be changed at following using page_buf allocated at onenand_init code.
static inline int onenand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd)
{
        struct onenand_chip *this = mtd->priv;

        bd->options &= ~NAND_BBT_SCANEMPTY;
        return create_bbt(mtd, this->page_buf, bd, -1);
}

Thank you,
Kyungmin Park





More information about the U-Boot mailing list