From: Julia Lawall Date: Sat, 21 Nov 2009 21:18:44 +0000 (+0100) Subject: drivers/regulator: use PTR_ERR to get error code X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d662fc82dc745ee24d518b0fde5a6a19758092ec;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git drivers/regulator: use PTR_ERR to get error code 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/) // @@ expression E,E1; @@ *E = IS_ERR(...) ... when != E = E1 *return E; // Signed-off-by: Julia Lawall Acked-by: Signed-off-by: Liam Girdwood --- diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c index 7803a320543b..76d08c282f9c 100644 --- a/drivers/regulator/lp3971.c +++ b/drivers/regulator/lp3971.c @@ -446,8 +446,8 @@ static int setup_regulators(struct lp3971 *lp3971, lp3971->rdev[i] = regulator_register(®ulators[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;