Skip to contentSkip to conversation

regulator: 88pm800: Fix checking whether num_regulator is valid

PATCH Applied Axel Lin 2 participants 2 messages Aug 4, 2013 – Aug 13, 2013 Voltage and current regulator framework

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 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.

---
 drivers/regulator/88pm800.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/regulator/88pm800.c +6 -3
index c72fe95..58e9b74 100644
@@ -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 {
Signature · 1 line
1.8.1.2
maintainer Applied
#1 lore raw
Quoted 3 lines · Axel Lin

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.

Applied, thanks.