mtd/drivers/mtd mtd_blkdevs.c,1.6,1.7
David Woodhouse
dwmw2 at infradead.org
Sun May 18 15:09:05 EDT 2003
Update of /home/cvs/mtd/drivers/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv8296
Modified Files:
mtd_blkdevs.c
Log Message:
fix blocksize
Index: mtd_blkdevs.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/mtd_blkdevs.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- mtd_blkdevs.c 18 May 2003 18:21:44 -0000 1.6
+++ mtd_blkdevs.c 18 May 2003 19:09:02 -0000 1.7
@@ -3,7 +3,7 @@
*
* (C) 2003 David Woodhouse <dwmw2 at infradead.org>
*
- * Interface to Linux block layer for MTD 'translation layers'.
+ * Interface to Linux 2.4 block layer for MTD 'translation layers'.
*
*/
@@ -19,9 +19,9 @@
#include <linux/blkpg.h>
#include <linux/spinlock.h>
#include <asm/semaphore.h>
-#include <linux/mtd/compatmac.h>
static LIST_HEAD(blktrans_majors);
+
extern struct semaphore mtd_table_mutex;
extern struct mtd_info *mtd_table[];
@@ -168,6 +168,9 @@
int devnum;
int ret = -ENODEV;
+ if (is_read_only(i->i_rdev) && (f->f_mode & FMODE_WRITE))
+ return -EROFS;
+
down(&mtd_table_mutex);
tr = get_tr(major_nr);
@@ -354,6 +357,7 @@
struct mtd_blktrans_ops *tr = new->tr;
struct list_head *this;
int last_devnum = -1;
+ int i;
if (!down_trylock(&mtd_table_mutex)) {
up(&mtd_table_mutex);
@@ -396,9 +400,23 @@
added:
spin_unlock(&tr->blkcore_priv->devs_lock);
new->usecount = 0;
+
+ if (!tr->writesect)
+ new->readonly = 1;
+
+ for (i = new->devnum << tr->part_bits;
+ i < (new->devnum+1) << tr->part_bits;
+ i++) {
+ set_device_ro(MKDEV(tr->major, i), new->readonly);
+ tr->blkcore_priv->blksizes[i] = new->blksize;
+ tr->blkcore_priv->sizes[i] = 0;
+ tr->blkcore_priv->part_table[i].nr_sects = 0;
+ tr->blkcore_priv->part_table[i].start_sect = 0;
+ }
+
tr->blkcore_priv->sizes[new->devnum << tr->part_bits] = new->size;
- tr->blkcore_priv->gd.nr_real++;
tr->blkcore_priv->part_table[new->devnum << tr->part_bits].nr_sects = new->size;
+ tr->blkcore_priv->gd.nr_real++;
if (tr->part_bits) {
grok_partitions(&tr->blkcore_priv->gd, new->devnum,
@@ -423,14 +441,14 @@
spin_lock(&tr->blkcore_priv->devs_lock);
list_del(&old->list);
spin_unlock(&tr->blkcore_priv->devs_lock);
- tr->blkcore_priv->gd.nr_real--;
- tr->blkcore_priv->sizes[old->devnum << tr->part_bits] = 0;
for (i = (old->devnum << tr->part_bits);
i < ((old->devnum+1) << tr->part_bits); i++) {
+ tr->blkcore_priv->sizes[i] = 0;
tr->blkcore_priv->part_table[i].nr_sects = 0;
tr->blkcore_priv->part_table[i].start_sect = 0;
}
+ tr->blkcore_priv->gd.nr_real--;
return 0;
}
@@ -567,4 +585,4 @@
MODULE_AUTHOR("David Woodhouse <dwmw2 at infradead.org>");
MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("Interface to block layer for MTD 'translation layers'");
+MODULE_DESCRIPTION("Common interface to block layer for MTD 'translation layers'");
More information about the linux-mtd-cvs
mailing list