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>
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 {