mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: Amitoj Kaur Chawla <amitoj1606@gmail.com>
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
Date: Sun, 31 Jul 2016 14:09:15 +0300	[thread overview]
Message-ID: <20160731110915.GE3243@valkosipuli.retiisi.org.uk> (raw)
In-Reply-To: <20160731035800.GA4576@amitoj-Inspiron-3542>

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 <amitoj1606@gmail.com>
> ---
>  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 <vz@mleia.com>
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 <vz@mleia.com>
    Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

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;

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

      reply	other threads:[~2016-07-31 11:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-31  3:58 Amitoj Kaur Chawla
2016-07-31 11:09 ` Sakari Ailus [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160731110915.GE3243@valkosipuli.retiisi.org.uk \
    --to=sakari.ailus@iki.fi \
    --cc=amitoj1606@gmail.com \
    --cc=julia.lawall@lip6.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@osg.samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®