aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/scan.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2009-06-30 09:11:59 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2009-07-05 11:47:08 -0400
commitfe96efc1a3c049f0a1bcd9b65e0faeb751ce5ec6 (patch)
tree5c750ab134bb1037eeaf5baa8d9eee6196566226 /drivers/mtd/ubi/scan.c
parent0c6c7fa1313fcb69cae35e34168d2e83b8da854a (diff)
UBI: nicify image sequence number handling
Move the image seq. number handling from I/O level to the scanning lever, where it really belongs to. Move the @image_seq_set variable to the @struct ubi_scan_info structure, which exists only during scanning. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/scan.c')
-rw-r--r--drivers/mtd/ubi/scan.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 72570ed7d33f..f60895ee0aeb 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -757,6 +757,8 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
757 si->is_empty = 0; 757 si->is_empty = 0;
758 758
759 if (!ec_corr) { 759 if (!ec_corr) {
760 int image_seq;
761
760 /* Make sure UBI version is OK */ 762 /* Make sure UBI version is OK */
761 if (ech->version != UBI_VERSION) { 763 if (ech->version != UBI_VERSION) {
762 ubi_err("this UBI version is %d, image version is %d", 764 ubi_err("this UBI version is %d, image version is %d",
@@ -778,6 +780,18 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
778 ubi_dbg_dump_ec_hdr(ech); 780 ubi_dbg_dump_ec_hdr(ech);
779 return -EINVAL; 781 return -EINVAL;
780 } 782 }
783
784 image_seq = be32_to_cpu(ech->ec);
785 if (!si->image_seq_set) {
786 ubi->image_seq = image_seq;
787 si->image_seq_set = 1;
788 } else if (ubi->image_seq != image_seq) {
789 ubi_err("bad image sequence number %d in PEB %d, "
790 "expected %d", image_seq, pnum, ubi->image_seq);
791 ubi_dbg_dump_ec_hdr(ech);
792 return -EINVAL;
793 }
794
781 } 795 }
782 796
783 /* OK, we've done with the EC header, let's look at the VID header */ 797 /* OK, we've done with the EC header, let's look at the VID header */
@@ -910,8 +924,6 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi)
910 if (si->is_empty) 924 if (si->is_empty)
911 ubi_msg("empty MTD device detected"); 925 ubi_msg("empty MTD device detected");
912 926
913 ubi->image_seq_set = 1;
914
915 /* 927 /*
916 * In case of unknown erase counter we use the mean erase counter 928 * In case of unknown erase counter we use the mean erase counter
917 * value. 929 * value.