Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH] drivers/regulator: use PTR_ERR to get error code

1 view
Skip to first unread message

Julia Lawall

unread,
Nov 21, 2009, 4:18:58 PM11/21/09
to Liam Girdwood, Mark Brown, linux-...@vger.kernel.org, kernel-...@vger.kernel.org
From: Julia Lawall <ju...@diku.dk>

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 <ju...@diku.dk>

---
drivers/regulator/lp3971.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c
index 7803a32..76d08c2 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(&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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Mark Brown

unread,
Nov 21, 2009, 4:33:41 PM11/21/09
to Julia Lawall, Liam Girdwood, linux-...@vger.kernel.org, kernel-...@vger.kernel.org
On 21 Nov 2009, at 21:18, Julia Lawall <ju...@diku.dk> wrote:

> From: Julia Lawall <ju...@diku.dk>
>
> 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 <ju...@diku.dk>

Acked-by: <bro...@opensource.wolfsonmicro.com>

Liam Girdwood

unread,
Nov 23, 2009, 6:01:41 AM11/23/09
to Julia Lawall, Mark Brown, linux-...@vger.kernel.org, kernel-...@vger.kernel.org
On Sat, 2009-11-21 at 22:18 +0100, Julia Lawall wrote:
> From: Julia Lawall <ju...@diku.dk>
>
> 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 <ju...@diku.dk>
>

Applied.

Thanks

Liam

0 new messages