mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chanwoo Choi <cw00.choi@samsung.com>
To: Sachin Kamat <sachin.kamat@linaro.org>
Cc: linux-kernel@vger.kernel.org, myungjoo.ham@samsung.com,
	patches@linaro.org
Subject: Re: [PATCH] extcon: Fix return value in extcon_register_interest()
Date: Tue, 25 Sep 2012 19:32:13 +0900	[thread overview]
Message-ID: <5061882D.2080804@samsung.com> (raw)
In-Reply-To: <1348556335-14686-1-git-send-email-sachin.kamat@linaro.org>

On 09/25/2012 03:58 PM, Sachin Kamat wrote:

> Return the value obtained from extcon_find_cable_index()
> instead of -ENODEV.
> 
> Fixes the following smatch info:
> drivers/extcon/extcon-class.c:478 extcon_register_interest() info:
> why not propagate 'obj->cable_index' from extcon_find_cable_index()
> instead of -19?
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> ---
>  drivers/extcon/extcon-class.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
> index 946a318..e996800 100644
> --- a/drivers/extcon/extcon-class.c
> +++ b/drivers/extcon/extcon-class.c
> @@ -475,7 +475,7 @@ int extcon_register_interest(struct extcon_specific_cable_nb *obj,
>  
>  	obj->cable_index = extcon_find_cable_index(obj->edev, cable_name);
>  	if (obj->cable_index < 0)
> -		return -ENODEV;
> +		return obj->cable_index;
>  
>  	obj->user_nb = nb;
>  


I agree.
But, if extcon_register_interest() return directly 'obj-cable_index' value
when extcon_find_cable_index() return -EINVAL, it would spoil readability
of extcon_register_interest() function. So, I think we can make it as
following
patch  a little better.

---
diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index 936580b..078e6a5 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -468,7 +468,7 @@ int extcon_register_interest(struct
extcon_specific_cable_nb *obj,

        obj->cable_index = extcon_find_cable_index(obj->edev, cable_name);
        if (obj->cable_index < 0)
-               return -ENODEV;
+               return -EINVAL;

        obj->user_nb = nb;



Thanks,
Chanwoo Choi

  parent reply	other threads:[~2012-09-25 10:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-25  6:58 Sachin Kamat
2012-09-25  9:15 ` anish singh
2012-09-25  9:20   ` Sachin Kamat
2012-09-25  9:27     ` anish singh
2012-09-25 10:32 ` Chanwoo Choi [this message]
2012-09-25 10:44   ` Sachin Kamat

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=5061882D.2080804@samsung.com \
    --to=cw00.choi@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=patches@linaro.org \
    --cc=sachin.kamat@linaro.org \
    /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®