Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756813AbZKUVdN (ORCPT ); Sat, 21 Nov 2009 16:33:13 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756090AbZKUVdN (ORCPT ); Sat, 21 Nov 2009 16:33:13 -0500 Received: from opensource.wolfsonmicro.com ([80.75.67.52]:46034 "EHLO opensource2.wolfsonmicro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754806AbZKUVdM (ORCPT ); Sat, 21 Nov 2009 16:33:12 -0500 References: (sfid-20091121_211852_064475_1FE64446) Message-Id: <542581F2-4F09-4771-B8C6-D81DC890ABC9@opensource.wolfsonmicro.com> From: Mark Brown To: Julia Lawall In-Reply-To: (sfid-20091121_211852_064475_1FE64446) Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Mailer: iPhone Mail (7D11) Mime-Version: 1.0 (iPhone Mail 7D11) Subject: Re: [PATCH] drivers/regulator: use PTR_ERR to get error code Date: Sat, 21 Nov 2009 21:33:25 +0000 Cc: Liam Girdwood , "linux-kernel@vger.kernel.org" , "kernel-janitors@vger.kernel.org" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1569 Lines: 52 On 21 Nov 2009, at 21:18, Julia Lawall wrote: > From: Julia Lawall > > 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: > > --- > 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(®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; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/