Skip to content

Commit

Permalink
plat-stm32mp1: scmi_server: fix case when regulator state is unchanged
Browse files Browse the repository at this point in the history
Fixes the return value when an SCMI regulator is already in
the expected state. Prior this change the implementation returned
SCMI_GENERIC_ERROR instead of SCMI_SUCCESS.

Changes also the SCMI return code in case of failure from
SCMI_GENERIC_ERROR to SCMI_INVALID_PARAMETERS when the requested
state is not one of the 2 supported SCMi voltage domain states
supported (SCMI_VOLTAGE_DOMAIN_CONFIG_ARCH_ON or
SCMI_VOLTAGE_DOMAIN_CONFIG_ARCH_OFF).

Fixes: 23e2006 ("plat-stm32mp1: scmi_server: use registered regulators")
Signed-off-by: Etienne Carriere <[email protected]>
  • Loading branch information
etienne-lms committed Nov 15, 2023
1 parent 17a6690 commit 5f56067
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions core/arch/arm/plat-stm32mp1/scmi_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,26 +875,28 @@ int32_t plat_scmi_voltd_set_config(unsigned int channel_id,
return SCMI_NOT_FOUND;

if (voltd->regulator) {
TEE_Result res = TEE_ERROR_GENERIC;
switch (config) {
case SCMI_VOLTAGE_DOMAIN_CONFIG_ARCH_ON:
if (!voltd->state) {
if (regulator_enable(voltd->regulator))
return SCMI_GENERIC_ERROR;

if (config == SCMI_VOLTAGE_DOMAIN_CONFIG_ARCH_ON &&
!voltd->state) {
res = regulator_enable(voltd->regulator);
if (!res)
voltd->state = true;
} else if (config == SCMI_VOLTAGE_DOMAIN_CONFIG_ARCH_OFF &&
voltd->state) {
res = regulator_disable(voltd->regulator);
if (!res)
}
break;
case SCMI_VOLTAGE_DOMAIN_CONFIG_ARCH_OFF:
if (voltd->state) {
if (regulator_disable(voltd->regulator))
return SCMI_GENERIC_ERROR;

voltd->state = false;
} else {
res = TEE_ERROR_GENERIC;
}
break;
default:
return SCMI_INVALID_PARAMETERS;
}

if (res)
return SCMI_GENERIC_ERROR;
else
return SCMI_SUCCESS;
return SCMI_SUCCESS;
}

switch (voltd->priv_dev) {
Expand Down

0 comments on commit 5f56067

Please sign in to comment.