From 8c6819120e7357925dff5a5c51147d0c5abf8117 Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Mon, 19 Dec 2022 14:19:37 +0100 Subject: [PATCH] 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 --- drivers/regulator/regulator_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/regulator_common.c b/drivers/regulator/regulator_common.c index 84ab8c6161d..f2b2e7097fd 100644 --- a/drivers/regulator/regulator_common.c +++ b/drivers/regulator/regulator_common.c @@ -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; }