Skip to content

Commit

Permalink
drivers/regulator: use PTR_ERR to get error code
Browse files Browse the repository at this point in the history
IS_ERR returns only 1 or 0.  The callsite of setup_regulators expects a
negative integer in an error case.  Thus, PTR_ERR has to be used to extract
it.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression E,E1;
@@

*E = IS_ERR(...)
 ... when != E = E1
*return E;
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
  • Loading branch information
Julia Lawall authored and Liam Girdwood committed Dec 17, 2009
1 parent b56daf1 commit d662fc8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/regulator/lp3971.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,8 @@ static int setup_regulators(struct lp3971 *lp3971,
lp3971->rdev[i] = regulator_register(&regulators[id],
lp3971->dev, pdata->regulators[i].initdata, lp3971);

err = IS_ERR(lp3971->rdev[i]);
if (err) {
if (IS_ERR(lp3971->rdev[i])) {
err = PTR_ERR(lp3971->rdev[i]);
dev_err(lp3971->dev, "regulator init failed: %d\n",
err);
goto error;
Expand Down

0 comments on commit d662fc8

Please sign in to comment.