diff options
author | Brian Norris <computersforpeace@gmail.com> | 2011-09-20 21:34:25 -0400 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@intel.com> | 2011-09-21 02:19:06 -0400 |
commit | d57f40544a41fdfe90fd863b6865138c5a82f1cc (patch) | |
tree | 4d5e8f6d0a62e8fa06ccfabd13fe9364b19db1b5 /drivers/mtd/ubi/io.c | |
parent | 7387ce773256f446bdd0280b2449b635441f906e (diff) |
mtd: utilize `mtd_is_*()' functions
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
Diffstat (limited to 'drivers/mtd/ubi/io.c')
-rw-r--r-- | drivers/mtd/ubi/io.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index 6ba55c235873..f20b6f22f240 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c | |||
@@ -172,9 +172,9 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset, | |||
172 | retry: | 172 | retry: |
173 | err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf); | 173 | err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf); |
174 | if (err) { | 174 | if (err) { |
175 | const char *errstr = (err == -EBADMSG) ? " (ECC error)" : ""; | 175 | const char *errstr = mtd_is_eccerr(err) ? " (ECC error)" : ""; |
176 | 176 | ||
177 | if (err == -EUCLEAN) { | 177 | if (mtd_is_bitflip(err)) { |
178 | /* | 178 | /* |
179 | * -EUCLEAN is reported if there was a bit-flip which | 179 | * -EUCLEAN is reported if there was a bit-flip which |
180 | * was corrected, so this is harmless. | 180 | * was corrected, so this is harmless. |
@@ -205,7 +205,7 @@ retry: | |||
205 | * all the requested data. But some buggy drivers might do | 205 | * all the requested data. But some buggy drivers might do |
206 | * this, so we change it to -EIO. | 206 | * this, so we change it to -EIO. |
207 | */ | 207 | */ |
208 | if (read != len && err == -EBADMSG) { | 208 | if (read != len && mtd_is_eccerr(err)) { |
209 | ubi_assert(0); | 209 | ubi_assert(0); |
210 | err = -EIO; | 210 | err = -EIO; |
211 | } | 211 | } |
@@ -469,7 +469,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum) | |||
469 | 469 | ||
470 | out: | 470 | out: |
471 | mutex_unlock(&ubi->buf_mutex); | 471 | mutex_unlock(&ubi->buf_mutex); |
472 | if (err == UBI_IO_BITFLIPS || err == -EBADMSG) { | 472 | if (err == UBI_IO_BITFLIPS || mtd_is_eccerr(err)) { |
473 | /* | 473 | /* |
474 | * If a bit-flip or data integrity error was detected, the test | 474 | * If a bit-flip or data integrity error was detected, the test |
475 | * has not passed because it happened on a freshly erased | 475 | * has not passed because it happened on a freshly erased |
@@ -760,7 +760,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, | |||
760 | 760 | ||
761 | read_err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE); | 761 | read_err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE); |
762 | if (read_err) { | 762 | if (read_err) { |
763 | if (read_err != UBI_IO_BITFLIPS && read_err != -EBADMSG) | 763 | if (read_err != UBI_IO_BITFLIPS && !mtd_is_eccerr(read_err)) |
764 | return read_err; | 764 | return read_err; |
765 | 765 | ||
766 | /* | 766 | /* |
@@ -776,7 +776,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, | |||
776 | 776 | ||
777 | magic = be32_to_cpu(ec_hdr->magic); | 777 | magic = be32_to_cpu(ec_hdr->magic); |
778 | if (magic != UBI_EC_HDR_MAGIC) { | 778 | if (magic != UBI_EC_HDR_MAGIC) { |
779 | if (read_err == -EBADMSG) | 779 | if (mtd_is_eccerr(read_err)) |
780 | return UBI_IO_BAD_HDR_EBADMSG; | 780 | return UBI_IO_BAD_HDR_EBADMSG; |
781 | 781 | ||
782 | /* | 782 | /* |
@@ -1032,12 +1032,12 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, | |||
1032 | p = (char *)vid_hdr - ubi->vid_hdr_shift; | 1032 | p = (char *)vid_hdr - ubi->vid_hdr_shift; |
1033 | read_err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset, | 1033 | read_err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset, |
1034 | ubi->vid_hdr_alsize); | 1034 | ubi->vid_hdr_alsize); |
1035 | if (read_err && read_err != UBI_IO_BITFLIPS && read_err != -EBADMSG) | 1035 | if (read_err && read_err != UBI_IO_BITFLIPS && !mtd_is_eccerr(read_err)) |
1036 | return read_err; | 1036 | return read_err; |
1037 | 1037 | ||
1038 | magic = be32_to_cpu(vid_hdr->magic); | 1038 | magic = be32_to_cpu(vid_hdr->magic); |
1039 | if (magic != UBI_VID_HDR_MAGIC) { | 1039 | if (magic != UBI_VID_HDR_MAGIC) { |
1040 | if (read_err == -EBADMSG) | 1040 | if (mtd_is_eccerr(read_err)) |
1041 | return UBI_IO_BAD_HDR_EBADMSG; | 1041 | return UBI_IO_BAD_HDR_EBADMSG; |
1042 | 1042 | ||
1043 | if (ubi_check_pattern(vid_hdr, 0xFF, UBI_VID_HDR_SIZE)) { | 1043 | if (ubi_check_pattern(vid_hdr, 0xFF, UBI_VID_HDR_SIZE)) { |
@@ -1219,7 +1219,7 @@ static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum) | |||
1219 | return -ENOMEM; | 1219 | return -ENOMEM; |
1220 | 1220 | ||
1221 | err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE); | 1221 | err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE); |
1222 | if (err && err != UBI_IO_BITFLIPS && err != -EBADMSG) | 1222 | if (err && err != UBI_IO_BITFLIPS && !mtd_is_eccerr(err)) |
1223 | goto exit; | 1223 | goto exit; |
1224 | 1224 | ||
1225 | crc = crc32(UBI_CRC32_INIT, ec_hdr, UBI_EC_HDR_SIZE_CRC); | 1225 | crc = crc32(UBI_CRC32_INIT, ec_hdr, UBI_EC_HDR_SIZE_CRC); |
@@ -1306,7 +1306,7 @@ static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum) | |||
1306 | p = (char *)vid_hdr - ubi->vid_hdr_shift; | 1306 | p = (char *)vid_hdr - ubi->vid_hdr_shift; |
1307 | err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset, | 1307 | err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset, |
1308 | ubi->vid_hdr_alsize); | 1308 | ubi->vid_hdr_alsize); |
1309 | if (err && err != UBI_IO_BITFLIPS && err != -EBADMSG) | 1309 | if (err && err != UBI_IO_BITFLIPS && !mtd_is_eccerr(err)) |
1310 | goto exit; | 1310 | goto exit; |
1311 | 1311 | ||
1312 | crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_EC_HDR_SIZE_CRC); | 1312 | crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_EC_HDR_SIZE_CRC); |
@@ -1358,7 +1358,7 @@ int ubi_dbg_check_write(struct ubi_device *ubi, const void *buf, int pnum, | |||
1358 | } | 1358 | } |
1359 | 1359 | ||
1360 | err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf1); | 1360 | err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf1); |
1361 | if (err && err != -EUCLEAN) | 1361 | if (err && !mtd_is_bitflip(err)) |
1362 | goto out_free; | 1362 | goto out_free; |
1363 | 1363 | ||
1364 | for (i = 0; i < len; i++) { | 1364 | for (i = 0; i < len; i++) { |
@@ -1422,7 +1422,7 @@ int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len) | |||
1422 | } | 1422 | } |
1423 | 1423 | ||
1424 | err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf); | 1424 | err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf); |
1425 | if (err && err != -EUCLEAN) { | 1425 | if (err && !mtd_is_bitflip(err)) { |
1426 | ubi_err("error %d while reading %d bytes from PEB %d:%d, " | 1426 | ubi_err("error %d while reading %d bytes from PEB %d:%d, " |
1427 | "read %zd bytes", err, len, pnum, offset, read); | 1427 | "read %zd bytes", err, len, pnum, offset, read); |
1428 | goto error; | 1428 | goto error; |