From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Denk Date: Sun, 09 Sep 2007 01:05:38 +0200 Subject: [U-Boot-Users] [PATCH 4/5] OneNAND support In-Reply-To: Your message of "Fri, 07 Sep 2007 10:01:02 +0900." <20070907010102.GA19979@party> Message-ID: <20070908230538.DAC6324653@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello, in message <20070907010102.GA19979@party> you wrote: > [PATCH] OneNAND support > > Signed-off-by: Kyungmin Park > --- > diff --git a/drivers/onenand/onenand_bbt.c b/drivers/onenand/onenand_bbt.c > new file mode 100644 > index 0000000..6a0eb57 > --- /dev/null > +++ b/drivers/onenand/onenand_bbt.c ... > + * check_short_pattern - [GENERIC] check if a pattern is in the buffer > + * @param buf the buffer to search > + * @param len the length of buffer to search > + * @param paglen the pagelength > + * @param td search pattern descriptor > + * > + * Check for a pattern at the given place. Used to search bad block > + * tables and good / bad block identifiers. Same as check_pattern, but > + * no optional empty check and the pattern is expected to start > + * at offset 0. > + */ > +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? Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "There is no statute of limitations on stupidity." - Randomly produced by a computer program called Markov3.