aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/jffs2/scan.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index a5103df5242e..7a46a436edfc 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -636,16 +636,17 @@ scan_more:
636 636
637 if (*(uint32_t *)(&buf[ofs-buf_ofs]) == 0xffffffff) { 637 if (*(uint32_t *)(&buf[ofs-buf_ofs]) == 0xffffffff) {
638 uint32_t inbuf_ofs; 638 uint32_t inbuf_ofs;
639 uint32_t empty_start; 639 uint32_t empty_start, scan_end;
640 640
641 empty_start = ofs; 641 empty_start = ofs;
642 ofs += 4; 642 ofs += 4;
643 scan_end = min_t(uint32_t, EMPTY_SCAN_SIZE(c->sector_size)/8, buf_len);
643 644
644 D1(printk(KERN_DEBUG "Found empty flash at 0x%08x\n", ofs)); 645 D1(printk(KERN_DEBUG "Found empty flash at 0x%08x\n", ofs));
645 more_empty: 646 more_empty:
646 inbuf_ofs = ofs - buf_ofs; 647 inbuf_ofs = ofs - buf_ofs;
647 while (inbuf_ofs < buf_len) { 648 while (inbuf_ofs < scan_end) {
648 if (*(uint32_t *)(&buf[inbuf_ofs]) != 0xffffffff) { 649 if (unlikely(*(uint32_t *)(&buf[inbuf_ofs]) != 0xffffffff)) {
649 printk(KERN_WARNING "Empty flash at 0x%08x ends at 0x%08x\n", 650 printk(KERN_WARNING "Empty flash at 0x%08x ends at 0x%08x\n",
650 empty_start, ofs); 651 empty_start, ofs);
651 if ((err = jffs2_scan_dirty_space(c, jeb, ofs-empty_start))) 652 if ((err = jffs2_scan_dirty_space(c, jeb, ofs-empty_start)))
@@ -666,7 +667,11 @@ scan_more:
666 D1(printk(KERN_DEBUG "%d bytes at start of block seems clean... assuming all clean\n", EMPTY_SCAN_SIZE(c->sector_size))); 667 D1(printk(KERN_DEBUG "%d bytes at start of block seems clean... assuming all clean\n", EMPTY_SCAN_SIZE(c->sector_size)));
667 return BLK_STATE_CLEANMARKER; 668 return BLK_STATE_CLEANMARKER;
668 } 669 }
669 670 if (!buf_size && (scan_end != buf_len)) {/* XIP/point case */
671 scan_end = buf_len;
672 goto more_empty;
673 }
674
670 /* See how much more there is to read in this eraseblock... */ 675 /* See how much more there is to read in this eraseblock... */
671 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); 676 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);
672 if (!buf_len) { 677 if (!buf_len) {
@@ -676,6 +681,8 @@ scan_more:
676 empty_start)); 681 empty_start));
677 break; 682 break;
678 } 683 }
684 /* point never reaches here */
685 scan_end = buf_len;
679 D1(printk(KERN_DEBUG "Reading another 0x%x at 0x%08x\n", buf_len, ofs)); 686 D1(printk(KERN_DEBUG "Reading another 0x%x at 0x%08x\n", buf_len, ofs));
680 err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); 687 err = jffs2_fill_scan_buf(c, buf, ofs, buf_len);
681 if (err) 688 if (err)