mtd/drivers/mtd/devices block2mtd.c,1.2,1.3

joern at infradead.org joern at infradead.org
Wed Dec 22 08:05:33 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:
Read-only devices are an inherintly stupid idea.  Get rid of them.



Index: block2mtd.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/devices/block2mtd.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- block2mtd.c	22 Dec 2004 13:05:02 -0000	1.2
+++ block2mtd.c	22 Dec 2004 13:05:31 -0000	1.3
@@ -62,7 +62,6 @@
 /* Module parameters passed by insmod/modprobe */
 char *device[MAX_DEVICES];    /* the block device to use */
 int erasesz[MAX_DEVICES];     /* optional default erase size */
-int ro[MAX_DEVICES];          /* optional read only flag */
 int sync;
 
 
@@ -73,8 +72,6 @@
 MODULE_PARM_DESC(device, "block device to use");
 MODULE_PARM(erasesz, "1-4i");
 MODULE_PARM_DESC(erasesz, "optional erase size to use in KiB. eg 4=4KiB.");
-MODULE_PARM(ro, "1-4i");
-MODULE_PARM_DESC(ro, "1=Read only, writes and erases cause errors");
 MODULE_PARM(sync, "i");
 MODULE_PARM_DESC(sync, "1=Synchronous writes");
 
@@ -445,7 +442,7 @@
 
 extern dev_t __init name_to_dev_t(const char *line);
 
-static struct blkmtd_dev *add_device(char *devname, int readonly, int erase_size)
+static struct blkmtd_dev *add_device(char *devname, int erase_size)
 {
 	struct block_device *bdev;
 	int mode;
@@ -458,10 +455,10 @@
 
 
 #ifdef MODULE
-	mode = (readonly) ? O_RDONLY : O_RDWR;
+	mode = O_RDWR;
 	bdev = open_bdev_excl(devname, mode, NULL);
 #else
-	mode = (readonly) ? FMODE_READ : FMODE_WRITE;
+	mode = FMODE_WRITE;
 	bdev = open_by_devnum(name_to_dev_t(devname), mode);
 #endif
 	if(IS_ERR(bdev)) {
@@ -488,9 +485,7 @@
 	memset(dev, 0, sizeof(struct blkmtd_dev));
 	dev->blkdev = bdev;
 	atomic_set(&(dev->blkdev->bd_inode->i_mapping->truncate_count), 0);
-	if(!readonly) {
-		init_MUTEX(&dev->wrbuf_mutex);
-	}
+	init_MUTEX(&dev->wrbuf_mutex);
 
 	dev->mtd_info.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
 
@@ -510,17 +505,12 @@
 	DEBUG(1, "blkmtd: init: found %d erase regions\n",
 	      dev->mtd_info.numeraseregions);
 
-	if(readonly) {
-		dev->mtd_info.type = MTD_ROM;
-		dev->mtd_info.flags = MTD_CAP_ROM;
-	} else {
-		dev->mtd_info.type = MTD_RAM;
-		dev->mtd_info.flags = MTD_CAP_RAM;
-		dev->mtd_info.erase = blkmtd_erase;
-		dev->mtd_info.write = blkmtd_write;
-		dev->mtd_info.writev = default_mtd_writev;
-		dev->mtd_info.sync = blkmtd_sync;
-	}
+	dev->mtd_info.type = MTD_RAM;
+	dev->mtd_info.flags = MTD_CAP_RAM;
+	dev->mtd_info.erase = blkmtd_erase;
+	dev->mtd_info.write = blkmtd_write;
+	dev->mtd_info.writev = default_mtd_writev;
+	dev->mtd_info.sync = blkmtd_sync;
 	dev->mtd_info.read = blkmtd_read;
 	dev->mtd_info.readv = default_mtd_readv;
 	dev->mtd_info.priv = dev;
@@ -532,10 +522,10 @@
 		list_del(&dev->list);
 		goto devinit_err;
 	} else {
-		info("mtd%d: [%s] erase_size = %dKiB %s [%ld]",
+		info("mtd%d: [%s] erase_size = %dKiB [%ld]",
 		     dev->mtd_info.index, dev->mtd_info.name + strlen("blkmtd: "),
 		     dev->mtd_info.erasesize >> 10,
-		     readonly ? "(read-only)" : "", PAGE_SIZE);
+		     PAGE_SIZE);
 	}
 	return dev;
 
@@ -595,20 +585,6 @@
 }
 
 
-static int __init param_blkmtd_ro(char *str)
-{
-	int i;
-	for(i = 0; i < MAX_DEVICES; i++) {
-		char *val = strsep(&str, ",");
-		if(val)
-			ro[i] = simple_strtoul(val, NULL, 0);
-		DEBUG(2, "blkmtd: ro setup: %d = %d\n", i, ro[i]);
-	}
-
-	return 1;
-}
-
-
 static int __init param_blkmtd_sync(char *str)
 {
 	if(str[0] == '1')
@@ -618,7 +594,6 @@
 
 __setup("blkmtd_device=", param_blkmtd_device);
 __setup("blkmtd_erasesz=", param_blkmtd_erasesz);
-__setup("blkmtd_ro=", param_blkmtd_ro);
 __setup("blkmtd_sync=", param_blkmtd_sync);
 
 #endif
@@ -637,7 +612,7 @@
 	}
 
 	for(i = 0; i < MAX_DEVICES; i++)
-		add_device(device[i], ro[i], erasesz[i] << 10);
+		add_device(device[i], erasesz[i] << 10);
 
 	if(list_empty(&blkmtd_device_list))
 		return -EINVAL;





More information about the linux-mtd-cvs mailing list