[U-Boot-Users] [PATCH] Fix OneNAND build break

Scott Wood scottwood at freescale.com
Wed Aug 13 18:02:07 CEST 2008


On Wed, Aug 13, 2008 at 09:11:02AM +0900, Kyungmin Park wrote:
> Since page size field is changed from oobblock to writesize. But OneNAND is not updated.
> - fix bufferram management at erase operation
> This patch includes the NAND/OneNAND state filed too.

Applied to nand-flash, with some changes:

> +static void onenand_invalidate_bufferram(struct mtd_info *mtd, loff_t addr,
> +                unsigned int len)
> +{
> +        struct onenand_chip *this = mtd->priv;
> +        int i;
> +        loff_t end_addr = addr + len;
> +
> +        /* Invalidate BufferRAM */

Use tabs for indentation.

>  /**
> + * onenand_block_isbad_nolock - [GENERIC] Check if a block is marked bad
> + * @param mtd		MTD device structure
> + * @param ofs		offset from device start
> + * @param allowbbt	1, if its allowed to access the bbt area
> + *
> + * Check, if the block is bad, Either by reading the bad block table or
> + * calling of the scan function.
> + */
> +static int onenand_block_isbad_nolock(struct mtd_info *mtd, loff_t ofs, int allowbbt)
> +{
> +	struct onenand_chip *this = mtd->priv;
> +	struct bbm_info *bbm = this->bbm;
> +
> +	/* Return info from the table */
> +	return bbm->isbad_bbt(mtd, ofs, allowbbt);
> +}
[snip]
> @@ -1005,30 +1050,45 @@ void onenand_sync(struct mtd_info *mtd)
>   * onenand_block_isbad - [MTD Interface] Check whether the block at the given offset is bad
>   * @param mtd		MTD device structure
>   * @param ofs		offset relative to mtd start
> + *
> + * Check whether the block is bad
>   */
>  int onenand_block_isbad(struct mtd_info *mtd, loff_t ofs)
>  {
> -	/*
> -	 * TODO
> -	 * 1. Bad block table (BBT)
> -	 *   -> using NAND BBT to support JFFS2
> -	 * 2. Bad block management (BBM)
> -	 *   -> bad block replace scheme
> -	 *
> -	 * Currently we do nothing
> -	 */
> -	return 0;
> +	int ret;
> +
> +	/* Check for invalid offset */
> +	if (ofs > mtd->size)
> +		return -EINVAL;
> +
> +	onenand_get_device(mtd, FL_READING);
> +	ret = onenand_block_isbad_nolock(mtd,ofs, 0);
> +	onenand_release_device(mtd);
> +	return ret;
>  }

This wasn't mentioned in the changelog.

> @@ -1184,10 +1244,8 @@ static int onenand_probe(struct mtd_info *mtd)
>  	/* Reset OneNAND to read default register values */
>  	this->write_word(ONENAND_CMD_RESET, this->base + ONENAND_BOOTRAM);
>  
> -	{
> -		int i;
> -		for (i = 0; i < 10000; i++) ;
> -	}
> +	/* Wait reset */
> +	this->wait(mtd, FL_RESETING);

Nor was this.

> diff --git a/include/linux/mtd/compat.h b/include/linux/mtd/compat.h
> index 9036b74..a4dc3e9 100644
> --- a/include/linux/mtd/compat.h
> +++ b/include/linux/mtd/compat.h
> @@ -18,7 +18,11 @@
>  #define KERN_DEBUG
>  
>  #define kmalloc(size, flags)	malloc(size)
> -#define kzalloc(size, flags)	calloc(size, 1)
> +#define kzalloc(size, flags)	({					\
> +	void *__ret = malloc(size);					\
> +	memset(__ret, 0, size);						\
> +	__ret;								\
> +})

What's the reason for this?  It fails to handle malloc() failure, BTW. 
Not applied.

> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index 8e0dc00..131d7aa 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -22,6 +22,21 @@
>  #define MTD_ERASE_DONE          0x08
>  #define MTD_ERASE_FAILED        0x10
>  
> +/*
> + * Enumeration for NAND/OneNAND flash chip state
> + */
> +enum {
> +	FL_READY,
> +	FL_READING,
> +	FL_WRITING,
> +	FL_ERASING,
> +	FL_SYNCING,
> +	FL_CACHEDPRG,
> +	FL_RESETING,
> +	FL_UNLOCKING,
> +	FL_LOCKING,
> +};

You left out FL_PM_SUSPENDED.

> diff --git a/include/onenand_uboot.h b/include/onenand_uboot.h
> index 4260ee7..41e30a2 100644
> --- a/include/onenand_uboot.h
> +++ b/include/onenand_uboot.h
> @@ -15,18 +15,13 @@
>  #define __UBOOT_ONENAND_H
>  
>  #include <linux/types.h>
> -
> -struct kvec {
> -	void *iov_base;
> -	size_t iov_len;
> -};
> -
> -typedef int spinlock_t;
> -typedef int wait_queue_head_t;
> +#include <mtd_uboot.h>

mtd_uboot.h does not exist.  Not applied.

You also need to fix read_oob/write_oob for the new API.

-Scott




More information about the U-Boot mailing list