diff -urN mtd-cvs-040314/drivers/mtd/devices/blkmtd.c mtd/drivers/mtd/devices/blkmtd.c
--- mtd-cvs-040314/drivers/mtd/devices/blkmtd.c 2004-03-24 14:49:22.000000000 +0100
+++ mtd/drivers/mtd/devices/blkmtd.c 2006-01-02 18:33:26.000000000 +0100
@@ -73,6 +73,7 @@
/* Module parameters passed by insmod/modprobe */
char *device[MAX_DEVICES]; /* the block device to use */
+char *label[MAX_DEVICES]; /* the block device label to use */
int erasesz[MAX_DEVICES]; /* optional default erase size */
int ro[MAX_DEVICES]; /* optional read only flag */
int sync;
@@ -83,6 +84,8 @@
MODULE_DESCRIPTION("Emulate an MTD using a block device");
MODULE_PARM(device, "1-4s");
MODULE_PARM_DESC(device, "block device to use");
+MODULE_PARM(label, "1-4s");
+MODULE_PARM_DESC(label, "block device label 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");
@@ -142,6 +145,15 @@
for(cnt = 0; cnt < pages; cnt++) {
page = grab_cache_page(dev->binding->bd_inode->i_mapping, pagenrs[cnt]);
+ if (page == NULL) {
+ warn("read: cant grab cache page %d (%d)", pagenrs[cnt], cnt);
+ while (cnt--) {
+ unlock_page(pagelst[cnt]);
+ page_cache_release(pagelst[cnt]);
+ }
+ err = -ENOMEM;
+ break;
+ }
pagelst[cnt] = page;
if(!Page_Uptodate(page)) {
iobuf->blocks[iobuf->nr_pages] = pagenrs[cnt];
@@ -149,7 +161,7 @@
}
}
- if(iobuf->nr_pages) {
+ if ((!err) && (iobuf->nr_pages)) {
iobuf->length = iobuf->nr_pages << PAGE_SHIFT;
err = brw_kiovec(READ, 1, &iobuf, kdev, iobuf->blocks, PAGE_SIZE);
DEBUG(3, "blkmtd: read_pages: finished, err = %d\n", err);
@@ -343,14 +355,14 @@
/* see if page is in the page cache */
DEBUG(3, "blkmtd: write: grabbing page %d from page cache\n", pagenr);
page = grab_cache_page(dev->binding->bd_inode->i_mapping, pagenr);
- if(PageDirty(page) && pagenr != ignorepage) {
- BUG();
- }
if(!page) {
warn("write: cant grab cache page %d", pagenr);
err = -ENOMEM;
goto write_err;
}
+ if(PageDirty(page) && pagenr != ignorepage) {
+ BUG();
+ }
if(!buf) {
memset(page_address(page), 0xff, PAGE_SIZE);
} else {
@@ -777,7 +789,7 @@
extern kdev_t name_to_kdev_t(char *line) __init;
-static struct blkmtd_dev *add_device(char *devname, int readonly, int erase_size)
+static struct blkmtd_dev *add_device(char *devname, int readonly, int erase_size, char *lbl)
{
int maj, min;
kdev_t kdev;
@@ -884,11 +896,18 @@
/* Setup the MTD structure */
/* make the name contain the block device in */
- dev->mtd_info.name = kmalloc(sizeof("blkmtd: ") + strlen(devname), GFP_KERNEL);
- if(dev->mtd_info.name == NULL)
- goto devinit_err;
-
- sprintf(dev->mtd_info.name, "blkmtd: %s", devname);
+ if (lbl) {
+ dev->mtd_info.name = kmalloc(strlen(devname)+strlen(lbl)+1, GFP_KERNEL);
+ if(dev->mtd_info.name == NULL)
+ goto devinit_err;
+ sprintf(dev->mtd_info.name, "%s:%s", devname, lbl);
+ }
+ else {
+ dev->mtd_info.name = kmalloc(sizeof("blkmtd: ") + strlen(devname), GFP_KERNEL);
+ if(dev->mtd_info.name == NULL)
+ goto devinit_err;
+ sprintf(dev->mtd_info.name, "blkmtd: %s", devname);
+ }
dev->mtd_info.eraseregions = calc_erase_regions(erase_size, dev->mtd_info.size,
&dev->mtd_info.numeraseregions);
if(dev->mtd_info.eraseregions == NULL)
@@ -971,6 +990,18 @@
return 1;
}
+static int __init param_blkmtd_label(char *str)
+{
+ int i;
+
+ for(i = 0; i < MAX_DEVICES; i++) {
+ label[i] = str;
+ DEBUG(2, "blkmtd: device label setup: %d = %s\n", i, label[i]);
+ strsep(&str, ",");
+ }
+ return 1;
+}
+
static int __init param_blkmtd_erasesz(char *str)
{
@@ -1027,7 +1058,7 @@
}
for(i = 0; i < MAX_DEVICES; i++)
- add_device(device[i], ro[i], erasesz[i] << 10);
+ add_device(device[i], ro[i], erasesz[i] << 10, label[i]);
if(list_empty(&blkmtd_device_list))
goto init_err;
diff -urN mtd-cvs-040314/drivers/mtd/mtdchar.c mtd/drivers/mtd/mtdchar.c
--- mtd-cvs-040314/drivers/mtd/mtdchar.c 2004-03-24 14:49:22.000000000 +0100
+++ mtd/drivers/mtd/mtdchar.c 2004-09-10 13:58:10.000000000 +0200
@@ -128,11 +128,15 @@
int ret=0;
int len;
char *kbuf;
+ loff_t pos = *ppos;
DEBUG(MTD_DEBUG_LEVEL0,"MTD_read\n");
- if (*ppos + count > mtd->size)
- count = mtd->size - *ppos;
+ if (pos < 0 || pos > mtd->size)
+ return 0;
+
+ if (count > mtd->size - pos)
+ count = mtd->size - pos;
if (!count)
return 0;
@@ -149,9 +153,9 @@
if (!kbuf)
return -ENOMEM;
- ret = MTD_READ(mtd, *ppos, len, &retlen, kbuf);
+ ret = MTD_READ(mtd, pos, len, &retlen, kbuf);
if (!ret) {
- *ppos += retlen;
+ pos += retlen;
if (copy_to_user(buf, kbuf, retlen)) {
kfree(kbuf);
return -EFAULT;
@@ -170,6 +174,8 @@
kfree(kbuf);
}
+ *ppos = pos;
+
return total_retlen;
} /* mtd_read */
@@ -179,17 +185,18 @@
char *kbuf;
size_t retlen;
size_t total_retlen=0;
+ loff_t pos = *ppos;
int ret=0;
int len;
DEBUG(MTD_DEBUG_LEVEL0,"MTD_write\n");
- if (*ppos == mtd->size)
+ if (pos < 0 || pos >= mtd->size)
return -ENOSPC;
-
- if (*ppos + count > mtd->size)
- count = mtd->size - *ppos;
+ if (count > mtd->size - pos)
+ count = mtd->size - pos;
+
if (!count)
return 0;
@@ -210,9 +217,9 @@
return -EFAULT;
}
- ret = (*(mtd->write))(mtd, *ppos, len, &retlen, kbuf);
+ ret = (*(mtd->write))(mtd, pos, len, &retlen, kbuf);
if (!ret) {
- *ppos += retlen;
+ pos += retlen;
total_retlen += retlen;
count -= retlen;
buf += retlen;
@@ -224,6 +231,7 @@
kfree(kbuf);
}
+ *ppos = pos;
return total_retlen;
} /* mtd_write */
diff -urN mtd-cvs-040314/fs/jffs2/compr_rtime.c mtd/fs/jffs2/compr_rtime.c
--- mtd-cvs-040314/fs/jffs2/compr_rtime.c 2004-03-24 14:49:22.000000000 +0100
+++ mtd/fs/jffs2/compr_rtime.c 2007-03-19 15:14:59.000000000 +0100
@@ -21,6 +21,9 @@
*
*/
+#ifndef __KERNEL__
+#include
There are only a few lines neccecary to access up to 256 MB of Flashmemory.
+There are only a few lines neccecary to access up to 256 MB of Flashmemory.
| Pin(s) | Function |
| I/O 0-7 | Data Inputs/Outputs |
| /WP | Write Protect |
| /SE | Spare area Enable |
| R/B | Ready / Busy Output |
As it is neccecary to use the spare area, the /SE (Spare area Enable) pin should be tied to GND. /CE, CLE and ALE should be GPIO pins or latched signals. It's possible to use address lines for ALE and CLE, but you have to take care about the timing -restrictions of the chip !
+restrictions of the chip !/RE and /WE can be tied to the corresponding lines of the CPU. Make sure, that
they are logicaly combined with the corresponding chipselect. You can also use two
different chipselects for /RE and /WE, but be aware of data hold time constraints
diff -urN mtd-cvs-040314/include/linux/jffs2_fs_i.h mtd/include/linux/jffs2_fs_i.h
--- mtd-cvs-040314/include/linux/jffs2_fs_i.h 2004-03-24 14:49:22.000000000 +0100
+++ mtd/include/linux/jffs2_fs_i.h 2004-04-30 15:41:50.000000000 +0200
@@ -37,7 +37,7 @@
uint16_t flags;
uint8_t usercompr;
#if !defined (__ECOS)
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,2)
+#if LINUX_VERSION_CODE > 0x020502
struct inode vfs_inode;
#endif
#endif
diff -urN mtd-cvs-040314/include/linux/rbtree.h mtd/include/linux/rbtree.h
--- mtd-cvs-040314/include/linux/rbtree.h 2004-03-24 14:49:22.000000000 +0100
+++ mtd/include/linux/rbtree.h 2004-04-30 15:41:50.000000000 +0200
@@ -8,7 +8,7 @@
#include