From 135f0a7488af2947adbe4b40b79280bdfe5e9886 Mon Sep 17 00:00:00 2001 From: Scott Wood Date: Mon, 19 May 2008 09:30:43 -0500 Subject: [PATCH 1/5] NAND: Provide a sane default for NAND_MAX_CHIPS. This allows the header to be included regardless of whether a board's config file provides NAND-related defininitions. Signed-off-by: Scott Wood --- include/linux/mtd/nand.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 4cc4a7d1bb..e2a25a60d8 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -385,6 +385,10 @@ struct nand_manufacturers { extern struct nand_flash_dev nand_flash_ids[]; extern struct nand_manufacturers nand_manuf_ids[]; +#ifndef NAND_MAX_CHIPS +#define NAND_MAX_CHIPS 8 +#endif + /** * struct nand_bbt_descr - bad block table descriptor * @options: options for this descriptor From 5922db6c0948506be91e0de44e7a6863a18a417f Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Tue, 13 May 2008 17:31:24 +0200 Subject: [PATCH 2/5] Cleanup nand_info[] declaration. The nand_info array is declared as extern in several .c files. Those days, nand.h contains a reference to the array, so there is no need to declare it elsewhere. Signed-off-by: Stelian Pop Signed-off-by: Scott Wood --- common/cmd_nand.c | 2 -- common/env_nand.c | 3 --- fs/jffs2/jffs2_1pass.c | 3 --- 3 files changed, 8 deletions(-) diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 37eb41b20e..37198d21e8 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -37,8 +37,6 @@ int find_dev_and_part(const char *id, struct mtd_device **dev, u8 *part_num, struct part_info **part); #endif -extern nand_info_t nand_info[]; /* info for NAND chips */ - static int nand_dump_oob(nand_info_t *nand, ulong off) { return 0; diff --git a/common/env_nand.c b/common/env_nand.c index 70d05ad15a..3a98d2b944 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -57,9 +57,6 @@ int nand_legacy_rw (struct nand_chip* nand, int cmd, size_t start, size_t len, size_t * retlen, u_char * buf); -/* info for NAND chips, defined in drivers/mtd/nand/nand.c */ -extern nand_info_t nand_info[]; - /* references to names in env_common.c */ extern uchar default_environment[]; extern int default_environment_size; diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c index 1993dc2359..7e27ee18a2 100644 --- a/fs/jffs2/jffs2_1pass.c +++ b/fs/jffs2/jffs2_1pass.c @@ -164,9 +164,6 @@ static struct part_info *current_part; /* this one defined in nand_legacy.c */ int read_jffs2_nand(size_t start, size_t len, size_t * retlen, u_char * buf, int nanddev); -#else -/* info for NAND chips, defined in drivers/mtd/nand/nand.c */ -extern nand_info_t nand_info[]; #endif #define NAND_PAGE_SIZE 512 From 9723bbb46abb7b2ca24eead5114a3faa58060c20 Mon Sep 17 00:00:00 2001 From: Dirk Behme Date: Wed, 16 Jan 2008 14:26:59 +0100 Subject: [PATCH 3/5] nand: Correct NAND erase percentage output For NAND erase sizes smaller than one NAND erase block, erase percentage output becomes grater than 100% e.g. -- cut -- > nand info Device 0: NAND 64MiB 1,8V 8-bit, sector size 16 KiB > nand erase 0x100000 0x2000 NAND erase: device 0 offset 0x100000, size 0x2000 Erasing at 0x100000 -- 200% complete. OK > -- cut -- Correct this and give user a warning that more is erased than specified: -- cut -- > nand erase 0x100000 0x2000 NAND erase: device 0 offset 0x100000, size 0x2000 Warning: Erase size 0x00002000 smaller than one erase block 0x00004000 Erasing 0x00004000 instead Erasing at 0x100000 -- 100% complete. OK > -- cut -- Signed-off-by: Dirk Behme --- drivers/mtd/nand/nand_util.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c index 6c5624a49a..c82f77b555 100644 --- a/drivers/mtd/nand/nand_util.c +++ b/drivers/mtd/nand/nand_util.c @@ -153,6 +153,13 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts) priv_nand->bbt = NULL; } + if (erase_length < meminfo->erasesize) { + printf("Warning: Erase size 0x%08x smaller than one " \ + "erase block 0x%08x\n",erase_length, meminfo->erasesize); + printf(" Erasing 0x%08x instead\n", meminfo->erasesize); + erase_length = meminfo->erasesize; + } + for (; erase.addr < opts->offset + erase_length; erase.addr += meminfo->erasesize) { From 229c56f07a82eacda8c8720cb146fc9be0f6db54 Mon Sep 17 00:00:00 2001 From: Scott Wood Date: Thu, 22 May 2008 10:49:00 -0500 Subject: [PATCH 4/5] Make onenand_uboot.h self-sufficient. Don't assume types are provided by previously included headers. Signed-off-by: Scott Wood --- include/onenand_uboot.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/onenand_uboot.h b/include/onenand_uboot.h index bd1831ea6d..4449f987bf 100644 --- a/include/onenand_uboot.h +++ b/include/onenand_uboot.h @@ -14,6 +14,8 @@ #ifndef __UBOOT_ONENAND_H #define __UBOOT_ONENAND_H +#include + struct kvec { void *iov_base; size_t iov_len; @@ -22,6 +24,9 @@ struct kvec { typedef int spinlock_t; typedef int wait_queue_head_t; +struct mtd_info; +struct erase_info; + /* Functions */ extern void onenand_init(void); extern int onenand_read(struct mtd_info *mtd, loff_t from, size_t len, From d6ac2ed893c2168738aee01579d6283af8d37045 Mon Sep 17 00:00:00 2001 From: Scott Wood Date: Thu, 22 May 2008 10:49:46 -0500 Subject: [PATCH 5/5] Remove prototypes of nand_init() in favor of including nand.h. Likewise with onenand_init(). Signed-off-by: Scott Wood --- lib_arm/board.c | 10 ++-------- lib_ppc/board.c | 4 +--- lib_sh/board.c | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/lib_arm/board.c b/lib_arm/board.c index 67506b35e1..5e04553911 100644 --- a/lib_arm/board.c +++ b/lib_arm/board.c @@ -45,6 +45,8 @@ #include #include #include +#include +#include #ifdef CONFIG_DRIVER_SMC91111 #include "../drivers/net/smc91111.h" @@ -55,14 +57,6 @@ DECLARE_GLOBAL_DATA_PTR; -#if defined(CONFIG_CMD_NAND) -void nand_init (void); -#endif - -#if defined(CONFIG_CMD_ONENAND) -void onenand_init(void); -#endif - ulong monitor_flash_len; #ifdef CONFIG_HAS_DATAFLASH diff --git a/lib_ppc/board.c b/lib_ppc/board.c index 4956403cce..6f7242d622 100644 --- a/lib_ppc/board.c +++ b/lib_ppc/board.c @@ -93,9 +93,7 @@ void doc_init (void); #if defined(CONFIG_HARD_SPI) #include #endif -#if defined(CONFIG_CMD_NAND) -void nand_init (void); -#endif +#include static char *failed = "*** failed ***\n"; diff --git a/lib_sh/board.c b/lib_sh/board.c index 883c381e64..807415c548 100644 --- a/lib_sh/board.c +++ b/lib_sh/board.c @@ -76,7 +76,7 @@ static int sh_flash_init(void) } #if defined(CONFIG_CMD_NAND) -void nand_init (void); +#include static int sh_nand_init(void) { printf("NAND: ");