devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Brian Masney <masneyb@onstation.org>, linux-iio@vger.kernel.org
Cc: devel@driverdev.osuosl.org, devicetree@vger.kernel.org,
	lars@metafoo.de, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org, robh+dt@kernel.org,
	Jon Brenner <Jon.Brenner@ams.com>,
	pmeerw@pmeerw.net, knaack.h@gmx.de, Mark.Rutland@arm.com
Subject: Re: [PATCH 02/10] staging: iio: tsl2583: check for error code from i2c_smbus_read_byte()
Date: Sun, 30 Oct 2016 17:49:15 +0000	[thread overview]
Message-ID: <f8b404c3-9b2a-e3fc-64e1-cb3d2a1ce1e4@kernel.org> (raw)
In-Reply-To: <1477648821-3786-3-git-send-email-masneyb@onstation.org>

On 28/10/16 11:00, Brian Masney wrote:
> taos_i2c_read() and taos_als_calibrate() does not check to see if the
> value returned by i2c_smbus_read_byte() was an error code. This patch
> adds the appropriate error handling.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders
to play with it.

Also Cc'd Jon on basis he might want to run his eye of these.
> ---
>  drivers/staging/iio/light/tsl2583.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
> index fd4b6ef..35c1696 100644
> --- a/drivers/staging/iio/light/tsl2583.c
> +++ b/drivers/staging/iio/light/tsl2583.c
> @@ -171,7 +171,14 @@ taos_i2c_read(struct i2c_client *client, u8 reg, u8 *val, unsigned int len)
>  			return ret;
>  		}
>  		/* read the data */
> -		*val = i2c_smbus_read_byte(client);
> +		ret = i2c_smbus_read_byte(client);
> +		if (ret < 0) {
> +			dev_err(&client->dev,
> +				"%s failed to read byte after writing to register %x\n",
> +				__func__, reg);
> +			return ret;
> +		}
> +		*val = ret;
>  		val++;
>  		reg++;
>  	}
> @@ -355,6 +362,13 @@ static int taos_als_calibrate(struct iio_dev *indio_dev)
>  	}
>  
>  	reg_val = i2c_smbus_read_byte(chip->client);
> +	if (reg_val < 0) {
> +		dev_err(&chip->client->dev,
> +			"%s failed to read after writing to the CNTRL register\n",
> +			__func__);
> +		return ret;
> +	}
> +
>  	if ((reg_val & (TSL258X_CNTL_ADC_ENBL | TSL258X_CNTL_PWR_ON))
>  			!= (TSL258X_CNTL_ADC_ENBL | TSL258X_CNTL_PWR_ON)) {
>  		dev_err(&chip->client->dev,
> @@ -371,6 +385,12 @@ static int taos_als_calibrate(struct iio_dev *indio_dev)
>  		return ret;
>  	}
>  	reg_val = i2c_smbus_read_byte(chip->client);
> +	if (reg_val < 0) {
> +		dev_err(&chip->client->dev,
> +			"%s failed to read after writing to the STATUS register\n",
> +			__func__);
> +		return ret;
> +	}
>  
>  	if ((reg_val & TSL258X_STA_ADC_VALID) != TSL258X_STA_ADC_VALID) {
>  		dev_err(&chip->client->dev,
> 

  reply	other threads:[~2016-10-30 17:49 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-28 10:00 [PATCH 00/10] staging: iio: tsl2583: staging cleanups Brian Masney
2016-10-28 10:00 ` [PATCH 01/10] staging: iio: tsl2583: add of_match table for device tree support Brian Masney
2016-10-30 17:43   ` Jonathan Cameron
     [not found]     ` <246d8513-3505-31cd-4cfa-4f2c2e9266d8-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-10-30 17:44       ` Jonathan Cameron
2016-10-31  6:06   ` Rob Herring
2016-10-28 10:00 ` [PATCH 02/10] staging: iio: tsl2583: check for error code from i2c_smbus_read_byte() Brian Masney
2016-10-30 17:49   ` Jonathan Cameron [this message]
2016-10-28 10:00 ` [PATCH 03/10] staging: iio: tsl2583: return proper error code instead of -1 Brian Masney
     [not found]   ` <1477648821-3786-4-git-send-email-masneyb-1iNe0GrtECGEi8DpZVb4nw@public.gmane.org>
2016-10-30 17:50     ` Jonathan Cameron
2016-10-28 10:00 ` [PATCH 04/10] staging: iio: tsl2583: remove redundant power_state sysfs attribute Brian Masney
2016-10-30 17:51   ` Jonathan Cameron
2016-10-28 10:00 ` [PATCH 05/10] staging: iio: tsl2583: check return values from taos_chip_{on, off} Brian Masney
     [not found]   ` <1477648821-3786-6-git-send-email-masneyb-1iNe0GrtECGEi8DpZVb4nw@public.gmane.org>
2016-10-30 17:54     ` [PATCH 05/10] staging: iio: tsl2583: check return values from taos_chip_{on,off} Jonathan Cameron
2016-10-28 10:00 ` [PATCH 06/10] staging: iio: tsl2583: convert to use iio_chan_spec and {read, write}_raw Brian Masney
     [not found]   ` <1477648821-3786-7-git-send-email-masneyb-1iNe0GrtECGEi8DpZVb4nw@public.gmane.org>
2016-10-30 18:04     ` [PATCH 06/10] staging: iio: tsl2583: convert to use iio_chan_spec and {read,write}_raw Jonathan Cameron
2016-10-28 10:00 ` [PATCH 07/10] staging: iio: tsl2583: convert illuminance0_calibscale sysfs attr to use iio_chan_spec Brian Masney
     [not found]   ` <1477648821-3786-8-git-send-email-masneyb-1iNe0GrtECGEi8DpZVb4nw@public.gmane.org>
2016-10-30 18:37     ` Jonathan Cameron
     [not found]       ` <a0fc532f-f034-d817-00f6-a28ec60daf6a-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-10-30 20:04         ` Brian Masney
     [not found]           ` <20161030200409.GA14808-+HJwobWzVoXN2ZRhSsNpr3G1qET/BF4J@public.gmane.org>
2016-10-30 20:29             ` Jonathan Cameron
2016-10-28 10:00 ` [PATCH 08/10] staging: iio: tsl2583: use IIO_*_ATTR* macros to create sysfs entries Brian Masney
     [not found]   ` <1477648821-3786-9-git-send-email-masneyb-1iNe0GrtECGEi8DpZVb4nw@public.gmane.org>
2016-10-30 18:38     ` Jonathan Cameron
2016-10-28 10:00 ` [PATCH 09/10] staging: iio: tsl2583: add error code to sysfs store functions Brian Masney
2016-10-30 18:39   ` Jonathan Cameron
2016-10-28 10:00 ` [PATCH 10/10] staging: iio: tsl2583: add locking to sysfs attributes Brian Masney
2016-10-30 18:43   ` 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=f8b404c3-9b2a-e3fc-64e1-cb3d2a1ce1e4@kernel.org \
    --to=jic23@kernel.org \
    --cc=Jon.Brenner@ams.com \
    --cc=Mark.Rutland@arm.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masneyb@onstation.org \
    --cc=pmeerw@pmeerw.net \
    --cc=robh+dt@kernel.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;
as well as URLs for NNTP newsgroup(s).