@@ -143,7 +143,7 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset,
143143
144144 err = paranoid_check_not_bad (ubi , pnum );
145145 if (err )
146- return err > 0 ? - EINVAL : err ;
146+ return err ;
147147
148148 addr = (loff_t )pnum * ubi -> peb_size + offset ;
149149retry :
@@ -236,12 +236,12 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
236236
237237 err = paranoid_check_not_bad (ubi , pnum );
238238 if (err )
239- return err > 0 ? - EINVAL : err ;
239+ return err ;
240240
241241 /* The area we are writing to has to contain all 0xFF bytes */
242242 err = ubi_dbg_check_all_ff (ubi , pnum , offset , len );
243243 if (err )
244- return err > 0 ? - EINVAL : err ;
244+ return err ;
245245
246246 if (offset >= ubi -> leb_start ) {
247247 /*
@@ -250,10 +250,10 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
250250 */
251251 err = paranoid_check_peb_ec_hdr (ubi , pnum );
252252 if (err )
253- return err > 0 ? - EINVAL : err ;
253+ return err ;
254254 err = paranoid_check_peb_vid_hdr (ubi , pnum );
255255 if (err )
256- return err > 0 ? - EINVAL : err ;
256+ return err ;
257257 }
258258
259259 if (ubi_dbg_is_write_failure ()) {
@@ -348,7 +348,7 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum)
348348
349349 err = ubi_dbg_check_all_ff (ubi , pnum , 0 , ubi -> peb_size );
350350 if (err )
351- return err > 0 ? - EINVAL : err ;
351+ return err ;
352352
353353 if (ubi_dbg_is_erase_failure () && !err ) {
354354 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)
542542
543543 err = paranoid_check_not_bad (ubi , pnum );
544544 if (err != 0 )
545- return err > 0 ? - EINVAL : err ;
545+ return err ;
546546
547547 if (ubi -> ro_mode ) {
548548 ubi_err ("read-only mode" );
@@ -819,7 +819,7 @@ int ubi_io_write_ec_hdr(struct ubi_device *ubi, int pnum,
819819
820820 err = paranoid_check_ec_hdr (ubi , pnum , ec_hdr );
821821 if (err )
822- return - EINVAL ;
822+ return err ;
823823
824824 err = ubi_io_write (ubi , ec_hdr , pnum , 0 , ubi -> ec_hdr_alsize );
825825 return err ;
@@ -1083,7 +1083,7 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
10831083
10841084 err = paranoid_check_peb_ec_hdr (ubi , pnum );
10851085 if (err )
1086- return err > 0 ? - EINVAL : err ;
1086+ return err ;
10871087
10881088 vid_hdr -> magic = cpu_to_be32 (UBI_VID_HDR_MAGIC );
10891089 vid_hdr -> version = UBI_VERSION ;
@@ -1092,7 +1092,7 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
10921092
10931093 err = paranoid_check_vid_hdr (ubi , pnum , vid_hdr );
10941094 if (err )
1095- return - EINVAL ;
1095+ return err ;
10961096
10971097 p = (char * )vid_hdr - ubi -> vid_hdr_shift ;
10981098 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,
11071107 * @ubi: UBI device description object
11081108 * @pnum: physical eraseblock number to check
11091109 *
1110- * This function returns zero if the physical eraseblock is good, a positive
1111- * number if it is bad and a negative error code if an error occurred.
1110+ * This function returns zero if the physical eraseblock is good, %-EINVAL if
1111+ * it is bad and a negative error code if an error occurred.
11121112 */
11131113static int paranoid_check_not_bad (const struct ubi_device * ubi , int pnum )
11141114{
@@ -1120,7 +1120,7 @@ static int paranoid_check_not_bad(const struct ubi_device *ubi, int pnum)
11201120
11211121 ubi_err ("paranoid check failed for PEB %d" , pnum );
11221122 ubi_dbg_dump_stack ();
1123- return err ;
1123+ return err > 0 ? - EINVAL : err ;
11241124}
11251125
11261126/**
@@ -1130,7 +1130,7 @@ static int paranoid_check_not_bad(const struct ubi_device *ubi, int pnum)
11301130 * @ec_hdr: the erase counter header to check
11311131 *
11321132 * This function returns zero if the erase counter header contains valid
1133- * values, and %1 if not.
1133+ * values, and %-EINVAL if not.
11341134 */
11351135static int paranoid_check_ec_hdr (const struct ubi_device * ubi , int pnum ,
11361136 const struct ubi_ec_hdr * ec_hdr )
@@ -1156,16 +1156,16 @@ static int paranoid_check_ec_hdr(const struct ubi_device *ubi, int pnum,
11561156fail :
11571157 ubi_dbg_dump_ec_hdr (ec_hdr );
11581158 ubi_dbg_dump_stack ();
1159- return 1 ;
1159+ return - EINVAL ;
11601160}
11611161
11621162/**
11631163 * paranoid_check_peb_ec_hdr - check erase counter header.
11641164 * @ubi: UBI device description object
11651165 * @pnum: the physical eraseblock number to check
11661166 *
1167- * This function returns zero if the erase counter header is all right, %1 if
1168- * not, and a negative error code if an error occurred.
1167+ * This function returns zero if the erase counter header is all right and and
1168+ * a negative error code if not or if an error occurred.
11691169 */
11701170static int paranoid_check_peb_ec_hdr (const struct ubi_device * ubi , int pnum )
11711171{
@@ -1188,7 +1188,7 @@ static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum)
11881188 ubi_err ("paranoid check failed for PEB %d" , pnum );
11891189 ubi_dbg_dump_ec_hdr (ec_hdr );
11901190 ubi_dbg_dump_stack ();
1191- err = 1 ;
1191+ err = - EINVAL ;
11921192 goto exit ;
11931193 }
11941194
@@ -1206,7 +1206,7 @@ static int paranoid_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum)
12061206 * @vid_hdr: the volume identifier header to check
12071207 *
12081208 * This function returns zero if the volume identifier header is all right, and
1209- * %1 if not.
1209+ * %-EINVAL if not.
12101210 */
12111211static int paranoid_check_vid_hdr (const struct ubi_device * ubi , int pnum ,
12121212 const struct ubi_vid_hdr * vid_hdr )
@@ -1233,7 +1233,7 @@ static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum,
12331233 ubi_err ("paranoid check failed for PEB %d" , pnum );
12341234 ubi_dbg_dump_vid_hdr (vid_hdr );
12351235 ubi_dbg_dump_stack ();
1236- return 1 ;
1236+ return - EINVAL ;
12371237
12381238}
12391239
@@ -1243,7 +1243,7 @@ static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum,
12431243 * @pnum: the physical eraseblock number to check
12441244 *
12451245 * 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.
12471247 */
12481248static int paranoid_check_peb_vid_hdr (const struct ubi_device * ubi , int pnum )
12491249{
@@ -1270,7 +1270,7 @@ static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum)
12701270 ubi_err ("paranoid check failed for PEB %d" , pnum );
12711271 ubi_dbg_dump_vid_hdr (vid_hdr );
12721272 ubi_dbg_dump_stack ();
1273- err = 1 ;
1273+ err = - EINVAL ;
12741274 goto exit ;
12751275 }
12761276
@@ -1289,8 +1289,8 @@ static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum)
12891289 * @len: the length of the region to check
12901290 *
12911291 * 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
1293- * code if an error occurred.
1292+ * @offset of the physical eraseblock @pnum, and a negative error code if not
1293+ * or if an error occurred.
12941294 */
12951295int ubi_dbg_check_all_ff (struct ubi_device * ubi , int pnum , int offset , int len )
12961296{
@@ -1321,7 +1321,7 @@ int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
13211321 ubi_msg ("hex dump of the %d-%d region" , offset , offset + len );
13221322 print_hex_dump (KERN_DEBUG , "" , DUMP_PREFIX_OFFSET , 32 , 1 ,
13231323 ubi -> dbg_peb_buf , len , 1 );
1324- err = 1 ;
1324+ err = - EINVAL ;
13251325error :
13261326 ubi_dbg_dump_stack ();
13271327 mutex_unlock (& ubi -> dbg_buf_mutex );
0 commit comments