diff options
Diffstat (limited to 'drivers/mtd/ubi/scan.c')
-rw-r--r-- | drivers/mtd/ubi/scan.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index 3c631863bf40..79ca304fc4db 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c | |||
@@ -787,16 +787,15 @@ static int check_corruption(struct ubi_device *ubi, struct ubi_vid_hdr *vid_hdr, | |||
787 | * erased, so it became unstable and corrupted, and should be | 787 | * erased, so it became unstable and corrupted, and should be |
788 | * erased. | 788 | * erased. |
789 | */ | 789 | */ |
790 | return 0; | 790 | err = 0; |
791 | goto out_unlock; | ||
791 | } | 792 | } |
792 | 793 | ||
793 | if (err) | 794 | if (err) |
794 | return err; | 795 | goto out_unlock; |
795 | 796 | ||
796 | if (ubi_check_pattern(ubi->peb_buf1, 0xFF, ubi->leb_size)) { | 797 | if (ubi_check_pattern(ubi->peb_buf1, 0xFF, ubi->leb_size)) |
797 | mutex_unlock(&ubi->buf_mutex); | 798 | goto out_unlock; |
798 | return 0; | ||
799 | } | ||
800 | 799 | ||
801 | ubi_err("PEB %d contains corrupted VID header, and the data does not " | 800 | ubi_err("PEB %d contains corrupted VID header, and the data does not " |
802 | "contain all 0xFF, this may be a non-UBI PEB or a severe VID " | 801 | "contain all 0xFF, this may be a non-UBI PEB or a severe VID " |
@@ -806,8 +805,11 @@ static int check_corruption(struct ubi_device *ubi, struct ubi_vid_hdr *vid_hdr, | |||
806 | pnum, ubi->leb_start, ubi->leb_size); | 805 | pnum, ubi->leb_start, ubi->leb_size); |
807 | ubi_dbg_print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, | 806 | ubi_dbg_print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, |
808 | ubi->peb_buf1, ubi->leb_size, 1); | 807 | ubi->peb_buf1, ubi->leb_size, 1); |
808 | err = 1; | ||
809 | |||
810 | out_unlock: | ||
809 | mutex_unlock(&ubi->buf_mutex); | 811 | mutex_unlock(&ubi->buf_mutex); |
810 | return 1; | 812 | return err; |
811 | } | 813 | } |
812 | 814 | ||
813 | /** | 815 | /** |
@@ -951,6 +953,10 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si, | |||
951 | * impossible to distinguish it from a PEB which just | 953 | * impossible to distinguish it from a PEB which just |
952 | * contains garbage because of a power cut during erase | 954 | * contains garbage because of a power cut during erase |
953 | * operation. So we just schedule this PEB for erasure. | 955 | * operation. So we just schedule this PEB for erasure. |
956 | * | ||
957 | * Besides, in case of NOR flash, we deliberatly | ||
958 | * corrupt both headers because NOR flash erasure is | ||
959 | * slow and can start from the end. | ||
954 | */ | 960 | */ |
955 | err = 0; | 961 | err = 0; |
956 | else | 962 | else |