mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Herve Codina <Herve.CODINA@celad.com>
To: barebox@lists.infradead.org
Cc: Herve Codina <Herve.CODINA@celad.com>
Subject: [PATCH 2/2] mtd: fix mtd erasesize
Date: Mon, 9 Jun 2014 17:14:08 +0200	[thread overview]
Message-ID: <1402326848-16239-2-git-send-email-Herve.CODINA@celad.com> (raw)
In-Reply-To: <1402326848-16239-1-git-send-email-Herve.CODINA@celad.com>

Set mtd erasize using max erasesize from erase regions

Signed-off-by: Herve Codina <Herve.CODINA@celad.com>
---
 drivers/mtd/nor/cfi_flash.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nor/cfi_flash.c b/drivers/mtd/nor/cfi_flash.c
index 3d3d231..a56183d 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;
-- 
1.7.9.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2014-06-09 15:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-09 15:14 [PATCH 1/2] mtd: Fix writesize parameter value Herve Codina
2014-06-09 15:14 ` Herve Codina [this message]
2014-06-10  6:39 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1402326848-16239-2-git-send-email-Herve.CODINA@celad.com \
    --to=herve.codina@celad.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox