summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerve Codina <Herve.CODINA@celad.com>2014-06-09 17:14:08 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-06-10 08:39:08 +0200
commit9c741047ae8dbc404aba049f0f63b89fbd9a5862 (patch)
treec71b22e099f9c6ebac218a9c3828f0fd4dd5ef3f
parent0860be223af664ec2417577f6f4f55727f899b16 (diff)
downloadbarebox-9c741047ae8dbc404aba049f0f63b89fbd9a5862.tar.gz
mtd: fix mtd erasesize
Set mtd erasize using max erasesize from erase regions Signed-off-by: Herve Codina <Herve.CODINA@celad.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/mtd/nor/cfi_flash.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/mtd/nor/cfi_flash.c b/drivers/mtd/nor/cfi_flash.c
index 3d3d231..a8118cb 100644
--- a/drivers/mtd/nor/cfi_flash.c
+++ b/drivers/mtd/nor/cfi_flash.c
@@ -949,6 +949,8 @@ static int cfi_mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
static void cfi_init_mtd(struct flash_info *info)
{
struct mtd_info *mtd = &info->mtd;
+ u_int32_t erasesize;
+ int i;
mtd->read = cfi_mtd_read;
mtd->write = cfi_mtd_write;
@@ -956,7 +958,14 @@ static void cfi_init_mtd(struct flash_info *info)
mtd->lock = cfi_mtd_lock;
mtd->unlock = cfi_mtd_unlock;
mtd->size = info->size;
- mtd->erasesize = info->eraseregions[1].erasesize; /* FIXME */
+
+ erasesize = 0;
+ for (i=0; i < info->numeraseregions; i++) {
+ if (erasesize < info->eraseregions[i].erasesize)
+ erasesize = info->eraseregions[i].erasesize;
+ }
+ mtd->erasesize = erasesize;
+
mtd->writesize = 1;
mtd->subpage_sft = 0;
mtd->eraseregions = info->eraseregions;