* [PATCH] regulator: twl-regulator: Simplify the code matching regulator id
@ 2012-04-09 14:32 Axel Lin
2012-04-10 10:06 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2012-04-09 14:32 UTC (permalink / raw)
To: linux-kernel
Cc: Peter Ujfalusi, Rajendra Nayak, Tero Kristo, Liam Girdwood,
Mark Brown
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] regulator: twl-regulator: Simplify the code matching regulator id
2012-04-09 14:32 [PATCH] regulator: twl-regulator: Simplify the code matching regulator id Axel Lin
@ 2012-04-10 10:06 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2012-04-10 10:06 UTC (permalink / raw)
To: Axel Lin
Cc: linux-kernel, Peter Ujfalusi, Rajendra Nayak, Tero Kristo,
Liam Girdwood
[-- Attachment #1: Type: text/plain, Size: 382 bytes --]
On Mon, Apr 09, 2012 at 10:32:49PM +0800, Axel Lin wrote:
> 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.
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:[~2012-04-10 10:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-09 14:32 [PATCH] regulator: twl-regulator: Simplify the code matching regulator id Axel Lin
2012-04-10 10:06 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox