diff --git a/drivers/mtd/afs.c b/drivers/mtd/afs.c index d09280ae12bd..a1eea50ce180 100644 --- a/drivers/mtd/afs.c +++ b/drivers/mtd/afs.c @@ -87,25 +87,23 @@ afs_read_footer_v1(struct mtd_info *mtd, u_int *img_start, u_int *iis_start, return ret; } - ret = 1; - /* * Does it contain the magic number? */ if (fs.signature != AFSV1_FOOTER_MAGIC) - ret = 0; + return 0; /* * Check the checksum. */ if (word_sum(&fs, sizeof(fs) / sizeof(u32)) != 0xffffffff) - ret = 0; + return 0; /* * Don't touch the SIB. */ if (fs.type == 2) - ret = 0; + return 0; *iis_start = fs.image_info_base & mask; *img_start = fs.image_start & mask; @@ -115,16 +113,16 @@ afs_read_footer_v1(struct mtd_info *mtd, u_int *img_start, u_int *iis_start, * be located after the footer structure. */ if (*iis_start >= ptr) - ret = 0; + return 0; /* * Check the start of this image. The image * data can not be located after this block. */ if (*img_start > off) - ret = 0; + return 0; - return ret; + return 1; } static int @@ -190,18 +188,17 @@ static int parse_afs_partitions(struct mtd_info *mtd, ret = afs_read_footer_v1(mtd, &img_ptr, &iis_ptr, off, mask); if (ret < 0) break; - if (ret == 0) - continue; + if (ret) { + ret = afs_read_iis_v1(mtd, &iis, iis_ptr); + if (ret < 0) + break; + if (ret == 0) + continue; - ret = afs_read_iis_v1(mtd, &iis, iis_ptr); - if (ret < 0) - break; - if (ret == 0) - continue; - - sz += sizeof(struct mtd_partition); - sz += strlen(iis.name) + 1; - idx += 1; + sz += sizeof(struct mtd_partition); + sz += strlen(iis.name) + 1; + idx += 1; + } } if (!sz)