All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: Brian Norris <computersforpeace@gmail.com>,
	linux-mtd@lists.infradead.org
Subject: [PATCH 1/3] mtdoops: refactor loop
Date: Fri, 11 May 2012 13:30:33 -0700	[thread overview]
Message-ID: <1336768235-12658-1-git-send-email-computersforpeace@gmail.com> (raw)

We can clean up the loop logic a bit, here. This refactoring was enabled
in part by:

 Commit bb4a09866 [mtdoops: clean-up new MTD API usage]

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/mtdoops.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
index ae36d7e..6ba9507 100644
--- a/drivers/mtd/mtdoops.c
+++ b/drivers/mtd/mtdoops.c
@@ -169,14 +169,7 @@ static void mtdoops_workfunc_erase(struct work_struct *work)
 			cxt->nextpage = 0;
 	}
 
-	while (1) {
-		ret = mtd_block_isbad(mtd, cxt->nextpage * record_size);
-		if (!ret)
-			break;
-		if (ret < 0) {
-			printk(KERN_ERR "mtdoops: block_isbad failed, aborting\n");
-			return;
-		}
+	while ((ret = mtd_block_isbad(mtd, cxt->nextpage * record_size)) > 0) {
 badblock:
 		printk(KERN_WARNING "mtdoops: bad block at %08lx\n",
 		       cxt->nextpage * record_size);
@@ -190,6 +183,11 @@ badblock:
 		}
 	}
 
+	if (ret < 0) {
+		printk(KERN_ERR "mtdoops: mtd_block_isbad failed, aborting\n");
+		return;
+	}
+
 	for (j = 0, ret = -1; (j < 3) && (ret < 0); j++)
 		ret = mtdoops_erase_block(cxt, cxt->nextpage * record_size);
 
-- 
1.7.5.4.2.g519b1

             reply	other threads:[~2012-05-11 20:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-11 20:30 Brian Norris [this message]
2012-05-11 20:30 ` [PATCH 2/3] mtd: cafe_nand: spelling mistake Brian Norris
2012-05-11 20:30 ` [PATCH 3/3] mtd: nand: gpmi: [FIXME] need to use {read, write}_oob_raw Brian Norris
2012-05-14  2:48   ` Huang Shijie
2012-05-15  7:59     ` [PATCH 3/3] mtd: nand: gpmi: [FIXME] need to use {read,write}_oob_raw Artem Bityutskiy
2012-05-15  7:58 ` [PATCH 1/3] mtdoops: refactor loop Artem Bityutskiy

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=1336768235-12658-1-git-send-email-computersforpeace@gmail.com \
    --to=computersforpeace@gmail.com \
    --cc=dedekind1@gmail.com \
    --cc=linux-mtd@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.