mtd/drivers/mtd/devices block2mtd.c,1.10,1.11

joern at infradead.org joern at infradead.org
Wed Dec 22 08:09:59 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:
kfree(NULL) works just fine, which allows for much simpler code.



Index: block2mtd.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/devices/block2mtd.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- block2mtd.c	22 Dec 2004 13:09:19 -0000	1.10
+++ block2mtd.c	22 Dec 2004 13:09:57 -0000	1.11
@@ -342,20 +342,20 @@
 	return;
 }
 
-static void free_device(struct blkmtd_dev *dev)
+static void blockmtd_free_device(struct blkmtd_dev *dev)
 {
-	if (dev) {
-		if (dev->mtd_info.eraseregions)
-			kfree(dev->mtd_info.eraseregions);
-		if (dev->mtd_info.name)
-			kfree(dev->mtd_info.name);
-
-		if (dev->blkdev) {
-			invalidate_inode_pages(dev->blkdev->bd_inode->i_mapping);
-			close_bdev_excl(dev->blkdev);
-		}
-		kfree(dev);
+	if (!dev)
+		return;
+
+	kfree(dev->mtd_info.eraseregions);
+	kfree(dev->mtd_info.name);
+
+	if (dev->blkdev) {
+		invalidate_inode_pages(dev->blkdev->bd_inode->i_mapping);
+		close_bdev_excl(dev->blkdev);
 	}
+
+	kfree(dev);
 }
 
 
@@ -496,7 +496,7 @@
 	return dev;
 
 devinit_err:
-	free_device(dev);
+	blockmtd_free_device(dev);
 	return NULL;
 }
 
@@ -629,7 +629,7 @@
 		INFO("mtd%d: [%s] removed", dev->mtd_info.index,
 				dev->mtd_info.name + strlen("blkmtd: "));
 		list_del(&dev->list);
-		free_device(dev);
+		blockmtd_free_device(dev);
 	}
 }
 





More information about the linux-mtd-cvs mailing list