From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>,
Rajendra Nayak <rnayak@ti.com>, Tero Kristo <t-kristo@ti.com>,
Liam Girdwood <lrg@ti.com>,
Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH] regulator: twl-regulator: Simplify the code matching regulator id
Date: Mon, 09 Apr 2012 22:32:49 +0800 [thread overview]
Message-ID: <1333981969.9076.1.camel@phoenix> (raw)
This patch makes the code easier to read.
Also add checking the case when no desc id is matched. This is required because
if no desc id is matched, the poiner info is pointed to twl_of_match[i].data
which may be not NULL. Checking info is NULL or not latter does not catch the
error.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/twl-regulator.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 9cdfc38..964946f 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -1207,10 +1207,12 @@ static int __devinit twlreg_probe(struct platform_device *pdev)
initdata = pdev->dev.platform_data;
for (i = 0, info = NULL; i < ARRAY_SIZE(twl_of_match); i++) {
info = twl_of_match[i].data;
- if (!info || info->desc.id != id)
- continue;
- break;
+ if (info && info->desc.id == id)
+ break;
}
+ if (i == ARRAY_SIZE(twl_of_match))
+ return -ENODEV;
+
drvdata = initdata->driver_data;
if (!drvdata)
return -EINVAL;
--
1.7.5.4
next reply other threads:[~2012-04-09 14:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-09 14:32 Axel Lin [this message]
2012-04-10 10:06 ` [PATCH] regulator: twl-regulator: Simplify the code matching regulator id 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=1333981969.9076.1.camel@phoenix \
--to=axel.lin@gmail.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@ti.com \
--cc=peter.ujfalusi@ti.com \
--cc=rnayak@ti.com \
--cc=t-kristo@ti.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox