diff options
author | Axel Lin <axel.lin@ingics.com> | 2013-08-04 03:23:28 +0200 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-08-13 12:19:05 +0200 |
commit | 19c6b5440a66cba44365e511d9794e5e34ae2e4e (patch) | |
tree | 35e1a4ab74347c1cf1971754079b2d3814799cd9 /drivers | |
parent | regulator: 88pm800: Add missing n_voltages setting for bucks (diff) | |
download | linux-19c6b5440a66cba44365e511d9794e5e34ae2e4e.tar.xz linux-19c6b5440a66cba44365e511d9794e5e34ae2e4e.zip |
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>
Diffstat (limited to 'drivers')
-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) return -ENODEV; } } else if (pdata->num_regulators) { - /* Check whether num_regulator is valid. */ unsigned int count = 0; - for (i = 0; pdata->regulators[i]; i++) - count++; + + /* Check whether num_regulator is valid. */ + for (i = 0; ARRAY_SIZE(pdata->regulators); i++) { + if (pdata->regulators[i]) + count++; + } if (count != pdata->num_regulators) return -EINVAL; } else { |