armv7: qca: common: smem: skip printing the partition info if it exceeds flash size

skip printing the partition info in smem if it exceeds flash size

Change-Id: Icb13b8d8f0f25f7817dfce2ee42d327081cbbfa6
Signed-off-by: Sridharan S N <quic_sridsn@quicinc.com>
This commit is contained in:
Sridharan S N 2023-08-11 15:41:28 +05:30 committed by Gerrit - the friendly Code Review server
parent 9c9cbfa2eb
commit c7c20989ab
2 changed files with 18 additions and 0 deletions

View file

@ -553,6 +553,14 @@ uint32_t get_nand_block_size(uint8_t dev_id)
return mtd->erasesize;
}
uint64_t get_nand_flash_size(uint8_t dev_id)
{
struct mtd_info *mtd;
mtd = &nand_info[dev_id];
return mtd->size;
}
#endif
/*
* get flash block size based on partition name.
@ -1167,6 +1175,10 @@ int do_smeminfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
qca_smem_flash_info_t *sfi = &qca_smem_flash_info;
int i;
uint32_t bsize;
#ifdef CONFIG_CMD_NAND
uint64_t fsize;
fsize = get_nand_flash_size(is_spi_nand_available());
#endif
#ifdef IPQ_UBI_VOL_WRITE_SUPPORT
ubi_set_rootfs_part();
#endif
@ -1218,6 +1230,11 @@ int do_smeminfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
psize = ((loff_t)p->size) * bsize;
}
#ifdef CONFIG_CMD_NAND
/* skip printing the partition that exceeds flash size */
if (((loff_t)p->start) * bsize + psize > fsize)
continue;
#endif
printf("%3d: " smem_ptn_name_fmt " 0x%08x %#16llx %#16llx\n",
i, p->name, p->attr, ((loff_t)p->start) * bsize, psize);
#ifdef IPQ_UBI_VOL_WRITE_SUPPORT

View file

@ -68,6 +68,7 @@ int smem_getpart_from_offset(uint32_t offset, uint32_t *start, uint32_t *size);
int getpart_offset_size(char *part_name, uint32_t *offset, uint32_t *size);
unsigned int smem_get_board_machtype(void);
uint32_t get_nand_block_size(uint8_t dev_id);
uint64_t get_nand_flash_size(uint8_t dev_id);
unsigned int get_which_flash_param(char *part_name);
int smem_get_build_version(char *version_name, int buf_size, int index);
int ipq_smem_get_boot_version(char *version_name, int buf_size);