mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2025-12-10 07:44:53 +01:00
ipq40xx: Replace sprintf with snprintf
Change-Id: I2f1d31901ce4c4b15dad9e25265597518d4b4122 Signed-off-by: Sasirekaa Madhesu <smadhesu@codeaurora.org>
This commit is contained in:
parent
ce563c425c
commit
c5ffa908c0
10 changed files with 33 additions and 25 deletions
|
|
@ -554,26 +554,29 @@ uint32_t qca_smem_get_flash_block_size(void)
|
|||
return qca_smem_flash_info.flash_block_size;
|
||||
}
|
||||
|
||||
void qca_smem_part_to_mtdparts(char *mtdid)
|
||||
void qca_smem_part_to_mtdparts(char *mtdid, int len)
|
||||
{
|
||||
qca_smem_flash_info_t *sfi = &qca_smem_flash_info;
|
||||
int i, l;
|
||||
int i, ret;
|
||||
int device_id = 0;
|
||||
char *part = mtdid, *unit;
|
||||
int init = 0;
|
||||
uint32_t bsize;
|
||||
|
||||
part += sprintf(part, "%s:", mtdid);
|
||||
ret = snprintf(part, len, "%s:", mtdid);
|
||||
part += ret;
|
||||
len -= ret;
|
||||
|
||||
for (i = 0; i < smem_ptable.len; i++) {
|
||||
for (i = 0; i < smem_ptable.len && len > 0; i++) {
|
||||
struct smem_ptn *p = &smem_ptable.parts[i];
|
||||
loff_t psize;
|
||||
bsize = get_part_block_size(p, sfi);
|
||||
|
||||
if (part_which_flash(p) && init == 0) {
|
||||
device_id = is_spi_nand_available();
|
||||
l = sprintf(part, ";nand%d:", device_id);
|
||||
part += l;
|
||||
ret = snprintf(part, len, ";nand%d:", device_id);
|
||||
part += ret;
|
||||
len -= ret;
|
||||
init = 1;
|
||||
}
|
||||
if (p->size == (~0u)) {
|
||||
|
|
@ -597,9 +600,10 @@ void qca_smem_part_to_mtdparts(char *mtdid)
|
|||
unit = "@";
|
||||
}
|
||||
|
||||
l = sprintf(part, "%lld%s0x%llx(%s),", psize, unit,
|
||||
ret = snprintf(part, len, "%lld%s0x%llx(%s),", psize, unit,
|
||||
((loff_t)p->start) * bsize, p->name);
|
||||
part += l;
|
||||
part += ret;
|
||||
len -= ret;
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ int smem_bootconfig_info(void);
|
|||
unsigned int get_smem_spi_addr_len(void);
|
||||
unsigned int get_rootfs_active_partition(void);
|
||||
unsigned int get_mibib_active_partition(void);
|
||||
void qca_smem_part_to_mtdparts(char *mtdid);
|
||||
void qca_smem_part_to_mtdparts(char *mtdid, int len);
|
||||
int ipq_smem_get_socinfo_cpu_type(uint32_t *cpu_type);
|
||||
int ipq_smem_get_socinfo_version(uint32_t *version);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -113,12 +113,12 @@ void set_ethmac_addr(void)
|
|||
* dts entry for the ethernet entries, which in turn
|
||||
* will be picked up by the HLOS driver
|
||||
*/
|
||||
sprintf(mac, "%x:%x:%x:%x:%x:%x",
|
||||
snprintf(mac, sizeof(mac), "%x:%x:%x:%x:%x:%x",
|
||||
mac_addr[0], mac_addr[1],
|
||||
mac_addr[2], mac_addr[3],
|
||||
mac_addr[4], mac_addr[5]);
|
||||
setenv(ethaddr, mac);
|
||||
}
|
||||
sprintf(ethaddr, "eth%daddr", (i + 1));
|
||||
snprintf(ethaddr, sizeof(ethaddr), "eth%daddr", (i + 1));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,6 +258,7 @@ int ft_board_setup(void *blob, bd_t *bd)
|
|||
u64 memory_size = gd->ram_size;
|
||||
char *mtdparts = NULL;
|
||||
char parts_str[4096];
|
||||
int len = sizeof(parts_str);
|
||||
qca_smem_flash_info_t *sfi = &qca_smem_flash_info;
|
||||
struct flash_node_info nodes[] = {
|
||||
{ "qcom,msm-nand", MTD_DEV_TYPE_NAND, 0 },
|
||||
|
|
@ -276,20 +277,20 @@ int ft_board_setup(void *blob, bd_t *bd)
|
|||
ipq_fdt_mem_rsvd_fixup(blob);
|
||||
#endif
|
||||
if (sfi->flash_type == SMEM_BOOT_NAND_FLASH) {
|
||||
sprintf(parts_str, "mtdparts=nand0");
|
||||
snprintf(parts_str, sizeof(parts_str), "mtdparts=nand0");
|
||||
} else if (sfi->flash_type == SMEM_BOOT_SPI_FLASH) {
|
||||
/* Patch NOR block size and density for
|
||||
* generic probe case */
|
||||
ipq_fdt_fixup_spi_nor_params(blob);
|
||||
sprintf(parts_str, "mtdparts=" QCA_SPI_NOR_DEVICE);
|
||||
snprintf(parts_str,sizeof(parts_str), "mtdparts=" QCA_SPI_NOR_DEVICE);
|
||||
|
||||
if (sfi->flash_secondary_type == SMEM_BOOT_NAND_FLASH)
|
||||
sprintf(parts_str,
|
||||
snprintf(parts_str, sizeof(parts_str),
|
||||
"mtdparts=nand0:64M@0(rootfs);nand1");
|
||||
}
|
||||
mtdparts = parts_str;
|
||||
if (mtdparts) {
|
||||
qca_smem_part_to_mtdparts(mtdparts);
|
||||
qca_smem_part_to_mtdparts(mtdparts,len);
|
||||
if (mtdparts[0] != '\0') {
|
||||
debug("mtdparts = %s\n", mtdparts);
|
||||
setenv("mtdparts", mtdparts);
|
||||
|
|
|
|||
|
|
@ -279,9 +279,9 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
|
|||
- info->start;
|
||||
info->blksz = dev_desc->blksz;
|
||||
|
||||
sprintf((char *)info->name, "%s",
|
||||
snprintf((char *)info->name, sizeof(info->name), "%s",
|
||||
print_efiname(&gpt_pte[part - 1]));
|
||||
sprintf((char *)info->type, "U-Boot");
|
||||
snprintf((char *)info->type, sizeof(info->type), "U-Boot");
|
||||
info->bootable = is_bootable(&gpt_pte[part - 1]);
|
||||
#ifdef CONFIG_PARTITION_UUIDS
|
||||
uuid_bin_to_str(gpt_pte[part - 1].unique_partition_guid.b, info->uuid,
|
||||
|
|
|
|||
|
|
@ -1480,14 +1480,16 @@ static int mmc_startup(struct mmc *mmc)
|
|||
#if !defined(CONFIG_SPL_BUILD) || \
|
||||
(defined(CONFIG_SPL_LIBCOMMON_SUPPORT) && \
|
||||
!defined(CONFIG_USE_TINY_PRINTF))
|
||||
sprintf(mmc->block_dev.vendor, "Man %06x Snr %04x%04x",
|
||||
mmc->cid[0] >> 24, (mmc->cid[2] & 0xffff),
|
||||
snprintf(mmc->block_dev.vendor, sizeof(mmc->block_dev.vendor),
|
||||
"Man %06x Snr %04x%04x", mmc->cid[0] >> 24, (mmc->cid[2] & 0xffff),
|
||||
(mmc->cid[3] >> 16) & 0xffff);
|
||||
sprintf(mmc->block_dev.product, "%c%c%c%c%c%c", mmc->cid[0] & 0xff,
|
||||
snprintf(mmc->block_dev.product, sizeof(mmc->block_dev.product),
|
||||
"%c%c%c%c%c%c", mmc->cid[0] & 0xff,
|
||||
(mmc->cid[1] >> 24), (mmc->cid[1] >> 16) & 0xff,
|
||||
(mmc->cid[1] >> 8) & 0xff, mmc->cid[1] & 0xff,
|
||||
(mmc->cid[2] >> 24) & 0xff);
|
||||
sprintf(mmc->block_dev.revision, "%d.%d", (mmc->cid[2] >> 20) & 0xf,
|
||||
snprintf(mmc->block_dev.revision, sizeof(mmc->block_dev.revision),
|
||||
"%d.%d", (mmc->cid[2] >> 20) & 0xf,
|
||||
(mmc->cid[2] >> 16) & 0xf);
|
||||
#else
|
||||
mmc->block_dev.vendor[0] = 0;
|
||||
|
|
|
|||
|
|
@ -897,7 +897,7 @@ int ipq40xx_edma_init(ipq40xx_edma_board_cfg_t *edma_cfg)
|
|||
dev[i]->enetaddr[4],
|
||||
dev[i]->enetaddr[5]);
|
||||
|
||||
sprintf(dev[i]->name, "eth%d", i);
|
||||
snprintf(dev[i]->name, sizeof(dev[i]->name), "eth%d", i);
|
||||
ipq40xx_edma_dev[i]->dev = dev[i];
|
||||
ipq40xx_edma_dev[i]->mac_unit = edma_cfg->unit;
|
||||
ipq40xx_edma_dev[i]->c_info = c_info[i];
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ int ipq40xx_sw_mdio_init(const char *name)
|
|||
bus->read = ipq40xx_phy_read;
|
||||
bus->write = ipq40xx_phy_write;
|
||||
bus->reset = NULL;
|
||||
sprintf(bus->name, name);
|
||||
snprintf(bus->name, MDIO_NAME_LEN, name);
|
||||
return mdio_register(bus);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ int ipq_sw_mdio_init(const char *name)
|
|||
bus->read = ipq_phy_read;
|
||||
bus->write = ipq_phy_write;
|
||||
bus->reset = NULL;
|
||||
sprintf(bus->name, name);
|
||||
snprintf(bus->name, MDIO_NAME_LEN, name);
|
||||
return mdio_register(bus);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,8 @@ static int fit_handle_file(struct image_tool_params *params)
|
|||
params->imagefile, params->cmdname);
|
||||
return (EXIT_FAILURE);
|
||||
}
|
||||
sprintf (tmpfile, "%s%s", params->imagefile, MKIMAGE_TMPFILE_SUFFIX);
|
||||
snprintf (tmpfile, MKIMAGE_MAX_TMPFILE_LEN, "%s%s", params->imagefile,
|
||||
MKIMAGE_TMPFILE_SUFFIX);
|
||||
|
||||
/* We either compile the source file, or use the existing FIT image */
|
||||
if (params->datafile) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue