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 for
both nand and nor cases.

Change-Id: I446a3300865fbf543b6e585f918f747a1b75a15c
Signed-off-by: Sridharan S N <quic_sridsn@quicinc.com>
This commit is contained in:
Sridharan S N 2023-09-15 15:06:27 +05:30
parent 314971f0b9
commit 1faa3fe00b
2 changed files with 45 additions and 2 deletions

View file

@ -42,6 +42,9 @@
#ifdef IPQ_UBI_VOL_WRITE_SUPPORT
static struct ubi_device *ubi;
#endif
extern unsigned int get_spi_flash_size(void);
typedef struct smem_pmic_type
{
unsigned pmic_model;
@ -1162,10 +1165,39 @@ static void print_ubi_vol_info(void)
}
#endif
int check_flash_exceed(struct smem_ptn *p, uint32_t offset, uint32_t psize) {
uint32_t fsize = 0;
qca_smem_flash_info_t *sfi = &qca_smem_flash_info;
uint32_t flash_type = sfi->flash_type;
if(flash_type == SMEM_BOOT_SPI_FLASH)
flash_type = part_which_flash(p) ? SMEM_BOOT_QSPI_NAND_FLASH :
SMEM_BOOT_SPI_FLASH;
switch (flash_type) {
case SMEM_BOOT_SPI_FLASH:
fsize = get_spi_flash_size();
break;
#ifdef CONFIG_CMD_NAND
case SMEM_BOOT_QSPI_NAND_FLASH:
fsize = nand_info[CONFIG_QPIC_NAND_NAND_INFO_IDX].size;
break;
#endif
default:
return -1;
}
if (offset + psize > fsize)
return -1;
return 0;
}
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;
int i,ret;
uint32_t bsize;
#ifdef IPQ_UBI_VOL_WRITE_SUPPORT
ubi_set_rootfs_part();
@ -1218,6 +1250,11 @@ int do_smeminfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
psize = ((loff_t)p->size) * bsize;
}
/* skip printing the partition that exceeds flash size */
ret = check_flash_exceed(p, ((loff_t)p->start) * bsize, psize);
if (ret)
continue;
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

@ -31,6 +31,12 @@
DECLARE_GLOBAL_DATA_PTR;
static u32 spi_fsize;
u32 get_spi_flash_size(void) {
return spi_fsize;
}
static void spi_flash_addr(struct spi_flash *flash, u32 addr, u8 *cmd)
{
/* cmd[0] is actual command */
@ -1324,7 +1330,7 @@ do_generic_probe:
return -EINVAL;
}
#endif
spi_fsize = flash->size;
#ifdef CONFIG_SPI_NAND
print_sf_info:
#endif