drivers: regulator: fix set_voltage limits check
Only voltage ranges out of the allowed range have to be skipped.
@@ -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;
}
