From 145eb479a4e9f2c32f10d8afdfea3393395dea9b Mon Sep 17 00:00:00 2001 From: Jacob Garber Date: Wed, 18 Sep 2019 22:47:55 -0600 Subject: soc/qualcomm/ipq40xx: Remove unnecessary allocation The bus variable doesn't live outside the scope of this function, and is only used as a convenient way for passing the pointers to all the sub-functions, so it doesn't need to be allocated. Put it on the stack instead. A similar fix for ipq806x was done in 0f33d8c29a (soc/qualcomm/ipq806x: Remove unnecessary allocation). Change-Id: Ibb1129b92e38a105e100f59e03d107de340b925c Signed-off-by: Jacob Garber Found-by: Coverity CID 1294801 Reviewed-on: https://review.coreboot.org/c/coreboot/+/35464 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- src/soc/qualcomm/ipq40xx/lcc.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/soc/qualcomm/ipq40xx/lcc.c b/src/soc/qualcomm/ipq40xx/lcc.c index b2b4c4524f..9a6c9116ec 100644 --- a/src/soc/qualcomm/ipq40xx/lcc.c +++ b/src/soc/qualcomm/ipq40xx/lcc.c @@ -287,29 +287,21 @@ static int lcc_enable_mi2s(IpqLccClocks *bus) int audio_clock_config(unsigned frequency) { - IpqLccClocks *bus = malloc(sizeof(*bus)); - - if (!bus) { - printk(BIOS_ERR, "%s: failed to allocate bus structure\n", - __func__); + IpqLccClocks bus = { + .gcc_apcs_regs = (void *)(MSM_GCC_BASE + GCC_PLL_APCS_REG), + .lcc_pll0_regs = (void *)(MSM_LPASS_LCC_BASE + LCC_PLL0_MODE_REG), + .lcc_ahbix_regs = (void *)(MSM_LPASS_LCC_BASE + LCC_AHBIX_NS_REG), + .lcc_mi2s_regs = (void *)(MSM_LPASS_LCC_BASE + LCC_MI2S_NS_REG), + .lcc_pll_regs = (void *)(MSM_LPASS_LCC_BASE + LCC_PLL_PCLK_REG), + }; + + if (lcc_init_enable_pll0(&bus)) return 1; - } - - bus->gcc_apcs_regs = (void *)(MSM_GCC_BASE + GCC_PLL_APCS_REG); - bus->lcc_pll0_regs = (void *)(MSM_LPASS_LCC_BASE + LCC_PLL0_MODE_REG); - bus->lcc_ahbix_regs = (void *)(MSM_LPASS_LCC_BASE + LCC_AHBIX_NS_REG); - bus->lcc_mi2s_regs = (void *)(MSM_LPASS_LCC_BASE + LCC_MI2S_NS_REG); - bus->lcc_pll_regs = (void *)(MSM_LPASS_LCC_BASE + LCC_PLL_PCLK_REG); - - - if (lcc_init_enable_pll0(bus)) - return 1; - if (lcc_init_enable_ahbix(bus)) + if (lcc_init_enable_ahbix(&bus)) return 1; - if (lcc_init_mi2s(bus, frequency)) + if (lcc_init_mi2s(&bus, frequency)) return 1; - - if (lcc_enable_mi2s(bus)) + if (lcc_enable_mi2s(&bus)) return 1; return 0; -- cgit v1.2.3