Skip to content

Commit

Permalink
drivers: regulator: split regulator_supported_voltages() assertions
Browse files Browse the repository at this point in the history
Split assertions in regulator_supported_voltages() to ease debugging,
providing a better indication of which condition is not fulfilled.

Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
  • Loading branch information
etienne-lms committed Apr 10, 2024
1 parent 9b3005e commit f34c4e9
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions core/drivers/regulator/regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,16 @@ TEE_Result regulator_supported_voltages(struct regulator *regulator,
return res;
}

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));
if ((*desc)->type == VOLTAGE_TYPE_FULL_LIST) {
assert((*desc)->num_levels);
assert((*levels)[0] >= regulator->min_uv);
assert((*levels)[(*desc)->num_levels - 1] <= regulator->max_uv);
} else if ((*desc)->type == VOLTAGE_TYPE_INCREMENT) {
assert((*levels)[0] >= regulator->min_uv);
assert((*levels)[1] <= regulator->max_uv);
} else {
assert(0);
}

return TEE_SUCCESS;
}
Expand Down

0 comments on commit f34c4e9

Please sign in to comment.