Skip to content

Commit

Permalink
regulator: 88pm800: Fix checking whether num_regulator is valid
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Axel Lin authored and Mark Brown committed Aug 13, 2013
1 parent 6625d9d commit 19c6b54
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/regulator/88pm800.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 19c6b54

Please sign in to comment.