From: Axel Lin <axel.lin@ingics.com>
To: Mark Brown <broonie@kernel.org>
Cc: "Joseph(Yossi) Hanin" <yhanin@marvell.com>,
Yi Zhang <yizhang@marvell.com>, Chao Xie <chao.xie@marvell.com>,
Liam Girdwood <lgirdwood@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] regulator: 88pm800: Fix checking whether num_regulator is valid
Date: Sun, 04 Aug 2013 09:23:28 +0800 [thread overview]
Message-ID: <1375579408.3588.1.camel@phoenix> (raw)
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
next reply other threads:[~2013-08-04 1:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-04 1:23 Axel Lin [this message]
2013-08-13 10:19 ` [PATCH] regulator: 88pm800: Fix checking whether num_regulator is valid Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1375579408.3588.1.camel@phoenix \
--to=axel.lin@ingics.com \
--cc=broonie@kernel.org \
--cc=chao.xie@marvell.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=yhanin@marvell.com \
--cc=yizhang@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.