mtd/drivers/mtd/devices block2mtd.c,1.12,1.13

joern at infradead.org joern at infradead.org
Wed Dec 22 08:10:50 EST 2004


Update of /home/cvs/mtd/drivers/mtd/devices
In directory phoenix.infradead.org:/home/joern/mtd/drivers/mtd/devices

Modified Files:
	block2mtd.c 
Log Message:
I see absolutely no reason for complicated erase reagions.  On the 
user side, everyone but mtdchar effectively ignores it anyway.



Index: block2mtd.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/devices/block2mtd.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- block2mtd.c	22 Dec 2004 13:10:22 -0000	1.12
+++ block2mtd.c	22 Dec 2004 13:10:47 -0000	1.13
@@ -361,65 +361,6 @@
 }
 
 
-/* For a given size and initial erase size, calculate the number
- * and size of each erase region. Goes round the loop twice,
- * once to find out how many regions, then allocates space,
- * then round the loop again to fill it in.
- */
-static struct mtd_erase_region_info *calc_erase_regions(
-	size_t erase_size, size_t total_size, int *regions)
-{
-	struct mtd_erase_region_info *info = NULL;
-
-	/* Make any user specified erasesize be a power of 2
-	   and at least PAGE_SIZE */
-	if (erase_size) {
-		int es = erase_size;
-		erase_size = 1;
-		while (es != 1) {
-			es >>= 1;
-			erase_size <<= 1;
-		}
-		if (erase_size < PAGE_SIZE)
-			erase_size = PAGE_SIZE;
-	} else {
-		erase_size = CONFIG_MTD_BLKDEV_ERASESIZE;
-	}
-
-	*regions = 0;
-
-	do {
-		int tot_size = total_size;
-		int er_size = erase_size;
-		int count = 0, offset = 0, regcnt = 0;
-
-		while (tot_size) {
-			count = tot_size / er_size;
-			if (count) {
-				tot_size = tot_size % er_size;
-				if (info) {
-					(info + regcnt)->offset = offset;
-					(info + regcnt)->erasesize = er_size;
-					(info + regcnt)->numblocks = count;
-					(*regions)++;
-				}
-				regcnt++;
-				offset += (count * er_size);
-			}
-			while (er_size > tot_size)
-				er_size >>= 1;
-		}
-		if (info == NULL) {
-			info = kmalloc(regcnt * sizeof(struct mtd_erase_region_info), GFP_KERNEL);
-			if (!info)
-				break;
-		}
-	} while (!(*regions));
-
-	return info;
-}
-
-
 extern dev_t __init name_to_dev_t(const char *line);
 
 static struct blkmtd_dev *add_device(char *devname, int erase_size)
@@ -471,11 +412,8 @@
 		goto devinit_err;
 
 	sprintf(dev->mtd_info.name, "blkmtd: %s", devname);
-	dev->mtd_info.eraseregions = calc_erase_regions(erase_size, dev->mtd_info.size, &dev->mtd_info.numeraseregions);
-	if (dev->mtd_info.eraseregions == NULL)
-		goto devinit_err;
 
-	dev->mtd_info.erasesize = dev->mtd_info.eraseregions->erasesize;
+	dev->mtd_info.erasesize = erase_size;
 	dev->mtd_info.type = MTD_RAM;
 	dev->mtd_info.flags = MTD_CAP_RAM;
 	dev->mtd_info.erase = blkmtd_erase;





More information about the linux-mtd-cvs mailing list