summaryrefslogtreecommitdiffstats
path: root/drivers/regulator/twl-regulator.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-04-09 16:32:49 +0200
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-10 12:04:26 +0200
commit5ade39358f0244a0672860766eed92e8c908b805 (patch)
tree6a8146beb7a0e542b2115de1579badd95d4f69fa /drivers/regulator/twl-regulator.c
parentregulator: max8998: Use simple equation to get selector (diff)
downloadlinux-5ade39358f0244a0672860766eed92e8c908b805.tar.xz
linux-5ade39358f0244a0672860766eed92e8c908b805.zip
regulator: twl-regulator: Simplify the code matching regulator id
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> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/twl-regulator.c')
-rw-r--r--drivers/regulator/twl-regulator.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 9cf6f59d27bc..88bc32bc31a0 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -1189,10 +1189,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;