linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	Peter Meerwald <pmeerw@pmeerw.net>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	Dan Murphy <dmurphy@ti.com>,
	linux-iio@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] iio: tsl4531: fix error handling in tsl4531_check_id()
Date: Sat, 15 Aug 2015 15:35:36 +0100	[thread overview]
Message-ID: <55CF4E38.70506@kernel.org> (raw)
In-Reply-To: <20150813202027.GA4385@mwanda>

On 13/08/15 21:21, Dan Carpenter wrote:
> The caller expect us to return zero if the ID doesn't match.  Negative
> error codes are treated as success.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Whilst this does indeed fix the issue, I think I'd prefer changing the call
site to deal with the error properly. Could return -ENODEV directly
from the function to make the code cleaner.  Not quite the minimal fix
but only slightly worse and avoids reworking it again to pass the
error up correctly as it should do (after the fix is in place).

Jonathan
> 
> diff --git a/drivers/iio/light/tsl4531.c b/drivers/iio/light/tsl4531.c
> index 2697918..730fd2b 100644
> --- a/drivers/iio/light/tsl4531.c
> +++ b/drivers/iio/light/tsl4531.c
> @@ -151,7 +151,7 @@ static int tsl4531_check_id(struct i2c_client *client)
>  {
>  	int ret = i2c_smbus_read_byte_data(client, TSL4531_ID);
>  	if (ret < 0)
> -		return ret;
> +		return 0;
>  
>  	switch (ret >> TSL4531_ID_SHIFT) {
>  	case TSL45311_ID:
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


  parent reply	other threads:[~2015-08-15 14:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-13 20:21 [patch] iio: tsl4531: fix error handling in tsl4531_check_id() Dan Carpenter
2015-08-13 21:03 ` Dan Murphy
2015-08-15 14:36   ` Jonathan Cameron
2015-08-15 14:35 ` Jonathan Cameron [this message]
2015-08-17 14:38   ` [patch v2] " Dan Carpenter
2015-08-17 14:51     ` Peter Meerwald
2015-08-17 15:05     ` Dan Murphy
2015-08-18  9:16       ` [patch v3] " Dan Carpenter
2015-08-31 15:30         ` Jonathan Cameron

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=55CF4E38.70506@kernel.org \
    --to=jic23@kernel.org \
    --cc=dan.carpenter@oracle.com \
    --cc=dmurphy@ti.com \
    --cc=k.kozlowski@samsung.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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;
as well as URLs for NNTP newsgroup(s).