diff options
author | Axel Lin <axel.lin@ingics.com> | 2013-08-03 21:23:28 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-08-13 06:19:05 -0400 |
commit | 19c6b5440a66cba44365e511d9794e5e34ae2e4e (patch) | |
tree | 35e1a4ab74347c1cf1971754079b2d3814799cd9 | |
parent | 6625d9d297f28741d42a4ba712338a05f7464bd6 (diff) |
regulator: 88pm800: Fix checking whether num_regulator is valid
The code to check whether num_regulator is valid is wrong because it should
iterate all array entries rather than break from the for loop if
pdata->regulators[i] is NULL.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/regulator/88pm800.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/regulator/88pm800.c b/drivers/regulator/88pm800.c index b4c29b1c52a5..f42356552f21 100644 --- a/drivers/regulator/88pm800.c +++ b/drivers/regulator/88pm800.c | |||
@@ -299,10 +299,13 @@ static int pm800_regulator_probe(struct platform_device *pdev) | |||
299 | return -ENODEV; | 299 | return -ENODEV; |
300 | } | 300 | } |
301 | } else if (pdata->num_regulators) { | 301 | } else if (pdata->num_regulators) { |
302 | /* Check whether num_regulator is valid. */ | ||
303 | unsigned int count = 0; | 302 | unsigned int count = 0; |
304 | for (i = 0; pdata->regulators[i]; i++) | 303 | |
305 | count++; | 304 | /* Check whether num_regulator is valid. */ |
305 | for (i = 0; ARRAY_SIZE(pdata->regulators); i++) { | ||
306 | if (pdata->regulators[i]) | ||
307 | count++; | ||
308 | } | ||
306 | if (count != pdata->num_regulators) | 309 | if (count != pdata->num_regulators) |
307 | return -EINVAL; | 310 | return -EINVAL; |
308 | } else { | 311 | } else { |