From patchwork Sun Jul 31 11:09:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 9253345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4B93960865 for ; Sun, 31 Jul 2016 11:09:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C9E4283F2 for ; Sun, 31 Jul 2016 11:09:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F6E72845D; Sun, 31 Jul 2016 11:09:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C0D828448 for ; Sun, 31 Jul 2016 11:09:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753120AbcGaLJY (ORCPT ); Sun, 31 Jul 2016 07:09:24 -0400 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:43926 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750748AbcGaLJX (ORCPT ); Sun, 31 Jul 2016 07:09:23 -0400 Received: from valkosipuli.retiisi.org.uk (valkosipuli.retiisi.org.uk [IPv6:2001:1bc8:1a6:d3d5::80:2]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id BEFE960096; Sun, 31 Jul 2016 14:09:15 +0300 (EEST) Received: by valkosipuli.retiisi.org.uk (Postfix, from userid 1000) id A3B582032C; Sun, 31 Jul 2016 14:09:15 +0300 (EEST) Date: Sun, 31 Jul 2016 14:09:15 +0300 From: Sakari Ailus To: Amitoj Kaur Chawla Cc: mchehab@osg.samsung.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, julia.lawall@lip6.fr Subject: Re: [PATCH] i2c: Modify error handling Message-ID: <20160731110915.GE3243@valkosipuli.retiisi.org.uk> References: <20160731035800.GA4576@amitoj-Inspiron-3542> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160731035800.GA4576@amitoj-Inspiron-3542> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Amitoj, On Sun, Jul 31, 2016 at 09:28:00AM +0530, Amitoj Kaur Chawla wrote: > devm_gpiod_get returns an ERR_PTR on error so a null check is > incorrect and an IS_ERR check is required. > > The Coccinelle semantic patch used to make this change is as follows: > @@ > expression e; > statement S; > @@ > > e = devm_gpiod_get(...); > if( > - !e > + IS_ERR(e) > ) > { > ... > - return ...; > + return PTR_ERR(e); > } > > Signed-off-by: Amitoj Kaur Chawla > --- > drivers/media/i2c/adp1653.c | 4 ++-- In this exact case, the issue has been fixed by similar patch in media-tree master branch. You likely used another branch for preparing this patch. Nevertheless, thank you for the patch --- this kind of cleanups are always much appreciated. commit 806f8ffa8a0fa9a6f0481c5648c27aa51d10fdc6 Author: Vladimir Zapolskiy Date: Mon Mar 7 15:39:32 2016 -0300 [media] media: i2c/adp1653: fix check of devm_gpiod_get() error code The devm_gpiod_get() function returns either a valid pointer to struct gpio_desc or ERR_PTR() error value, check for NULL is bogus. Signed-off-by: Vladimir Zapolskiy Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c index fb7ed73..9e1731c 100644 --- a/drivers/media/i2c/adp1653.c +++ b/drivers/media/i2c/adp1653.c @@ -466,9 +466,9 @@ static int adp1653_of_init(struct i2c_client *client, of_node_put(child); pd->enable_gpio = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW); - if (!pd->enable_gpio) { + if (IS_ERR(pd->enable_gpio)) { dev_err(&client->dev, "Error getting GPIO\n"); - return -EINVAL; + return PTR_ERR(pd->enable_gpio); } return 0;