Skip to content

Commit

Permalink
drivers: regulator: supported voltage consider levels bounds
Browse files Browse the repository at this point in the history
Assert regulator_supported_voltages() provides a list that takes into
account the min/max voltage levels possibly set from the secure DT.

Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
  • Loading branch information
etienne-lms authored and jforissier committed Dec 6, 2023
1 parent a7990eb commit af5b988
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/drivers/regulator/regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,19 @@ TEE_Result regulator_supported_voltages(struct regulator *regulator,

res = regulator->ops->supported_voltages(regulator, desc,
levels);
if (res == TEE_SUCCESS)
return TEE_SUCCESS;
if (res != TEE_ERROR_NOT_SUPPORTED)
return res;
} else {
*desc = &regulator->voltages_fallback.desc;
*levels = regulator->voltages_fallback.levels;
}

*desc = &regulator->voltages_fallback.desc;
*levels = regulator->voltages_fallback.levels;
assert(((*desc)->type == VOLTAGE_TYPE_FULL_LIST &&
(*levels)[0] >= regulator->min_uv && (*desc)->num_levels &&
(*levels)[(*desc)->num_levels - 1] <= regulator->max_uv) ||
((*desc)->type == VOLTAGE_TYPE_INCREMENT &&
(*levels)[0] >= regulator->min_uv &&
(*levels)[1] <= regulator->max_uv));

return TEE_SUCCESS;
}
Expand Down

0 comments on commit af5b988

Please sign in to comment.