aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/regulator/gpio-regulator.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index ebe2b5c2e2df..2c38bea5065e 100644
--- a/drivers/regulator/gpio-regulator.c
+++ b/drivers/regulator/gpio-regulator.c
@@ -104,13 +104,15 @@ static int gpio_regulator_set_value(struct regulator_dev *dev,
104 int min, int max) 104 int min, int max)
105{ 105{
106 struct gpio_regulator_data *data = rdev_get_drvdata(dev); 106 struct gpio_regulator_data *data = rdev_get_drvdata(dev);
107 int ptr, target, state, best_val = INT_MAX; 107 int ptr, target = 0, state, best_val = INT_MAX;
108 108
109 for (ptr = 0; ptr < data->nr_states; ptr++) 109 for (ptr = 0; ptr < data->nr_states; ptr++)
110 if (data->states[ptr].value < best_val && 110 if (data->states[ptr].value < best_val &&
111 data->states[ptr].value >= min && 111 data->states[ptr].value >= min &&
112 data->states[ptr].value <= max) 112 data->states[ptr].value <= max) {
113 target = data->states[ptr].gpios; 113 target = data->states[ptr].gpios;
114 best_val = data->states[ptr].value;
115 }
114 116
115 if (best_val == INT_MAX) 117 if (best_val == INT_MAX)
116 return -EINVAL; 118 return -EINVAL;