lkml.org 
[lkml]   [2013]   [Aug]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] regulator: 88pm800: Fix checking whether num_regulator is valid
From
Date
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>
---
drivers/regulator/88pm800.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/88pm800.c b/drivers/regulator/88pm800.c
index c72fe95..58e9b74 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 {
--
1.8.1.2




\
 
 \ /
  Last update: 2013-08-04 03:41    [W:0.038 / U:0.316 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site