Skip to contentSkip to conversation

mtd: Remove unneeded call to check_free_sectors in the function, INFTL_formatblock

PATCH New Nicholas Krause 1 participant 2 messages Jan 16, 2015 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mtd: Remove unneeded call to check_free_sectors in the function, INFTL_formatblock

Removes unneeded call to check_free_sectors internally in the function,INFTL_formatblock. This call is no longer needed due to us checking to see if erasing the block against the structure pointer passed to the function,inftl internal variable state is equal to the macro,MTD_ERASE_FAILED to see if the block has failed in being erased successfully.Due to this we can remove the no longer needed check to check_free_sectors and comments related to questioning the reason for it's use with the check against MTD_ERASE_FAILED for inftl's state variable already checking for successfully erasing of the mtd block.

---
 drivers/mtd/inftlmount.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/mtd/inftlmount.c +1 -11
index 1388c8d..f5808ad 100644
@@ -362,12 +362,9 @@ static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address,
 
 /*
  * INFTL_format: format a Erase Unit by erasing ALL Erase Zones in the Erase
- *		 Unit and Update INFTL metadata. Each erase operation is
- *		 checked with check_free_sectors.
- *
+ *		 Unit and Update INFTL metadata. *
  * Return: 0 when succeed, -1 on error.
  *
- * ToDo: 1. Is it necessary to check_free_sector after erasing ??
  */
 int INFTL_formatblock(struct INFTLrecord *inftl, int block)
 {
@@ -401,13 +398,6 @@ int INFTL_formatblock(struct INFTLrecord *inftl, int block)
 			goto fail;
 		}
 
-		/*
-		 * Check the "freeness" of Erase Unit before updating metadata.
-		 * FixMe: is this check really necessary? Since we have check
-		 * the return code after the erase operation.
-		 */
-		if (check_free_sectors(inftl, instr->addr, instr->len, 1) != 0)
-			goto fail;
 	}
 
 	uci.EraseMark = cpu_to_le16(ERASE_MARK);
Signature · 1 line
2.1.0
#1 lore raw

PATCH 2/2 mtd: Remove the no longer need functions, check_free_sectors and memcmpb

The functions,check_free_sectors and memcmpb are no longer needed due to removing the only caller for both functions in check_free_sectors for memcmpb and in INFTL_formatblock for check_free_sectors respectfully.

---
 drivers/mtd/inftlmount.c | 40 ----------------------------------------
 1 file changed, 40 deletions(-)
drivers/mtd/inftlmount.c +0 -40
index f5808ad..d0a7b7c 100644
@@ -319,46 +319,6 @@ static int find_boot_record(struct INFTLrecord *inftl)
 	return -1;
 }
 
-static int memcmpb(void *a, int c, int n)
-{
-	int i;
-	for (i = 0; i < n; i++) {
-		if (c != ((unsigned char *)a)[i])
-			return 1;
-	}
-	return 0;
-}
-
-/*
- * check_free_sector: check if a free sector is actually FREE,
- *	i.e. All 0xff in data and oob area.
- */
-static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address,
-	int len, int check_oob)
-{
-	u8 buf[SECTORSIZE + inftl->mbd.mtd->oobsize];
-	struct mtd_info *mtd = inftl->mbd.mtd;
-	size_t retlen;
-	int i;
-
-	for (i = 0; i < len; i += SECTORSIZE) {
-		if (mtd_read(mtd, address, SECTORSIZE, &retlen, buf))
-			return -1;
-		if (memcmpb(buf, 0xff, SECTORSIZE) != 0)
-			return -1;
-
-		if (check_oob) {
-			if(inftl_read_oob(mtd, address, mtd->oobsize,
-					  &retlen, &buf[SECTORSIZE]) < 0)
-				return -1;
-			if (memcmpb(buf + SECTORSIZE, 0xff, mtd->oobsize) != 0)
-				return -1;
-		}
-		address += SECTORSIZE;
-	}
-
-	return 0;
-}
 
 /*
  * INFTL_format: format a Erase Unit by erasing ALL Erase Zones in the Erase
Signature · 1 line
2.1.0