Skip to contentSkip to conversation

mtdoops: refactor loop

PATCH In review Brian Norris 3 participants 6 messages May 11, 2012 – May 15, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 mtdoops: refactor loop

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]

---
 drivers/mtd/mtdoops.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)
drivers/mtd/mtdoops.c +6 -8
index ae36d7e..6ba9507 100644
@@ -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);
 
Signature · 1 line
1.7.5.4.2.g519b1
#1 lore raw

PATCH 2/3 mtd: cafe_nand: spelling mistake

---
 drivers/mtd/nand/cafe_nand.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mtd/nand/cafe_nand.c +1 -1
index 41371ba..f3594a6 100644
@@ -377,7 +377,7 @@ static int cafe_nand_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
  * @buf:	buffer to store read data
  * @oob_required:	caller expects OOB data read to chip->oob_poi
  *
- * The hw generator calculates the error syndrome automatically. Therefor
+ * The hw generator calculates the error syndrome automatically. Therefore
  * we need a special oob layout and handling.
  */
 static int cafe_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip,
Signature · 1 line
1.7.5.4.2.g519b1
#2 lore raw

PATCH 3/3 mtd: nand: gpmi: [FIXME] need to use {read, write}_oob_raw

In reply to Brian Norris

This patch is simply an added warning in the comments. Ideally, this patch need not be merged, but rather, a developer will write a proper solution that can use the ecc.read_oob_raw and ecc.write_oob_raw interfaces.

---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +3 -0
index 8250f63..033bd7a 100644
@@ -1054,6 +1054,9 @@ exit_auxiliary:
  * ECC-based or raw view of the page is implicit in which function it calls
  * (there is a similar pair of ECC-based/raw functions for writing).
  *
+ * FIXME: The following paragraph is incorrect, now that there exist
+ * ecc.read_oob_raw and ecc.write_oob_raw functions.
+ *
  * Since MTD assumes the OOB is not covered by ECC, there is no pair of
  * ECC-based/raw functions for reading or or writing the OOB. The fact that the
  * caller wants an ECC-based or raw view of the page is not propagated down to
Signature · 1 line
1.7.5.4.2.g519b1
#3 lore raw

Re: [PATCH 3/3] mtd: nand: gpmi: [FIXME] need to use {read, write}_oob_raw

Hi Brian :

Quoted 15 lines

This patch is simply an added warning in the comments. Ideally, this patch need not be merged, but rather, a developer will write a proper solution that can use the ecc.read_oob_raw and ecc.write_oob_raw interfaces.

---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +0 -0
index 8250f63..033bd7a 100644

drivers/mtd/nand/gpmi-nand/gpmi-nand.c exit_auxiliary: · line 1058

Quoted 5 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +2 -0
@@ -1054,6 +1054,9 @@ exit_auxiliary:
  * ECC-based or raw view of the page is implicit in which function it calls
  * (there is a similar pair of ECC-based/raw functions for writing).
  *
+ * FIXME: The following paragraph is incorrect, now that there exist
+ * ecc.read_oob_raw and ecc.write_oob_raw functions.

I think you can just remove the following paragraph(it's out of date now).

Best Regards
Huang Shijie

Quoted 4 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +1 -0
+ *
  * Since MTD assumes the OOB is not covered by ECC, there is no pair of
  * ECC-based/raw functions for reading or or writing the OOB. The fact that the
  * caller wants an ECC-based or raw view of the page is not propagated down to
#4 lore raw

Re: [PATCH 3/3] mtd: nand: gpmi: [FIXME] need to use {read,write}_oob_raw

Quoted 11 lines · Huang Shijie

Hi Brian :

Quoted 10 lines

This patch is simply an added warning in the comments. Ideally, this patch need not be merged, but rather, a developer will write a proper solution that can use the ecc.read_oob_raw and ecc.write_oob_raw interfaces.

---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Quoted 11 lines

drivers/mtd/nand/gpmi-nand/gpmi-nand.c exit_auxiliary: · line 1058

Quoted 10 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +2 -0
index 8250f63..033bd7a 100644
@@ -1054,6 +1054,9 @@ exit_auxiliary:
  * ECC-based or raw view of the page is implicit in which function it calls
  * (there is a similar pair of ECC-based/raw functions for writing).
  *
+ * FIXME: The following paragraph is incorrect, now that there exist
+ * ecc.read_oob_raw and ecc.write_oob_raw functions.

I think you can just remove the following paragraph(it's out of date now).

I've pushed Brian's patch to l2-mtd.git - it is OK in this form and I think it is better if someone who takes care of gpmi fixes-up the comments properly instead.

Signature · 2 lines
Best Regards,
Artem Bityutskiy