summaryrefslogtreecommitdiff
path: root/drivers/mtd/cfi_mtd.c
diff options
context:
space:
mode:
authorMinkyu Kang <mk7.kang@samsung.com>2010-03-15 10:51:36 +0900
committerMinkyu Kang <mk7.kang@samsung.com>2010-03-15 10:51:36 +0900
commit995a4b1d83a08223c82c1e15778b02e85e5bba51 (patch)
tree0acb85278216df76d8fb7284b32d6dd95a1fc978 /drivers/mtd/cfi_mtd.c
parenta8d25fc26f681a9c4dfb062ebb4b00b9509a7966 (diff)
parent44de3e8ff7ed48bf96ec6c5e2173187d9c1c61e6 (diff)
downloadu-boot-imx-995a4b1d83a08223c82c1e15778b02e85e5bba51.zip
u-boot-imx-995a4b1d83a08223c82c1e15778b02e85e5bba51.tar.gz
u-boot-imx-995a4b1d83a08223c82c1e15778b02e85e5bba51.tar.bz2
Merge branch 'master' of git://git.denx.de/u-boot-arm
Conflicts: board/davinci/da830evm/da830evm.c board/edb93xx/sdram_cfg.c board/esd/otc570/otc570.c board/netstar/eeprom.c board/netstar/eeprom_start.S cpu/arm920t/ep93xx/timer.c include/configs/netstar.h include/configs/otc570.h Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
Diffstat (limited to 'drivers/mtd/cfi_mtd.c')
-rw-r--r--drivers/mtd/cfi_mtd.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/drivers/mtd/cfi_mtd.c b/drivers/mtd/cfi_mtd.c
index 34748dd..6a0cab3 100644
--- a/drivers/mtd/cfi_mtd.c
+++ b/drivers/mtd/cfi_mtd.c
@@ -161,8 +161,8 @@ static int cfi_mtd_set_erasesize(struct mtd_info *mtd, flash_info_t *fi)
int sect;
int regions = 0;
int numblocks = 0;
- ulong offset = 0;
- ulong base_addr = fi->start[0];
+ ulong offset;
+ ulong base_addr;
/*
* First detect the number of eraseregions so that we can allocate
@@ -174,29 +174,35 @@ static int cfi_mtd_set_erasesize(struct mtd_info *mtd, flash_info_t *fi)
sect_size_old = flash_sector_size(fi, sect);
}
+ switch (regions) {
+ case 0:
+ return 1;
+ case 1: /* flash has uniform erase size */
+ mtd->numeraseregions = 0;
+ mtd->erasesize = sect_size_old;
+ return 0;
+ }
+
+ mtd->numeraseregions = regions;
mtd->eraseregions = malloc(sizeof(struct mtd_erase_region_info) * regions);
/*
* Now detect the largest sector and fill the eraseregions
*/
- sect_size_old = 0;
regions = 0;
+ base_addr = offset = fi->start[0];
+ sect_size_old = flash_sector_size(fi, 0);
for (sect = 0; sect < fi->sector_count; sect++) {
- if ((sect_size_old != flash_sector_size(fi, sect)) &&
- (sect_size_old != 0)) {
+ if (sect_size_old != flash_sector_size(fi, sect)) {
mtd->eraseregions[regions].offset = offset - base_addr;
mtd->eraseregions[regions].erasesize = sect_size_old;
mtd->eraseregions[regions].numblocks = numblocks;
-
/* Now start counting the next eraseregions */
numblocks = 0;
regions++;
- } else {
- numblocks++;
- }
-
- if (sect_size_old != flash_sector_size(fi, sect))
offset = fi->start[sect];
+ }
+ numblocks++;
/*
* Select the largest sector size as erasesize (e.g. for UBI)
@@ -212,12 +218,7 @@ static int cfi_mtd_set_erasesize(struct mtd_info *mtd, flash_info_t *fi)
*/
mtd->eraseregions[regions].offset = offset - base_addr;
mtd->eraseregions[regions].erasesize = sect_size_old;
- mtd->eraseregions[regions].numblocks = numblocks + 1;
-
- if (regions)
- mtd->numeraseregions = regions + 1;
- else
- mtd->numeraseregions = 0;
+ mtd->eraseregions[regions].numblocks = numblocks;
mtd->erasesize = sect_size;