diff options
-rw-r--r-- | fs/jffs2/erase.c | 27 |
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); |