diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-05-14 09:10:33 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-07-24 06:32:54 -0400 |
commit | 979c9296bdcfded58ebac41905c3397317df0355 (patch) | |
tree | 7e9eed092834f747559390017834c2ce029b9944 /drivers | |
parent | 338b9bb3adac0d2c5a1e180491d9b001d624c402 (diff) |
UBI: print error code
Print error code if checking failed which is very useful
to identify problems.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/ubi/vtbl.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index af36b12be278..3c4d68f2cfd4 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c | |||
@@ -127,7 +127,7 @@ static int vtbl_check(const struct ubi_device *ubi, | |||
127 | const struct ubi_vtbl_record *vtbl) | 127 | const struct ubi_vtbl_record *vtbl) |
128 | { | 128 | { |
129 | int i, n, reserved_pebs, alignment, data_pad, vol_type, name_len; | 129 | int i, n, reserved_pebs, alignment, data_pad, vol_type, name_len; |
130 | int upd_marker; | 130 | int upd_marker, err; |
131 | uint32_t crc; | 131 | uint32_t crc; |
132 | const char *name; | 132 | const char *name; |
133 | 133 | ||
@@ -153,7 +153,7 @@ static int vtbl_check(const struct ubi_device *ubi, | |||
153 | if (reserved_pebs == 0) { | 153 | if (reserved_pebs == 0) { |
154 | if (memcmp(&vtbl[i], &empty_vtbl_record, | 154 | if (memcmp(&vtbl[i], &empty_vtbl_record, |
155 | UBI_VTBL_RECORD_SIZE)) { | 155 | UBI_VTBL_RECORD_SIZE)) { |
156 | dbg_err("bad empty record"); | 156 | err = 2; |
157 | goto bad; | 157 | goto bad; |
158 | } | 158 | } |
159 | continue; | 159 | continue; |
@@ -161,56 +161,57 @@ static int vtbl_check(const struct ubi_device *ubi, | |||
161 | 161 | ||
162 | if (reserved_pebs < 0 || alignment < 0 || data_pad < 0 || | 162 | if (reserved_pebs < 0 || alignment < 0 || data_pad < 0 || |
163 | name_len < 0) { | 163 | name_len < 0) { |
164 | dbg_err("negative values"); | 164 | err = 3; |
165 | goto bad; | 165 | goto bad; |
166 | } | 166 | } |
167 | 167 | ||
168 | if (alignment > ubi->leb_size || alignment == 0) { | 168 | if (alignment > ubi->leb_size || alignment == 0) { |
169 | dbg_err("bad alignment"); | 169 | err = 4; |
170 | goto bad; | 170 | goto bad; |
171 | } | 171 | } |
172 | 172 | ||
173 | n = alignment % ubi->min_io_size; | 173 | n = alignment % ubi->min_io_size; |
174 | if (alignment != 1 && n) { | 174 | if (alignment != 1 && n) { |
175 | dbg_err("alignment is not multiple of min I/O unit"); | 175 | err = 5; |
176 | goto bad; | 176 | goto bad; |
177 | } | 177 | } |
178 | 178 | ||
179 | n = ubi->leb_size % alignment; | 179 | n = ubi->leb_size % alignment; |
180 | if (data_pad != n) { | 180 | if (data_pad != n) { |
181 | dbg_err("bad data_pad, has to be %d", n); | 181 | dbg_err("bad data_pad, has to be %d", n); |
182 | err = 6; | ||
182 | goto bad; | 183 | goto bad; |
183 | } | 184 | } |
184 | 185 | ||
185 | if (vol_type != UBI_VID_DYNAMIC && vol_type != UBI_VID_STATIC) { | 186 | if (vol_type != UBI_VID_DYNAMIC && vol_type != UBI_VID_STATIC) { |
186 | dbg_err("bad vol_type"); | 187 | err = 7; |
187 | goto bad; | 188 | goto bad; |
188 | } | 189 | } |
189 | 190 | ||
190 | if (upd_marker != 0 && upd_marker != 1) { | 191 | if (upd_marker != 0 && upd_marker != 1) { |
191 | dbg_err("bad upd_marker"); | 192 | err = 8; |
192 | goto bad; | 193 | goto bad; |
193 | } | 194 | } |
194 | 195 | ||
195 | if (reserved_pebs > ubi->good_peb_count) { | 196 | if (reserved_pebs > ubi->good_peb_count) { |
196 | dbg_err("too large reserved_pebs, good PEBs %d", | 197 | dbg_err("too large reserved_pebs, good PEBs %d", |
197 | ubi->good_peb_count); | 198 | ubi->good_peb_count); |
199 | err = 9; | ||
198 | goto bad; | 200 | goto bad; |
199 | } | 201 | } |
200 | 202 | ||
201 | if (name_len > UBI_VOL_NAME_MAX) { | 203 | if (name_len > UBI_VOL_NAME_MAX) { |
202 | dbg_err("too long volume name, max %d", | 204 | err = 10; |
203 | UBI_VOL_NAME_MAX); | ||
204 | goto bad; | 205 | goto bad; |
205 | } | 206 | } |
206 | 207 | ||
207 | if (name[0] == '\0') { | 208 | if (name[0] == '\0') { |
208 | dbg_err("NULL volume name"); | 209 | err = 11; |
209 | goto bad; | 210 | goto bad; |
210 | } | 211 | } |
211 | 212 | ||
212 | if (name_len != strnlen(name, name_len + 1)) { | 213 | if (name_len != strnlen(name, name_len + 1)) { |
213 | dbg_err("bad name_len"); | 214 | err = 12; |
214 | goto bad; | 215 | goto bad; |
215 | } | 216 | } |
216 | } | 217 | } |
@@ -235,7 +236,7 @@ static int vtbl_check(const struct ubi_device *ubi, | |||
235 | return 0; | 236 | return 0; |
236 | 237 | ||
237 | bad: | 238 | bad: |
238 | ubi_err("volume table check failed, record %d", i); | 239 | ubi_err("volume table check failed: record %d, error %d", i, err); |
239 | ubi_dbg_dump_vtbl_record(&vtbl[i], i); | 240 | ubi_dbg_dump_vtbl_record(&vtbl[i], i); |
240 | return -EINVAL; | 241 | return -EINVAL; |
241 | } | 242 | } |
@@ -620,30 +621,32 @@ static int init_volumes(struct ubi_device *ubi, const struct ubi_scan_info *si, | |||
620 | static int check_sv(const struct ubi_volume *vol, | 621 | static int check_sv(const struct ubi_volume *vol, |
621 | const struct ubi_scan_volume *sv) | 622 | const struct ubi_scan_volume *sv) |
622 | { | 623 | { |
624 | int err; | ||
625 | |||
623 | if (sv->highest_lnum >= vol->reserved_pebs) { | 626 | if (sv->highest_lnum >= vol->reserved_pebs) { |
624 | dbg_err("bad highest_lnum"); | 627 | err = 1; |
625 | goto bad; | 628 | goto bad; |
626 | } | 629 | } |
627 | if (sv->leb_count > vol->reserved_pebs) { | 630 | if (sv->leb_count > vol->reserved_pebs) { |
628 | dbg_err("bad leb_count"); | 631 | err = 2; |
629 | goto bad; | 632 | goto bad; |
630 | } | 633 | } |
631 | if (sv->vol_type != vol->vol_type) { | 634 | if (sv->vol_type != vol->vol_type) { |
632 | dbg_err("bad vol_type"); | 635 | err = 3; |
633 | goto bad; | 636 | goto bad; |
634 | } | 637 | } |
635 | if (sv->used_ebs > vol->reserved_pebs) { | 638 | if (sv->used_ebs > vol->reserved_pebs) { |
636 | dbg_err("bad used_ebs"); | 639 | err = 4; |
637 | goto bad; | 640 | goto bad; |
638 | } | 641 | } |
639 | if (sv->data_pad != vol->data_pad) { | 642 | if (sv->data_pad != vol->data_pad) { |
640 | dbg_err("bad data_pad"); | 643 | err = 5; |
641 | goto bad; | 644 | goto bad; |
642 | } | 645 | } |
643 | return 0; | 646 | return 0; |
644 | 647 | ||
645 | bad: | 648 | bad: |
646 | ubi_err("bad scanning information"); | 649 | ubi_err("bad scanning information, error %d", err); |
647 | ubi_dbg_dump_sv(sv); | 650 | ubi_dbg_dump_sv(sv); |
648 | ubi_dbg_dump_vol_info(vol); | 651 | ubi_dbg_dump_vol_info(vol); |
649 | return -EINVAL; | 652 | return -EINVAL; |