aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/ubi/io.c')
-rw-r--r--drivers/mtd/ubi/io.c80
1 files changed, 39 insertions, 41 deletions
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index a8d523794b52..78a1dcbf2107 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -177,21 +177,20 @@ retry:
177 * enabled. A corresponding message will be printed 177 * enabled. A corresponding message will be printed
178 * later, when it is has been scrubbed. 178 * later, when it is has been scrubbed.
179 */ 179 */
180 dbg_msg("fixable bit-flip detected at PEB %d", pnum); 180 ubi_msg("fixable bit-flip detected at PEB %d", pnum);
181 ubi_assert(len == read); 181 ubi_assert(len == read);
182 return UBI_IO_BITFLIPS; 182 return UBI_IO_BITFLIPS;
183 } 183 }
184 184
185 if (retries++ < UBI_IO_RETRIES) { 185 if (retries++ < UBI_IO_RETRIES) {
186 ubi_warn("error %d%s while reading %d bytes from PEB " 186 ubi_warn("error %d%s while reading %d bytes from PEB %d:%d, read only %zd bytes, retry",
187 "%d:%d, read only %zd bytes, retry",
188 err, errstr, len, pnum, offset, read); 187 err, errstr, len, pnum, offset, read);
189 yield(); 188 yield();
190 goto retry; 189 goto retry;
191 } 190 }
192 191
193 ubi_err("error %d%s while reading %d bytes from PEB %d:%d, " 192 ubi_err("error %d%s while reading %d bytes from PEB %d:%d, read %zd bytes",
194 "read %zd bytes", err, errstr, len, pnum, offset, read); 193 err, errstr, len, pnum, offset, read);
195 dump_stack(); 194 dump_stack();
196 195
197 /* 196 /*
@@ -274,8 +273,8 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
274 } 273 }
275 274
276 if (ubi_dbg_is_write_failure(ubi)) { 275 if (ubi_dbg_is_write_failure(ubi)) {
277 ubi_err("cannot write %d bytes to PEB %d:%d " 276 ubi_err("cannot write %d bytes to PEB %d:%d (emulated)",
278 "(emulated)", len, pnum, offset); 277 len, pnum, offset);
279 dump_stack(); 278 dump_stack();
280 return -EIO; 279 return -EIO;
281 } 280 }
@@ -283,8 +282,8 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
283 addr = (loff_t)pnum * ubi->peb_size + offset; 282 addr = (loff_t)pnum * ubi->peb_size + offset;
284 err = mtd_write(ubi->mtd, addr, len, &written, buf); 283 err = mtd_write(ubi->mtd, addr, len, &written, buf);
285 if (err) { 284 if (err) {
286 ubi_err("error %d while writing %d bytes to PEB %d:%d, written " 285 ubi_err("error %d while writing %d bytes to PEB %d:%d, written %zd bytes",
287 "%zd bytes", err, len, pnum, offset, written); 286 err, len, pnum, offset, written);
288 dump_stack(); 287 dump_stack();
289 ubi_dump_flash(ubi, pnum, offset, len); 288 ubi_dump_flash(ubi, pnum, offset, len);
290 } else 289 } else
@@ -685,8 +684,7 @@ static int validate_ec_hdr(const struct ubi_device *ubi,
685 leb_start = be32_to_cpu(ec_hdr->data_offset); 684 leb_start = be32_to_cpu(ec_hdr->data_offset);
686 685
687 if (ec_hdr->version != UBI_VERSION) { 686 if (ec_hdr->version != UBI_VERSION) {
688 ubi_err("node with incompatible UBI version found: " 687 ubi_err("node with incompatible UBI version found: this UBI version is %d, image version is %d",
689 "this UBI version is %d, image version is %d",
690 UBI_VERSION, (int)ec_hdr->version); 688 UBI_VERSION, (int)ec_hdr->version);
691 goto bad; 689 goto bad;
692 } 690 }
@@ -777,10 +775,10 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
777 if (ubi_check_pattern(ec_hdr, 0xFF, UBI_EC_HDR_SIZE)) { 775 if (ubi_check_pattern(ec_hdr, 0xFF, UBI_EC_HDR_SIZE)) {
778 /* The physical eraseblock is supposedly empty */ 776 /* The physical eraseblock is supposedly empty */
779 if (verbose) 777 if (verbose)
780 ubi_warn("no EC header found at PEB %d, " 778 ubi_warn("no EC header found at PEB %d, only 0xFF bytes",
781 "only 0xFF bytes", pnum); 779 pnum);
782 dbg_bld("no EC header found at PEB %d, " 780 dbg_bld("no EC header found at PEB %d, only 0xFF bytes",
783 "only 0xFF bytes", pnum); 781 pnum);
784 if (!read_err) 782 if (!read_err)
785 return UBI_IO_FF; 783 return UBI_IO_FF;
786 else 784 else
@@ -792,12 +790,12 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
792 * 0xFF bytes. Report that the header is corrupted. 790 * 0xFF bytes. Report that the header is corrupted.
793 */ 791 */
794 if (verbose) { 792 if (verbose) {
795 ubi_warn("bad magic number at PEB %d: %08x instead of " 793 ubi_warn("bad magic number at PEB %d: %08x instead of %08x",
796 "%08x", pnum, magic, UBI_EC_HDR_MAGIC); 794 pnum, magic, UBI_EC_HDR_MAGIC);
797 ubi_dump_ec_hdr(ec_hdr); 795 ubi_dump_ec_hdr(ec_hdr);
798 } 796 }
799 dbg_bld("bad magic number at PEB %d: %08x instead of " 797 dbg_bld("bad magic number at PEB %d: %08x instead of %08x",
800 "%08x", pnum, magic, UBI_EC_HDR_MAGIC); 798 pnum, magic, UBI_EC_HDR_MAGIC);
801 return UBI_IO_BAD_HDR; 799 return UBI_IO_BAD_HDR;
802 } 800 }
803 801
@@ -806,12 +804,12 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
806 804
807 if (hdr_crc != crc) { 805 if (hdr_crc != crc) {
808 if (verbose) { 806 if (verbose) {
809 ubi_warn("bad EC header CRC at PEB %d, calculated " 807 ubi_warn("bad EC header CRC at PEB %d, calculated %#08x, read %#08x",
810 "%#08x, read %#08x", pnum, crc, hdr_crc); 808 pnum, crc, hdr_crc);
811 ubi_dump_ec_hdr(ec_hdr); 809 ubi_dump_ec_hdr(ec_hdr);
812 } 810 }
813 dbg_bld("bad EC header CRC at PEB %d, calculated " 811 dbg_bld("bad EC header CRC at PEB %d, calculated %#08x, read %#08x",
814 "%#08x, read %#08x", pnum, crc, hdr_crc); 812 pnum, crc, hdr_crc);
815 813
816 if (!read_err) 814 if (!read_err)
817 return UBI_IO_BAD_HDR; 815 return UBI_IO_BAD_HDR;
@@ -1032,10 +1030,10 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
1032 1030
1033 if (ubi_check_pattern(vid_hdr, 0xFF, UBI_VID_HDR_SIZE)) { 1031 if (ubi_check_pattern(vid_hdr, 0xFF, UBI_VID_HDR_SIZE)) {
1034 if (verbose) 1032 if (verbose)
1035 ubi_warn("no VID header found at PEB %d, " 1033 ubi_warn("no VID header found at PEB %d, only 0xFF bytes",
1036 "only 0xFF bytes", pnum); 1034 pnum);
1037 dbg_bld("no VID header found at PEB %d, " 1035 dbg_bld("no VID header found at PEB %d, only 0xFF bytes",
1038 "only 0xFF bytes", pnum); 1036 pnum);
1039 if (!read_err) 1037 if (!read_err)
1040 return UBI_IO_FF; 1038 return UBI_IO_FF;
1041 else 1039 else
@@ -1043,12 +1041,12 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
1043 } 1041 }
1044 1042
1045 if (verbose) { 1043 if (verbose) {
1046 ubi_warn("bad magic number at PEB %d: %08x instead of " 1044 ubi_warn("bad magic number at PEB %d: %08x instead of %08x",
1047 "%08x", pnum, magic, UBI_VID_HDR_MAGIC); 1045 pnum, magic, UBI_VID_HDR_MAGIC);
1048 ubi_dump_vid_hdr(vid_hdr); 1046 ubi_dump_vid_hdr(vid_hdr);
1049 } 1047 }
1050 dbg_bld("bad magic number at PEB %d: %08x instead of " 1048 dbg_bld("bad magic number at PEB %d: %08x instead of %08x",
1051 "%08x", pnum, magic, UBI_VID_HDR_MAGIC); 1049 pnum, magic, UBI_VID_HDR_MAGIC);
1052 return UBI_IO_BAD_HDR; 1050 return UBI_IO_BAD_HDR;
1053 } 1051 }
1054 1052
@@ -1057,12 +1055,12 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
1057 1055
1058 if (hdr_crc != crc) { 1056 if (hdr_crc != crc) {
1059 if (verbose) { 1057 if (verbose) {
1060 ubi_warn("bad CRC at PEB %d, calculated %#08x, " 1058 ubi_warn("bad CRC at PEB %d, calculated %#08x, read %#08x",
1061 "read %#08x", pnum, crc, hdr_crc); 1059 pnum, crc, hdr_crc);
1062 ubi_dump_vid_hdr(vid_hdr); 1060 ubi_dump_vid_hdr(vid_hdr);
1063 } 1061 }
1064 dbg_bld("bad CRC at PEB %d, calculated %#08x, " 1062 dbg_bld("bad CRC at PEB %d, calculated %#08x, read %#08x",
1065 "read %#08x", pnum, crc, hdr_crc); 1063 pnum, crc, hdr_crc);
1066 if (!read_err) 1064 if (!read_err)
1067 return UBI_IO_BAD_HDR; 1065 return UBI_IO_BAD_HDR;
1068 else 1066 else
@@ -1300,8 +1298,8 @@ static int self_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum)
1300 crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_EC_HDR_SIZE_CRC); 1298 crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_EC_HDR_SIZE_CRC);
1301 hdr_crc = be32_to_cpu(vid_hdr->hdr_crc); 1299 hdr_crc = be32_to_cpu(vid_hdr->hdr_crc);
1302 if (hdr_crc != crc) { 1300 if (hdr_crc != crc) {
1303 ubi_err("bad VID header CRC at PEB %d, calculated %#08x, " 1301 ubi_err("bad VID header CRC at PEB %d, calculated %#08x, read %#08x",
1304 "read %#08x", pnum, crc, hdr_crc); 1302 pnum, crc, hdr_crc);
1305 ubi_err("self-check failed for PEB %d", pnum); 1303 ubi_err("self-check failed for PEB %d", pnum);
1306 ubi_dump_vid_hdr(vid_hdr); 1304 ubi_dump_vid_hdr(vid_hdr);
1307 dump_stack(); 1305 dump_stack();
@@ -1411,15 +1409,15 @@ int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
1411 1409
1412 err = mtd_read(ubi->mtd, addr, len, &read, buf); 1410 err = mtd_read(ubi->mtd, addr, len, &read, buf);
1413 if (err && !mtd_is_bitflip(err)) { 1411 if (err && !mtd_is_bitflip(err)) {
1414 ubi_err("error %d while reading %d bytes from PEB %d:%d, " 1412 ubi_err("error %d while reading %d bytes from PEB %d:%d, read %zd bytes",
1415 "read %zd bytes", err, len, pnum, offset, read); 1413 err, len, pnum, offset, read);
1416 goto error; 1414 goto error;
1417 } 1415 }
1418 1416
1419 err = ubi_check_pattern(buf, 0xFF, len); 1417 err = ubi_check_pattern(buf, 0xFF, len);
1420 if (err == 0) { 1418 if (err == 0) {
1421 ubi_err("flash region at PEB %d:%d, length %d does not " 1419 ubi_err("flash region at PEB %d:%d, length %d does not contain all 0xFF bytes",
1422 "contain all 0xFF bytes", pnum, offset, len); 1420 pnum, offset, len);
1423 goto fail; 1421 goto fail;
1424 } 1422 }
1425 1423