aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/erase.c
diff options
context:
space:
mode:
authorJoakim Tjernlund <Joakim.Tjernlund@transmode.se>2007-06-01 09:14:09 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2007-06-28 13:41:22 -0400
commitfab2c399129273713b7dcc6a54cef17ca124a47f (patch)
tree738297917ecf605447fe29755b2b4053fd16a783 /fs/jffs2/erase.c
parent7eafaed55f4b8599cfe55449a6ed88d3693954de (diff)
[JFFS2] Use point(), if available, to check newly erased blocks.
Faster and won't trash the D-cache. Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs/jffs2/erase.c')
-rw-r--r--fs/jffs2/erase.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
index bdab9bc51d65..e9e3c2c330cc 100644
--- a/fs/jffs2/erase.c
+++ b/fs/jffs2/erase.c
@@ -317,6 +317,33 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
317 size_t retlen; 317 size_t retlen;
318 int ret = -EIO; 318 int ret = -EIO;
319 319
320 if (c->mtd->point) {
321 unsigned long *wordebuf;
322
323 ret = c->mtd->point(c->mtd, jeb->offset, c->sector_size, &retlen, (unsigned char **)&ebuf);
324 if (ret) {
325 D1(printk(KERN_DEBUG "MTD point failed %d\n", ret));
326 goto do_flash_read;
327 }
328 if (retlen < c->sector_size) {
329 /* Don't muck about if it won't let us point to the whole erase sector */
330 D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", retlen));
331 c->mtd->unpoint(c->mtd, ebuf, jeb->offset, c->sector_size);
332 goto do_flash_read;
333 }
334 wordebuf = ebuf-sizeof(*wordebuf);
335 retlen /= sizeof(*wordebuf);
336 do {
337 if (*++wordebuf != ~0)
338 break;
339 } while(--retlen);
340 c->mtd->unpoint(c->mtd, ebuf, jeb->offset, c->sector_size);
341 if (retlen)
342 printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08x\n",
343 *wordebuf, jeb->offset + c->sector_size-retlen*sizeof(*wordebuf));
344 return 0;
345 }
346 do_flash_read:
320 ebuf = kmalloc(PAGE_SIZE, GFP_KERNEL); 347 ebuf = kmalloc(PAGE_SIZE, GFP_KERNEL);
321 if (!ebuf) { 348 if (!ebuf) {
322 printk(KERN_WARNING "Failed to allocate page buffer for verifying erase at 0x%08x. Refiling\n", jeb->offset); 349 printk(KERN_WARNING "Failed to allocate page buffer for verifying erase at 0x%08x. Refiling\n", jeb->offset);