Skip to content

Commit

Permalink
regulator: twl-regulator: Simplify the code matching regulator id
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Axel Lin authored and Mark Brown committed Apr 10, 2012
1 parent 2e42a7d commit 5ade393
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/regulator/twl-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5ade393

Please sign in to comment.