Skip to contentSkip to conversation

MTD: Change cfi-mtd to accept non-uniform sector sizes

PATCH New Stefan Roese 1 participant 1 message Mar 18, 2009 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MTD: Change cfi-mtd to accept non-uniform sector sizes

With this patch non-uniform NOR FLASH chips (chips with multiple erase regions) can be exported via the cfi-mtd layer and therefor used by UBI. We select the largest sector size as erasesize. The cfi driver will make sure that the smaller sectors are handled correctly.

---
 drivers/mtd/cfi_mtd.c |   18 ++++--------------
 1 files changed, 4 insertions(+), 14 deletions(-)
drivers/mtd/cfi_mtd.c +4 -14
index cf82d92..1000f1b 100644
@@ -141,22 +141,12 @@ static int cfi_mtd_set_erasesize(struct mtd_info *mtd, flash_info_t *fi)
 	int sect_size = 0;
 	int sect;
 
+	/*
+	 * Select the largest sector size as erasesize (e.g. for UBI)
+	 */
 	for (sect = 0; sect < fi->sector_count; sect++) {
-		if (!sect_size) {
+		if (flash_sector_size(fi, sect) > sect_size)
 			sect_size = flash_sector_size(fi, sect);
-			continue;
-		}
-
-		if (sect_size != flash_sector_size(fi, sect)) {
-			sect_size = 0;
-			break;
-		}
-	}
-
-	if (!sect_size) {
-		puts("cfi-mtd: devices with multiple sector sizes are"
-							"not supported\n");
-		return -EINVAL;
 	}
 
 	mtd->erasesize = sect_size;
Signature · 1 line
1.6.2.1