patch-2.4.19 linux-2.4.19/drivers/mtd/mtdblock.c
Next file: linux-2.4.19/drivers/mtd/mtdblock_ro.c
Previous file: linux-2.4.19/drivers/mtd/maps/tsunami_flash.c
Back to the patch index
Back to the overall index
- Lines: 93
- Date:
Fri Aug 2 17:39:44 2002
- Orig file:
linux-2.4.18/drivers/mtd/mtdblock.c
- Orig date:
Thu Oct 25 13:58:35 2001
diff -urN linux-2.4.18/drivers/mtd/mtdblock.c linux-2.4.19/drivers/mtd/mtdblock.c
@@ -1,7 +1,7 @@
/*
* Direct MTD block device access
*
- * $Id: mtdblock.c,v 1.47 2001/10/02 15:05:11 dwmw2 Exp $
+ * $Id: mtdblock.c,v 1.51 2001/11/20 11:42:33 dwmw2 Exp $
*
* 02-nov-2000 Nicolas Pitre Added read-modify-write with cache
*/
@@ -60,6 +60,13 @@
static int mtd_sizes[MAX_MTD_DEVICES];
static int mtd_blksizes[MAX_MTD_DEVICES];
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,14)
+#define BLK_INC_USE_COUNT MOD_INC_USE_COUNT
+#define BLK_DEC_USE_COUNT MOD_DEC_USE_COUNT
+#else
+#define BLK_INC_USE_COUNT do {} while(0)
+#define BLK_DEC_USE_COUNT do {} while(0)
+#endif
/*
* Cache stuff...
@@ -287,11 +294,14 @@
if (dev >= MAX_MTD_DEVICES)
return -EINVAL;
+ BLK_INC_USE_COUNT;
+
mtd = get_mtd_device(NULL, dev);
if (!mtd)
return -ENODEV;
if (MTD_ABSENT == mtd->type) {
put_mtd_device(mtd);
+ BLK_DEC_USE_COUNT;
return -ENODEV;
}
@@ -314,6 +324,7 @@
mtdblk = kmalloc(sizeof(struct mtdblk_dev), GFP_KERNEL);
if (!mtdblk) {
put_mtd_device(mtd);
+ BLK_DEC_USE_COUNT;
return -ENOMEM;
}
memset(mtdblk, 0, sizeof(*mtdblk));
@@ -329,6 +340,7 @@
if (!mtdblk->cache_data) {
put_mtd_device(mtdblk->mtd);
kfree(mtdblk);
+ BLK_DEC_USE_COUNT;
return -ENOMEM;
}
}
@@ -371,8 +383,6 @@
if (inode == NULL)
release_return(-ENODEV);
- invalidate_device(inode->i_rdev, 1);
-
dev = MINOR(inode->i_rdev);
mtdblk = mtdblks[dev];
@@ -396,6 +406,7 @@
DEBUG(MTD_DEBUG_LEVEL1, "ok\n");
+ BLK_DEC_USE_COUNT;
release_return(0);
}
@@ -535,8 +546,11 @@
switch (cmd) {
case BLKGETSIZE: /* Return device size */
return put_user((mtdblk->mtd->size >> 9), (unsigned long *) arg);
+
+#ifdef BLKGETSIZE64
case BLKGETSIZE64:
return put_user((u64)mtdblk->mtd->size, (u64 *)arg);
+#endif
case BLKFLSBUF:
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
@@ -569,7 +583,9 @@
#else
static struct block_device_operations mtd_fops =
{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,14)
owner: THIS_MODULE,
+#endif
open: mtdblock_open,
release: mtdblock_release,
ioctl: mtdblock_ioctl
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)