GIT 954c24227318c166ec1925e1229db442e1f56f51 git://git.infradead.org/mtd-2.6.git commit 954c24227318c166ec1925e1229db442e1f56f51 Author: Joern Engel Date: Tue Apr 18 21:03:08 2006 -0700 mtd: improve parameter parsing for block2mtd Expand the parameter parsing for block2mtd. It now accepts: Ki, Mi, Gi - the official prefixes for binary multiples, see http://physics.nist.gov/cuu/Units/binary.html, ki - mistake on my side and analog to "k" for decimal multiples, KiB, MiB, GiB - for people that prefer to add a "B" for byte, kiB - combination of the above. There were complaints about not accepting "k" for 1024. This has long been common practice, but is known to lead to confusion. Hence the new SI units and hence block2mtd only accepts units that cannot be confused with decimal units. Diverging from common practice doesn't always please people, even if the change is for the better. Signed-off-by: Joern Engel Cc: David Woodhouse Cc: Thomas Gleixner Signed-off-by: Andrew Morton commit 373d5e71833978fe3d91264d86857762bb92cfe2 Author: Richard Purdie Date: Tue Apr 18 02:05:46 2006 +0100 JFFS2: Return an error for long filenames Return an error if a name is too long for JFFS2 rather than corrupting data. Signed-off-by: Richard Purdie commit 6e62e8c2c7b1e3387d73ecb3f7539314b7a9931e Author: Richard Purdie Date: Tue Apr 18 02:04:18 2006 +0100 MTD: Correct Poodle partition size Correct the MTD NAND partition size for Poodle (Sharp Zaurus SL-5600) Signed-off-by: Richard Purdie commit b802c0741103aa92251d536c115874d51f802ec8 Author: Thago Galesi Date: Mon Apr 17 17:38:15 2006 +0100 [PATCH] Remove unnecessary kmalloc/kfree calls in mtdchar This patch removes repeated calls to kmalloc / kfree in mtd_write / mtd_read functions, replacing them by a single kmalloc / kfree pair. Signed-off-by: Thiago Galesi Signed-off-by: David Woodhouse commit cd2866faaa0efd9af18fe4a86d129cbd99240796 Author: Jörn Engel Date: Thu Apr 13 18:55:09 2006 +0200 Remove unused MTD types Three types are never set or checked for. Remove. Signed-off-by: Jörn Engel Signed-off-by: David Woodhouse commit a6c591eda3078f92e7a3ff3db55f6841e4819fb5 Author: Jörn Engel Date: Thu Apr 13 18:54:34 2006 +0200 Remove unchecked MTD flags Several flags are set by some devices, but never checked. Remove them. Signed-off-by: Jörn Engel Signed-off-by: David Woodhouse commit af63a3bcac77d8c01f3d963bac11a6f3f9b7c473 Author: Jörn Engel Date: Thu Apr 13 18:53:55 2006 +0200 Make mtdblock_ro unconditionally readonly mtdblock_ro is by definition readonly. Remove the silly checks. Signed-off-by: Jörn Engel Signed-off-by: David Woodhouse commit 7f7c08dfdf5bc0a7c906285d9d97b932f83e8979 Author: Jörn Engel Date: Thu Apr 13 18:53:14 2006 +0200 Simplify test for RAM devices mtdblock is the only user of aggregate capabilities in mtd. This is clearly bogus and should be changed. In particular, it tries to determine whether the device in question is a piece of RAM. For every single driver that fits the current criteria, an easier test would be to check for the type being MTD_RAM. Signed-off-by: Jörn Engel Signed-off-by: David Woodhouse commit d96fb997c6174f98a2a0a98200f99ac13b053bd6 Author: David Woodhouse Date: Mon Apr 17 00:19:48 2006 +0100 [JFFS2] Fix race in post-mount node checking For a while now, we've postponed CRC-checking of data nodes to be done by the GC thread, instead of being done while the user is waiting for mount to finish. The GC thread would iterate through all the inodes on the system and check each of their data nodes. It would skip over inodes which had already been used or were already being read in by read_inode(), because their data nodes would have been examined anyway. However, we could sometimes reach the end of the for-each-inode loop and still have some unchecked space left, if an inode we'd skipped was _still_ in the process of being read. This fixes that race by actually waiting for read_inode() to finish rather than just moving on. Thanks to Ladislav Michl for coming up with a reproducible test case and helping to track it down. Signed-off-by: David Woodhouse commit fb6a82c94a9c69adfb6b9f6ce9f84be36884e471 Author: Randy Dunlap Date: Tue Apr 11 20:12:10 2006 -0400 [PATCH] jffs2: fix printk warnings Fix printk format warnings in jffs2. Signed-off-by: Randy Dunlap Signed-off-by: David Woodhouse commit b104513c74d972f09737017394c5abc7e0a6835d Author: Randy Dunlap Date: Tue Apr 11 20:05:20 2006 -0400 [PATCH] MTD: m25p80: fix printk format warning Fix printk format warning: drivers/mtd/devices/m25p80.c:189: warning: format '%zd' expects type 'signed size_t', but argument 6 has type 'u_int32_t' Signed-off-by: Randy Dunlap Signed-off-by: David Woodhouse commit 6cc449c7d0292cb9b993f0df84fd3225e3099492 Author: Jesper Juhl Date: Tue Apr 11 19:42:44 2006 -0400 [PATCH] mtd, nettel: fix build error and implicit declaration I just hit the following error and warning : drivers/mtd/maps/nettel.c: In function `nettel_init': drivers/mtd/maps/nettel.c:418: error: `ROOT_DEV' undeclared (first use in this function) drivers/mtd/maps/nettel.c:418: error: (Each undeclared identifier is reported only once drivers/mtd/maps/nettel.c:418: error: for each function it appears in.) drivers/mtd/maps/nettel.c:418: warning: implicit declaration of function `MKDEV' make[3]: *** [drivers/mtd/maps/nettel.o] Error 1 make[2]: *** [drivers/mtd/maps] Error 2 make[1]: *** [drivers/mtd] Error 2 The patch fixes the missing ROOT_DEV declaration by including linux/root_dev.h and fixes the implicit declaration of MKDEV by including linux/kdev_t.h . Signed-off-by: Jesper Juhl Signed-off-by: David Woodhouse commit f4e9ce66c70c5d08b8a4d2c676924748c8b7550b Author: David Woodhouse Date: Tue Apr 11 19:29:07 2006 -0400 New MTD git tree in MAINTAINERS Signed-off-by: David Woodhouse --- diff --git a/MAINTAINERS b/MAINTAINERS index 6d3c401..20f3aea 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1778,12 +1778,12 @@ S: linux-scsi@vger.kernel.org W: http://megaraid.lsilogic.com S: Maintained -MEMORY TECHNOLOGY DEVICES +MEMORY TECHNOLOGY DEVICES (MTD) P: David Woodhouse M: dwmw2@infradead.org W: http://www.linux-mtd.infradead.org/ L: linux-mtd@lists.infradead.org -T: git kernel.org:/pub/scm/linux/kernel/git/tglx/mtd-2.6.git +T: git git://git.infradead.org/mtd-2.6.git S: Maintained MICROTEK X6 SCANNER diff --git a/drivers/mtd/chips/map_ram.c b/drivers/mtd/chips/map_ram.c index bd2e876..7639257 100644 --- a/drivers/mtd/chips/map_ram.c +++ b/drivers/mtd/chips/map_ram.c @@ -70,7 +70,7 @@ static struct mtd_info *map_ram_probe(st mtd->read = mapram_read; mtd->write = mapram_write; mtd->sync = mapram_nop; - mtd->flags = MTD_CAP_RAM | MTD_VOLATILE; + mtd->flags = MTD_CAP_RAM; mtd->erasesize = PAGE_SIZE; while(mtd->size & (mtd->erasesize - 1)) diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index 4160b83..f54e4bf 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c @@ -4,7 +4,7 @@ * block2mtd.c - create an mtd from a block device * * Copyright (C) 2001,2002 Simon Evans - * Copyright (C) 2004,2005 Jörn Engel + * Copyright (C) 2004-2006 Jörn Engel * * Licence: GPL */ @@ -351,6 +351,12 @@ devinit_err: } +/* This function works similar to reguler strtoul. In addition, it + * allows some suffixes for a more human-readable number format: + * ki, Ki, kiB, KiB - multiply result with 1024 + * Mi, MiB - multiply result with 1024^2 + * Gi, GiB - multiply result with 1024^3 + */ static int ustrtoul(const char *cp, char **endp, unsigned int base) { unsigned long result = simple_strtoul(cp, endp, base); @@ -359,11 +365,16 @@ static int ustrtoul(const char *cp, char result *= 1024; case 'M': result *= 1024; + case 'K': case 'k': result *= 1024; /* By dwmw2 editorial decree, "ki", "Mi" or "Gi" are to be used. */ - if ((*endp)[1] == 'i') - (*endp) += 2; + if ((*endp)[1] == 'i') { + if ((*endp)[2] == 'B') + (*endp) += 3; + else + (*endp) += 2; + } } return result; } diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 04e65d5..d5f2408 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -186,7 +186,7 @@ static int m25p80_erase(struct mtd_info struct m25p *flash = mtd_to_m25p(mtd); u32 addr,len; - DEBUG(MTD_DEBUG_LEVEL2, "%s: %s %s 0x%08x, len %d\n", + DEBUG(MTD_DEBUG_LEVEL2, "%s: %s %s 0x%08x, len %zd\n", flash->spi->dev.bus_id, __FUNCTION__, "at", (u32)instr->addr, instr->len); diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c index e8685ee..41af969 100644 --- a/drivers/mtd/devices/phram.c +++ b/drivers/mtd/devices/phram.c @@ -142,7 +142,7 @@ static int register_device(char *name, u new->mtd.name = name; new->mtd.size = len; - new->mtd.flags = MTD_CAP_RAM | MTD_ERASEABLE | MTD_VOLATILE; + new->mtd.flags = MTD_CAP_RAM; new->mtd.erase = phram_erase; new->mtd.point = phram_point; new->mtd.unpoint = phram_unpoint; diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c index 6faee6c..b3f665e 100644 --- a/drivers/mtd/devices/slram.c +++ b/drivers/mtd/devices/slram.c @@ -200,8 +200,7 @@ static int register_device(char *name, u (*curmtd)->mtdinfo->name = name; (*curmtd)->mtdinfo->size = length; - (*curmtd)->mtdinfo->flags = MTD_CLEAR_BITS | MTD_SET_BITS | - MTD_WRITEB_WRITEABLE | MTD_VOLATILE | MTD_CAP_RAM; + (*curmtd)->mtdinfo->flags = MTD_CAP_RAM; (*curmtd)->mtdinfo->erase = slram_erase; (*curmtd)->mtdinfo->point = slram_point; (*curmtd)->mtdinfo->unpoint = slram_unpoint; diff --git a/drivers/mtd/maps/nettel.c b/drivers/mtd/maps/nettel.c index 54a3102..20771b2 100644 --- a/drivers/mtd/maps/nettel.c +++ b/drivers/mtd/maps/nettel.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include /****************************************************************************/ diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c index 2cef280..8e50170 100644 --- a/drivers/mtd/mtdblock.c +++ b/drivers/mtd/mtdblock.c @@ -288,8 +288,7 @@ static int mtdblock_open(struct mtd_blkt mutex_init(&mtdblk->cache_mutex); mtdblk->cache_state = STATE_EMPTY; - if ((mtdblk->mtd->flags & MTD_CAP_RAM) != MTD_CAP_RAM && - mtdblk->mtd->erasesize) { + if (mtdblk->mtd->type != MTD_RAM && mtdblk->mtd->erasesize) { mtdblk->cache_size = mtdblk->mtd->erasesize; mtdblk->cache_data = NULL; } diff --git a/drivers/mtd/mtdblock_ro.c b/drivers/mtd/mtdblock_ro.c index 0c830ba..29563ed 100644 --- a/drivers/mtd/mtdblock_ro.c +++ b/drivers/mtd/mtdblock_ro.c @@ -45,9 +45,7 @@ static void mtdblock_add_mtd(struct mtd_ dev->blksize = 512; dev->size = mtd->size >> 9; dev->tr = tr; - if ((mtd->flags & (MTD_CLEAR_BITS|MTD_SET_BITS|MTD_WRITEABLE)) != - (MTD_CLEAR_BITS|MTD_SET_BITS|MTD_WRITEABLE)) - dev->readonly = 1; + dev->readonly = 1; add_mtd_blktrans_dev(dev); } diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 6f04458..6b83aee 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c @@ -170,16 +170,22 @@ static ssize_t mtd_read(struct file *fil /* FIXME: Use kiovec in 2.5 to lock down the user's buffers and pass them directly to the MTD functions */ + + if (count > MAX_KMALLOC_SIZE) + kbuf=kmalloc(MAX_KMALLOC_SIZE, GFP_KERNEL); + else + kbuf=kmalloc(count, GFP_KERNEL); + + if (!kbuf) + return -ENOMEM; + while (count) { + if (count > MAX_KMALLOC_SIZE) len = MAX_KMALLOC_SIZE; else len = count; - kbuf=kmalloc(len,GFP_KERNEL); - if (!kbuf) - return -ENOMEM; - switch (MTD_MODE(file)) { case MTD_MODE_OTP_FACT: ret = mtd->read_fact_prot_reg(mtd, *ppos, len, &retlen, kbuf); @@ -215,9 +221,9 @@ static ssize_t mtd_read(struct file *fil return ret; } - kfree(kbuf); } + kfree(kbuf); return total_retlen; } /* mtd_read */ @@ -241,18 +247,21 @@ static ssize_t mtd_write(struct file *fi if (!count) return 0; + if (count > MAX_KMALLOC_SIZE) + kbuf=kmalloc(MAX_KMALLOC_SIZE, GFP_KERNEL); + else + kbuf=kmalloc(count, GFP_KERNEL); + + if (!kbuf) + return -ENOMEM; + while (count) { + if (count > MAX_KMALLOC_SIZE) len = MAX_KMALLOC_SIZE; else len = count; - kbuf=kmalloc(len,GFP_KERNEL); - if (!kbuf) { - printk("kmalloc is null\n"); - return -ENOMEM; - } - if (copy_from_user(kbuf, buf, len)) { kfree(kbuf); return -EFAULT; @@ -282,10 +291,9 @@ static ssize_t mtd_write(struct file *fi kfree(kbuf); return ret; } - - kfree(kbuf); } + kfree(kbuf); return total_retlen; } /* mtd_write */ diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c index 1924a4f..c294374 100644 --- a/drivers/mtd/nand/sharpsl.c +++ b/drivers/mtd/nand/sharpsl.c @@ -237,7 +237,7 @@ sharpsl_nand_init(void) nr_partitions = DEFAULT_NUM_PARTITIONS; sharpsl_partition_info = sharpsl_nand_default_partition_info; if (machine_is_poodle()) { - sharpsl_partition_info[1].size=30 * 1024 * 1024; + sharpsl_partition_info[1].size=22 * 1024 * 1024; } else if (machine_is_corgi() || machine_is_shepherd()) { sharpsl_partition_info[1].size=25 * 1024 * 1024; } else if (machine_is_husky()) { diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index 8bc7a50..f92840a 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c @@ -78,6 +78,9 @@ static struct dentry *jffs2_lookup(struc D1(printk(KERN_DEBUG "jffs2_lookup()\n")); + if (target->d_name.len > JFFS2_MAX_NAME_LEN) + return ERR_PTR(-ENAMETOOLONG); + dir_f = JFFS2_INODE_INFO(dir_i); c = JFFS2_SB_INFO(dir_i->i_sb); diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c index f9ffece..967fb2c 100644 --- a/fs/jffs2/gc.c +++ b/fs/jffs2/gc.c @@ -181,6 +181,10 @@ int jffs2_garbage_collect_pass(struct jf and trigger the BUG() above while we haven't yet finished checking all its nodes */ D1(printk(KERN_DEBUG "Waiting for ino #%u to finish reading\n", ic->ino)); + /* We need to come back again for the _same_ inode. We've + made no progress in this case, but that should be OK */ + c->checked_ino--; + up(&c->alloc_sem); sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); return 0; diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c index f169564..e1acce8 100644 --- a/fs/jffs2/readinode.c +++ b/fs/jffs2/readinode.c @@ -204,7 +204,7 @@ static inline int read_dnode(struct jffs tn = jffs2_alloc_tmp_dnode_info(); if (!tn) { - JFFS2_ERROR("failed to allocate tn (%d bytes).\n", sizeof(*tn)); + JFFS2_ERROR("failed to allocate tn (%zu bytes).\n", sizeof(*tn)); return -ENOMEM; } @@ -434,7 +434,7 @@ static int read_more(struct jffs2_sb_inf } if (retlen < len) { - JFFS2_ERROR("short read at %#08x: %d instead of %d.\n", + JFFS2_ERROR("short read at %#08x: %zu instead of %d.\n", offs, retlen, len); return -EIO; } @@ -542,7 +542,7 @@ static int jffs2_get_inode_nodes(struct } if (retlen < len) { - JFFS2_ERROR("short read at %#08x: %d instead of %d.\n", ref_offset(ref), retlen, len); + JFFS2_ERROR("short read at %#08x: %zu instead of %d.\n", ref_offset(ref), retlen, len); err = -EIO; goto free_out; } diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c index fb9cec6..3240d62 100644 --- a/fs/jffs2/summary.c +++ b/fs/jffs2/summary.c @@ -655,7 +655,7 @@ static int jffs2_sum_write_data(struct j if (ret || (retlen != infosize)) { - JFFS2_WARNING("Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", + JFFS2_WARNING("Write of %d bytes at 0x%08x failed. returned %d, retlen %zu\n", infosize, jeb->offset + c->sector_size - jeb->free_size, ret, retlen); c->summary->sum_size = JFFS2_SUMMARY_NOSUM_SIZE; diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h index b5994ea..fa25241 100644 --- a/include/mtd/mtd-abi.h +++ b/include/mtd/mtd-abi.h @@ -28,27 +28,18 @@ struct mtd_oob_buf { #define MTD_ROM 2 #define MTD_NORFLASH 3 #define MTD_NANDFLASH 4 -#define MTD_PEROM 5 #define MTD_DATAFLASH 6 -#define MTD_OTHER 14 -#define MTD_UNKNOWN 15 #define MTD_CLEAR_BITS 1 // Bits can be cleared (flash) #define MTD_SET_BITS 2 // Bits can be set -#define MTD_ERASEABLE 4 // Has an erase function -#define MTD_WRITEB_WRITEABLE 8 // Direct IO is possible -#define MTD_VOLATILE 16 // Set for RAMs -#define MTD_XIP 32 // eXecute-In-Place possible -#define MTD_OOB 64 // Out-of-band data (NAND flash) #define MTD_ECC 128 // Device capable of automatic ECC -#define MTD_NO_VIRTBLOCKS 256 // Virtual blocks not allowed #define MTD_PROGRAM_REGIONS 512 // Configurable Programming Regions // Some common devices / combinations of capabilities #define MTD_CAP_ROM 0 -#define MTD_CAP_RAM (MTD_CLEAR_BITS|MTD_SET_BITS|MTD_WRITEB_WRITEABLE) -#define MTD_CAP_NORFLASH (MTD_CLEAR_BITS|MTD_ERASEABLE) -#define MTD_CAP_NANDFLASH (MTD_CLEAR_BITS|MTD_ERASEABLE|MTD_OOB) +#define MTD_CAP_RAM (MTD_CLEAR_BITS|MTD_SET_BITS) +#define MTD_CAP_NORFLASH (MTD_CLEAR_BITS) +#define MTD_CAP_NANDFLASH (MTD_CLEAR_BITS) #define MTD_WRITEABLE (MTD_CLEAR_BITS|MTD_SET_BITS)