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.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 8aa51e7a6a7..a2501299a67 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -143,7 +143,7 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset,
143 143
144 err = paranoid_check_not_bad(ubi, pnum); 144 err = paranoid_check_not_bad(ubi, pnum);
145 if (err) 145 if (err)
146 return err > 0 ? -EINVAL : err; 146 return err;
147 147
148 addr = (loff_t)pnum * ubi->peb_size + offset; 148 addr = (loff_t)pnum * ubi->peb_size + offset;
149retry: 149retry:
@@ -236,12 +236,12 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
236 236
237 err = paranoid_check_not_bad(ubi, pnum); 237 err = paranoid_check_not_bad(ubi, pnum);
238 if (err) 238 if (err)
239 return err > 0 ? -EINVAL : err; 239 return err;
240 240
241 /* The area we are writing to has to contain all 0xFF bytes */ 241 /* The area we are writing to has to contain all 0xFF bytes */
242 err = ubi_dbg_check_all_ff(ubi, pnum, offset, len); 242 err = ubi_dbg_check_all_ff(ubi, pnum, offset, len);
243 if (err) 243 if (err)
244 return err > 0 ? -EINVAL : err; 244 return err;
245 245
246 if (offset >= ubi->leb_start) { 246 if (offset >= ubi->leb_start) {
247 /* 247 /*
@@ -250,10 +250,10 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
250 */ 250 */
251 err = paranoid_check_peb_ec_hdr(ubi, pnum); 251 err = paranoid_check_peb_ec_hdr(ubi, pnum);
252 if (err) 252 if (err)
253 return err > 0 ? -EINVAL : err; 253 return err;
254 err = paranoid_check_peb_vid_hdr(ubi, pnum); 254 err = paranoid_check_peb_vid_hdr(ubi, pnum);
255 if (err) 255 if (err)
256 return err > 0 ? -EINVAL : err; 256 return err;
257 } 257 }
258 258
259 if (ubi_dbg_is_write_failure()) { 259 if (ubi_dbg_is_write_failure()) {
@@ -348,7 +348,7 @@ retry:
348 348
349 err = ubi_dbg_check_all_ff(ubi, pnum, 0, ubi->peb_size); 349 err = ubi_dbg_check_all_ff(ubi, pnum, 0, ubi->peb_size);
350 if (err) 350 if (err)
351 return err > 0 ? -EINVAL : err; 351 return err;
352 352
353 if (ubi_dbg_is_erase_failure() && !err) { 353 if (ubi_dbg_is_erase_failure() && !err) {
354 dbg_err("cannot erase PEB %d (emulated)", pnum); 354 dbg_err("cannot erase PEB %d (emulated)", pnum);
@@ -542,7 +542,7 @@ int ubi_io_sync_erase(struct ubi_device *ubi, int pnum, int torture)
542 542
543 err = paranoid_check_not_bad(ubi, pnum); 543 err = paranoid_check_not_bad(ubi, pnum);
544 if (err != 0) 544 if (err != 0)
545 return err > 0 ? -EINVAL : err; 545 return err;
546 546
547 if (ubi->ro_mode) { 547 if (ubi->ro_mode) {
548 ubi_err("read-only mode"); 548 ubi_err("read-only mode");
@@ -819,7 +819,7 @@ int ubi_io_write_ec_hdr(struct ubi_device *ubi, int pnum,
819 819
820 err = paranoid_check_ec_hdr(ubi, pnum, ec_hdr); 820 err = paranoid_check_ec_hdr(ubi, pnum, ec_hdr);
821 if (err) 821 if (err)
822 return -EINVAL; 822 return err;
823 823
824 err = ubi_io_write(ubi, ec_hdr, pnum, 0, ubi->ec_hdr_alsize); 824 err = ubi_io_write(ubi, ec_hdr, pnum, 0, ubi->ec_hdr_alsize);
825 return err; 825 return err;
@@ -1083,7 +1083,7 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
1083 1083
1084 err = paranoid_check_peb_ec_hdr(ubi, pnum); 1084 err = paranoid_check_peb_ec_hdr(ubi, pnum);
1085 if (err) 1085 if (err)
1086 return err > 0 ? -EINVAL : err; 1086 return err;
1087 1087
1088 vid_hdr->magic = cpu_to_be32(UBI_VID_HDR_MAGIC); 1088 vid_hdr->magic = cpu_to_be32(UBI_VID_HDR_MAGIC);
1089 vid_hdr->version = UBI_VERSION; 1089 vid_hdr->version = UBI_VERSION;
@@ -1092,7 +1092,7 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
1092 1092
1093 err = paranoid_check_vid_hdr(ubi, pnum, vid_hdr); 1093 err = paranoid_check_vid_hdr(ubi, pnum, vid_hdr);
1094 if (err) 1094 if (err)
1095 return -EINVAL; 1095 return err;
1096 1096
1097 p = (char *)vid_hdr - ubi->vid_hdr_shift; 1097 p = (char *)vid_hdr - ubi->vid_hdr_shift;
1098 err = ubi_io_write(ubi, p, pnum, ubi->vid_hdr_aloffset, 1098 err = ubi_io_write(ubi, p, pnum, ubi->vid_hdr_aloffset,
@@ -1107,8 +1107,8 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
1107 * @ubi: UBI device description object 1107 * @ubi: UBI device description object
1108 * @pnum: physical eraseblock number to check 1108 * @pnum: physical eraseblock number to check
1109 * 1109 *
1110 * This function returns zero if the physical eraseblock is good, a positive 1110 * This function returns zero if the physical eraseblock is good, %-EINVAL if
1111 * number if it is bad and a negative error code if an error occurred. 1111 * it is bad and a negative error code if an error occurred.
1112 */ 1112 */
1113static int paranoid_check_not_bad(const struct ubi_device *ubi, int pnum) 1113static int paranoid_check_not_bad(const struct ubi_device *ubi, int pnum)
1114{ 1114{
@@ -1120,7 +1120,7 @@ static int paranoid_check_not_bad(const struct ubi_device *ubi, int pnum)
1120 1120
1121 ubi_err("paranoid check failed for PEB %d", pnum); 1121 ubi_err("paranoid check failed for PEB %d", pnum);
1122 ubi_dbg_dump_stack(); 1122 ubi_dbg_dump_stack();
1123 return err; 1123 return err > 0 ? -EINVAL : err;
1124} 1124}
1125 1125
1126/** 1126/**
@@ -1130,7 +1130,7 @@ static int paranoid_check_not_bad(const struct ubi_device *ubi, int pnum)
1130 * @ec_hdr: the erase counter header to check 1130 * @ec_hdr: the erase counter header to check
1131 * 1131 *
1132 * This function returns zero if the erase counter header contains valid 1132 * This function returns zero if the erase counter header contains valid
1133 * values, and %1 if not. 1133 * values, and %-EINVAL if not.
1134 */ 1134 */
1135static int paranoid_check_ec_hdr(const struct ubi_device *ubi, int pnum, 1135static int paranoid_check_ec_hdr(const struct ubi_device *ubi, int pnum,
1136 const struct ubi_ec_hdr *ec_hdr) 1136 const struct ubi_ec_hdr *ec_hdr)
@@ -1156,7 +1156,7 @@ static int paranoid_check_ec_hdr(const struct ubi_device *ubi, int pnum,
1156fail: 1156fail:
1157 ubi_dbg_dump_ec_hdr(ec_hdr); 1157 ubi_dbg_dump_ec_hdr(ec_hdr);
1158 ubi_dbg_dump_stack(); 1158 ubi_dbg_dump_stack();
1159 return 1; 1159 return -EINVAL;
1160} 1160}
1161 1161
1162/** 1162/**
@@ -1164,8 +1164,8 @@ fail:
1164 * @ubi: UBI device description object 1164 * @ubi: UBI device description object
1165 * @pnum: the physical eraseblock number to check 1165 * @pnum: the physical eraseblock number to check
1166 * 1166 *
1167 * This function returns zero if the erase counter header is all right, %1 if 1167 * This function returns zero if the erase counter header is all right and and
1168 * not, and a negative error code if an error occurred. 1168 * a negative error code if not or if an error occurred.
1169 */ 1169 */
1170static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum) 1170static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum)
1171{ 1171{
@@ -1188,7 +1188,7 @@ static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum)
1188 ubi_err("paranoid check failed for PEB %d", pnum); 1188 ubi_err("paranoid check failed for PEB %d", pnum);
1189 ubi_dbg_dump_ec_hdr(ec_hdr); 1189 ubi_dbg_dump_ec_hdr(ec_hdr);
1190 ubi_dbg_dump_stack(); 1190 ubi_dbg_dump_stack();
1191 err = 1; 1191 err = -EINVAL;
1192 goto exit; 1192 goto exit;
1193 } 1193 }
1194 1194
@@ -1206,7 +1206,7 @@ exit:
1206 * @vid_hdr: the volume identifier header to check 1206 * @vid_hdr: the volume identifier header to check
1207 * 1207 *
1208 * This function returns zero if the volume identifier header is all right, and 1208 * This function returns zero if the volume identifier header is all right, and
1209 * %1 if not. 1209 * %-EINVAL if not.
1210 */ 1210 */
1211static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum, 1211static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum,
1212 const struct ubi_vid_hdr *vid_hdr) 1212 const struct ubi_vid_hdr *vid_hdr)
@@ -1233,7 +1233,7 @@ fail:
1233 ubi_err("paranoid check failed for PEB %d", pnum); 1233 ubi_err("paranoid check failed for PEB %d", pnum);
1234 ubi_dbg_dump_vid_hdr(vid_hdr); 1234 ubi_dbg_dump_vid_hdr(vid_hdr);
1235 ubi_dbg_dump_stack(); 1235 ubi_dbg_dump_stack();
1236 return 1; 1236 return -EINVAL;
1237 1237
1238} 1238}
1239 1239
@@ -1243,7 +1243,7 @@ fail:
1243 * @pnum: the physical eraseblock number to check 1243 * @pnum: the physical eraseblock number to check
1244 * 1244 *
1245 * This function returns zero if the volume identifier header is all right, 1245 * This function returns zero if the volume identifier header is all right,
1246 * %1 if not, and a negative error code if an error occurred. 1246 * and a negative error code if not or if an error occurred.
1247 */ 1247 */
1248static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum) 1248static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum)
1249{ 1249{
@@ -1270,7 +1270,7 @@ static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum)
1270 ubi_err("paranoid check failed for PEB %d", pnum); 1270 ubi_err("paranoid check failed for PEB %d", pnum);
1271 ubi_dbg_dump_vid_hdr(vid_hdr); 1271 ubi_dbg_dump_vid_hdr(vid_hdr);
1272 ubi_dbg_dump_stack(); 1272 ubi_dbg_dump_stack();
1273 err = 1; 1273 err = -EINVAL;
1274 goto exit; 1274 goto exit;
1275 } 1275 }
1276 1276
@@ -1289,8 +1289,8 @@ exit:
1289 * @len: the length of the region to check 1289 * @len: the length of the region to check
1290 * 1290 *
1291 * This function returns zero if only 0xFF bytes are present at offset 1291 * This function returns zero if only 0xFF bytes are present at offset
1292 * @offset of the physical eraseblock @pnum, %1 if not, and a negative error 1292 * @offset of the physical eraseblock @pnum, and a negative error code if not
1293 * code if an error occurred. 1293 * or if an error occurred.
1294 */ 1294 */
1295int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len) 1295int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
1296{ 1296{
@@ -1321,7 +1321,7 @@ fail:
1321 ubi_msg("hex dump of the %d-%d region", offset, offset + len); 1321 ubi_msg("hex dump of the %d-%d region", offset, offset + len);
1322 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, 1322 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
1323 ubi->dbg_peb_buf, len, 1); 1323 ubi->dbg_peb_buf, len, 1);
1324 err = 1; 1324 err = -EINVAL;
1325error: 1325error:
1326 ubi_dbg_dump_stack(); 1326 ubi_dbg_dump_stack();
1327 mutex_unlock(&ubi->dbg_buf_mutex); 1327 mutex_unlock(&ubi->dbg_buf_mutex);