drivers: regulator: fix set_voltage limits check
Only voltage ranges out of the allowed range have to be skipped. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
56c85ccd59
commit
8c6819120e
1 changed files with 2 additions and 2 deletions
|
@ -137,7 +137,7 @@ bool regulator_is_supported_voltage(const struct device *dev, int32_t min_uv,
|
|||
unsigned int volt_cnt;
|
||||
|
||||
/* voltage may not be allowed, even if supported */
|
||||
if ((min_uv < config->min_uv) || (max_uv > config->max_uv)) {
|
||||
if ((min_uv > config->max_uv) || (max_uv < config->min_uv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ int regulator_set_voltage(const struct device *dev, int32_t min_uv,
|
|||
}
|
||||
|
||||
/* voltage may not be allowed, even if supported */
|
||||
if ((min_uv < config->min_uv) || (max_uv > config->max_uv)) {
|
||||
if ((min_uv > config->max_uv) || (max_uv < config->min_uv)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue