mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 4/8] mtd: erase_info may be modified in mtd_erase
Date: Thu, 13 Feb 2014 11:25:31 +0100	[thread overview]
Message-ID: <1392287135-445-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1392287135-445-1-git-send-email-s.hauer@pengutronix.de>

erase_info may be modified by the mtd partition code, so
set the address each time we call mtd_erase.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/core.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 6db1c6d..e4def2a 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -146,6 +146,7 @@ static int mtd_op_erase(struct cdev *cdev, size_t count, loff_t offset)
 {
 	struct mtd_info *mtd = cdev->priv;
 	struct erase_info erase;
+	uint32_t addr;
 	int ret;
 
 	ret = mtd_erase_align(mtd, &count, &offset);
@@ -154,7 +155,7 @@ static int mtd_op_erase(struct cdev *cdev, size_t count, loff_t offset)
 
 	memset(&erase, 0, sizeof(erase));
 	erase.mtd = mtd;
-	erase.addr = offset;
+	addr = offset;
 
 	if (!mtd->block_isbad) {
 		erase.len = count;
@@ -164,22 +165,24 @@ static int mtd_op_erase(struct cdev *cdev, size_t count, loff_t offset)
 	erase.len = mtd->erasesize;
 
 	while (count > 0) {
-		dev_dbg(cdev->dev, "erase %d %d\n", erase.addr, erase.len);
+		dev_dbg(cdev->dev, "erase %d %d\n", addr, erase.len);
 
 		if (!mtd->allow_erasebad)
-			ret = mtd_block_isbad(mtd, erase.addr);
+			ret = mtd_block_isbad(mtd, addr);
 		else
 			ret = 0;
 
+		erase.addr = addr;
+
 		if (ret > 0) {
-			printf("Skipping bad block at 0x%08x\n", erase.addr);
+			printf("Skipping bad block at 0x%08x\n", addr);
 		} else {
 			ret = mtd_erase(mtd, &erase);
 			if (ret)
 				return ret;
 		}
 
-		erase.addr += mtd->erasesize;
+		addr += mtd->erasesize;
 		count -= count > mtd->erasesize ? mtd->erasesize : count;
 	}
 
-- 
1.8.5.3


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

  parent reply	other threads:[~2014-02-13 10:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-13 10:25 [PATCH 1/8] mtd: Simplify partitions Sascha Hauer
2014-02-13 10:25 ` [PATCH 2/8] device: init bus list Sascha Hauer
2014-02-13 10:25 ` [PATCH 3/8] device: remove parameters when unregistering a device Sascha Hauer
2014-02-13 10:25 ` Sascha Hauer [this message]
2014-02-13 10:25 ` [PATCH 5/8] mtd: Only call of_parse_partitions when the mtd has a parent Sascha Hauer
2014-02-13 10:25 ` [PATCH 6/8] mtd: partition: only copy selected fields to partition Sascha Hauer
2014-02-13 10:25 ` [PATCH 7/8] mtd: register mtd partitions as real mtd devices Sascha Hauer
2014-02-13 10:25 ` [PATCH 8/8] ubi: register ubi devices and volumes as devices Sascha Hauer
2014-02-13 11:08 ` [PATCH 1/8] mtd: Simplify partitions Alexander Aring
2014-02-13 13:34   ` Sascha Hauer
2014-02-13 14:01     ` Alexander Aring
2014-02-13 18:45       ` Sascha Hauer
2014-02-13 19:05         ` Alexander Aring

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=1392287135-445-4-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --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