fix(st-sdmmc2): check regulator enable/disable return

The issue was reported by Coverity [1]. The return of the functions
regulator_disable() and regulator_enable() was not checked.
If they fail, this means there is an issue either with PMIC or I2C.
The board should the stop booting with a panic().

[1] https://scan4.scan.coverity.com/reports.htm#v47771/p11439/mergedDefectId=374565

Change-Id: If5dfd5643c210e03ae4b1f4cab0168c0db89f60e
Signed-off-by: Yann Gautier <yann.gautier@st.com>
This commit is contained in:
Yann Gautier 2022-01-04 15:25:04 +01:00
parent e752fa4a4c
commit d50e7a71cb
1 changed files with 10 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2021, STMicroelectronics - All Rights Reserved
* Copyright (c) 2018-2022, STMicroelectronics - All Rights Reserved
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -157,13 +157,17 @@ static void stm32_sdmmc2_init(void)
uint32_t clock_div;
uint32_t freq = STM32MP_MMC_INIT_FREQ;
uintptr_t base = sdmmc2_params.reg_base;
int ret;
if (sdmmc2_params.max_freq != 0U) {
freq = MIN(sdmmc2_params.max_freq, freq);
}
if (sdmmc2_params.vmmc_regu != NULL) {
regulator_disable(sdmmc2_params.vmmc_regu);
ret = regulator_disable(sdmmc2_params.vmmc_regu);
if (ret < 0) {
panic();
}
}
mdelay(VCC_POWER_OFF_DELAY);
@ -173,7 +177,10 @@ static void stm32_sdmmc2_init(void)
mdelay(POWER_CYCLE_DELAY);
if (sdmmc2_params.vmmc_regu != NULL) {
regulator_enable(sdmmc2_params.vmmc_regu);
ret = regulator_enable(sdmmc2_params.vmmc_regu);
if (ret < 0) {
panic();
}
}
mdelay(VCC_POWER_ON_DELAY);