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 +#endif #include #include #include diff -urN mtd-cvs-040314/fs/jffs2/rbtree.c mtd/fs/jffs2/rbtree.c --- mtd-cvs-040314/fs/jffs2/rbtree.c 2004-03-24 14:49:22.000000000 +0100 +++ mtd/fs/jffs2/rbtree.c 2006-02-22 09:30:10.000000000 +0100 @@ -302,7 +302,8 @@ } #endif /* Before 2.4.11 */ - /* These routines haven't made it into 2.4 (yet) */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,28) +/* These routines have appeared in 2.4.28 */ struct rb_node *rb_next(struct rb_node *node) { /* If we have a right-hand child, go down and then left as far @@ -339,7 +340,9 @@ return node->rb_parent; } +#endif +/* This routine hasn't made it into 2.4 (yet) */ void rb_replace_node(struct rb_node *victim, struct rb_node *new, struct rb_root *root) { struct rb_node *parent = victim->rb_parent; Les fichiers binaires mtd-cvs-040314/html/mtd.jpeg et mtd/html/mtd.jpeg sont différents. diff -urN mtd-cvs-040314/html/tech/nand.html mtd/html/tech/nand.html --- mtd-cvs-040314/html/tech/nand.html 2004-03-24 14:49:22.000000000 +0100 +++ mtd/html/tech/nand.html 2004-03-24 14:49:21.000000000 +0100 @@ -76,7 +76,7 @@ is given by writing to the chip with the Command Latch Enable pin high. Address is given by writing with the Address Latch Enable pin high.

-

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.

@@ -88,11 +88,11 @@ -
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 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,40) +#if LINUX_VERSION_CODE >= 0x020528 #include_next #else #define rb_node_s rb_node diff -urN mtd-cvs-040314/include/linux/workqueue.h mtd/include/linux/workqueue.h --- mtd-cvs-040314/include/linux/workqueue.h 2004-03-24 14:49:22.000000000 +0100 +++ mtd/include/linux/workqueue.h 2004-04-30 15:41:50.000000000 +0200 @@ -8,7 +8,7 @@ #include -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,40) +#if LINUX_VERSION_CODE > 0x020528 #include_next #else #include Les fichiers binaires mtd-cvs-040314/patches/lilo-mtd.tar.gz et mtd/patches/lilo-mtd.tar.gz sont différents. diff -urN mtd-cvs-040314/patches/patchin.sh mtd/patches/patchin.sh --- mtd-cvs-040314/patches/patchin.sh 2004-03-24 14:49:22.000000000 +0100 +++ mtd/patches/patchin.sh 2004-04-30 15:41:50.000000000 +0200 @@ -83,10 +83,10 @@ else SRCFILE=$FILE fi - rm -f $LINUXDIR/$DIR/$FILE 2>/dev/null - $LNCP $TOPDIR/$DIR/$SRCFILE $LINUXDIR/$DIR/$FILE + rm -f "$LINUXDIR/$DIR/$FILE" 2>/dev/null + $LNCP "$TOPDIR/$DIR/$SRCFILE" "$LINUXDIR/$DIR/$FILE" done - cd $LINUXDIR + cd "$LINUXDIR" done } @@ -104,14 +104,14 @@ esac done shift `expr $OPTIND - 1` -LINUXDIR=$1 +LINUXDIR="$1" -if [ -z $LINUXDIR ]; then +if [ -z "$LINUXDIR" ]; then usage; fi # Check if kerneldir contains a Makefile -if [ ! -f $LINUXDIR/Makefile ] +if [ ! -f "$LINUXDIR/Makefile" ] then echo "Directory $LINUXDIR does not exist or is not a kernel source directory"; exit 1; @@ -139,7 +139,7 @@ # Have we to use ZLIB PATCH ? if [ "$FILESYSTEMS" = "yes" ] then - PATCHDONE=`grep -s zlib_deflate $LINUXDIR/lib/Makefile | head -n 1` + PATCHDONE=`grep -s zlib_deflate "$LINUXDIR/lib/Makefile" | head -n 1` if test $PATCHLEVEL -eq 4 -a $SUBLEVEL -lt 20 then if [ "$PATCHDONE" = "" ] @@ -165,13 +165,13 @@ JFFS2_H=$FS_INC_25 fi -echo Patching $LINUXDIR -echo Include Filesytems: $FILESYSTEMS -echo Zlib-Patch needed: $ZLIBPATCH -echo Method: $METHOD -read -p "Can we start now ? [y/N]" ANSWER -echo "" - +echo Patching "$LINUXDIR" +echo Include Filesytems: "$FILESYSTEMS" +echo Zlib-Patch needed: "$ZLIBPATCH" +echo Method: "$METHOD" +#read -p "Can we start now ? [y/N]" ANSWER +#echo "" +ANSWER="y" if [ "$ANSWER" != "y" ] then echo Patching Kernel cancelled @@ -183,7 +183,7 @@ THISDIR=`pwd` TOPDIR=`dirname $THISDIR` -cd $LINUXDIR +cd "$LINUXDIR" # make directories, if necessary # remove existing files/links and link/copy the new ones diff -urN mtd-cvs-040314/util/compr_zlib.c mtd/util/compr_zlib.c --- mtd-cvs-040314/util/compr_zlib.c 2004-03-24 14:49:22.000000000 +0100 +++ mtd/util/compr_zlib.c 2007-02-28 10:29:07.000000000 +0100 @@ -36,7 +36,7 @@ */ #include -#include +#include #include #include diff -urN mtd-cvs-040314/util/jffs2reader.c mtd/util/jffs2reader.c --- mtd-cvs-040314/util/jffs2reader.c 2004-03-24 14:49:22.000000000 +0100 +++ mtd/util/jffs2reader.c 2007-02-28 10:29:07.000000000 +0100 @@ -77,7 +77,7 @@ #include #include #include -#include +#include #include #define SCRATCH_SIZE (5*1024*1024) diff -urN mtd-cvs-040314/util/mkfs.jffs2.c mtd/util/mkfs.jffs2.c --- mtd-cvs-040314/util/mkfs.jffs2.c 2004-03-24 14:49:22.000000000 +0100 +++ mtd/util/mkfs.jffs2.c 2007-02-28 10:29:07.000000000 +0100 @@ -64,7 +64,7 @@ #include #include #define crc32 __complete_crap -#include +#include #undef crc32 #include "crc32.h"