public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: 88pm800: Fix checking whether num_regulator is valid
@ 2013-08-04  1:23 Axel Lin
  2013-08-13 10:19 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2013-08-04  1:23 UTC (permalink / raw)
  To: Mark Brown
  Cc: Joseph(Yossi) Hanin, Yi Zhang, Chao Xie, Liam Girdwood,
	linux-kernel

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




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] regulator: 88pm800: Fix checking whether num_regulator is valid
  2013-08-04  1:23 [PATCH] regulator: 88pm800: Fix checking whether num_regulator is valid Axel Lin
@ 2013-08-13 10:19 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2013-08-13 10:19 UTC (permalink / raw)
  To: Axel Lin
  Cc: Joseph(Yossi) Hanin, Yi Zhang, Chao Xie, Liam Girdwood,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 253 bytes --]

On Sun, Aug 04, 2013 at 09:23:28AM +0800, Axel Lin wrote:
> 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.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-13 10:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-04  1:23 [PATCH] regulator: 88pm800: Fix checking whether num_regulator is valid Axel Lin
2013-08-13 10:19 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox