patch-2.4.19 linux-2.4.19/drivers/mtd/mtdpart.c
Next file: linux-2.4.19/drivers/mtd/nand/nand_ecc.c
Previous file: linux-2.4.19/drivers/mtd/mtdcore.c
Back to the patch index
Back to the overall index
- Lines: 133
- Date:
Fri Aug 2 17:39:44 2002
- Orig file:
linux-2.4.18/drivers/mtd/mtdpart.c
- Orig date:
Thu Oct 4 15:14:59 2001
diff -urN linux-2.4.18/drivers/mtd/mtdpart.c linux-2.4.19/drivers/mtd/mtdpart.c
@@ -5,8 +5,12 @@
*
* This code is GPL
*
- * $Id: mtdpart.c,v 1.23 2001/10/02 15:05:11 dwmw2 Exp $
- */
+ * $Id: mtdpart.c,v 1.27 2002/03/08 16:34:35 rkaiser Exp $
+ * - with protection register access removed until that code is merged in 2.4.
+ *
+ * 02-21-2002 Thomas Gleixner <gleixner@autronix.de>
+ * added support for read_oob, write_oob
+ */
#include <linux/module.h>
#include <linux/types.h>
@@ -28,6 +32,7 @@
u_int32_t offset;
int index;
struct list_head list;
+ int registered;
};
/*
@@ -54,6 +59,18 @@
len, retlen, buf);
}
+static int part_read_oob (struct mtd_info *mtd, loff_t from, size_t len,
+ size_t *retlen, u_char *buf)
+{
+ struct mtd_part *part = PART(mtd);
+ if (from >= mtd->size)
+ len = 0;
+ else if (from + len > mtd->size)
+ len = mtd->size - from;
+ return part->master->read_oob (part->master, from + part->offset,
+ len, retlen, buf);
+}
+
static int part_write (struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf)
{
@@ -68,6 +85,20 @@
len, retlen, buf);
}
+static int part_write_oob (struct mtd_info *mtd, loff_t to, size_t len,
+ size_t *retlen, const u_char *buf)
+{
+ struct mtd_part *part = PART(mtd);
+ if (!(mtd->flags & MTD_WRITEABLE))
+ return -EROFS;
+ if (to >= mtd->size)
+ len = 0;
+ else if (to + len > mtd->size)
+ len = mtd->size - to;
+ return part->master->write_oob (part->master, to + part->offset,
+ len, retlen, buf);
+}
+
static int part_writev (struct mtd_info *mtd, const struct iovec *vecs,
unsigned long count, loff_t to, size_t *retlen)
{
@@ -148,7 +179,8 @@
if (slave->master == master) {
struct list_head *prev = node->prev;
__list_del(prev, node->next);
- del_mtd_device(&slave->mtd);
+ if(slave->registered)
+ del_mtd_device(&slave->mtd);
kfree(slave);
node = prev;
}
@@ -198,18 +230,21 @@
slave->mtd.name = parts[i].name;
slave->mtd.bank_size = master->bank_size;
-
slave->mtd.module = master->module;
slave->mtd.read = part_read;
slave->mtd.write = part_write;
+
+ if (master->read_oob)
+ slave->mtd.read_oob = part_read_oob;
+ if (master->write_oob)
+ slave->mtd.write_oob = part_write_oob;
if (master->sync)
slave->mtd.sync = part_sync;
if (!i && master->suspend && master->resume) {
slave->mtd.suspend = part_suspend;
slave->mtd.resume = part_resume;
}
-
if (master->writev)
slave->mtd.writev = part_writev;
if (master->readv)
@@ -225,6 +260,15 @@
if (slave->offset == MTDPART_OFS_APPEND)
slave->offset = cur_offset;
+ if (slave->offset == MTDPART_OFS_NXTBLK) {
+ u_int32_t emask = master->erasesize-1;
+ slave->offset = (cur_offset + emask) & ~emask;
+ if (slave->offset != cur_offset) {
+ printk(KERN_NOTICE "Moving partition %d: "
+ "0x%08x -> 0x%08x\n", i,
+ cur_offset, slave->offset);
+ }
+ }
if (slave->mtd.size == MTDPART_SIZ_FULL)
slave->mtd.size = master->size - slave->offset;
cur_offset = slave->offset + slave->mtd.size;
@@ -279,8 +323,17 @@
parts[i].name);
}
- /* register our partition */
- add_mtd_device(&slave->mtd);
+ if(parts[i].mtdp)
+ { /* store the object pointer (caller may or may not register it */
+ *parts[i].mtdp = &slave->mtd;
+ slave->registered = 0;
+ }
+ else
+ {
+ /* register our partition */
+ add_mtd_device(&slave->mtd);
+ slave->registered = 1;
+ }
}
return 0;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)