mirror of https://lore.kernel.org/lkml/
 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, gregkh@linuxfoundation.org,
	lars@metafoo.de, pmeerw@pmeerw.net, knaack.h@gmx.de,
	linux-kernel@vger.kernel.org, Jon.Brenner@ams.com
Subject: Re: [PATCH 2/9] staging: iio: tsl2583: removed unused code from device probing
Date: Sun, 6 Nov 2016 11:46:50 +0000	[thread overview]
Message-ID: <1ebfaec1-fe18-5692-9fae-b4161c118c4c@kernel.org> (raw)
In-Reply-To: <1478177780-28699-3-git-send-email-masneyb@onstation.org>

On 03/11/16 12:56, Brian Masney wrote:
> taos_probe() queries the all of the sensor's registers and loads all of
> the values into a buffer stored on the stack. Only the chip ID register
> was actually used. Change the probe function to just query the chip ID
> register on the device.
> 
> Verified that the driver still functions correctly using a TSL2581
> hooked up to a Raspberry Pi 2.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Huh. I'm embarrassed that I didn't notice this bit of silliness in the
original reviews :)

Applied to the togreg branch of iio.git

Thanks,

Jonathan
> ---
>  drivers/staging/iio/light/tsl2583.c | 37 +++++++++++++------------------------
>  1 file changed, 13 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
> index a3a9095..388440b 100644
> --- a/drivers/staging/iio/light/tsl2583.c
> +++ b/drivers/staging/iio/light/tsl2583.c
> @@ -31,8 +31,6 @@
>  #include <linux/iio/iio.h>
>  #include <linux/iio/sysfs.h>
>  
> -#define TSL258X_MAX_DEVICE_REGS		32
> -
>  /* Triton register offsets */
>  #define	TSL258X_REG_MAX		8
>  
> @@ -66,6 +64,9 @@
>  /* Lux calculation constants */
>  #define	TSL258X_LUX_CALC_OVER_FLOW		65535
>  
> +#define TSL2583_CHIP_ID			0x90
> +#define TSL2583_CHIP_ID_MASK		0xf0
> +
>  enum {
>  	TSL258X_CHIP_UNKNOWN = 0,
>  	TSL258X_CHIP_WORKING = 1,
> @@ -607,12 +608,6 @@ static const struct attribute_group tsl2583_attribute_group = {
>  	.attrs = sysfs_attrs_ctrl,
>  };
>  
> -/* Use the default register values to identify the Taos device */
> -static int taos_tsl258x_device(unsigned char *bufp)
> -{
> -	return ((bufp[TSL258X_CHIPID] & 0xf0) == 0x90);
> -}
> -
>  static const struct iio_chan_spec tsl2583_channels[] = {
>  	{
>  		.type = IIO_LIGHT,
> @@ -777,8 +772,7 @@ static const struct iio_info tsl2583_info = {
>  static int taos_probe(struct i2c_client *clientp,
>  		      const struct i2c_device_id *idp)
>  {
> -	int i, ret;
> -	unsigned char buf[TSL258X_MAX_DEVICE_REGS];
> +	int ret;
>  	struct tsl2583_chip *chip;
>  	struct iio_dev *indio_dev;
>  
> @@ -799,22 +793,17 @@ static int taos_probe(struct i2c_client *clientp,
>  	chip->taos_chip_status = TSL258X_CHIP_UNKNOWN;
>  	memcpy(chip->taos_config, taos_config, sizeof(chip->taos_config));
>  
> -	for (i = 0; i < TSL258X_MAX_DEVICE_REGS; i++) {
> -		ret = i2c_smbus_read_byte_data(clientp,
> -					       (TSL258X_CMD_REG |
> -						(TSL258X_CNTRL + i)));
> -		if (ret < 0) {
> -			dev_err(&clientp->dev,
> -				"i2c_smbus_read_byte from reg failed in taos_probe(), err = %d\n",
> -				ret);
> -			return ret;
> -		}
> -		buf[i] = ret;
> +	ret = i2c_smbus_read_byte_data(clientp,
> +				       TSL258X_CMD_REG | TSL258X_CHIPID);
> +	if (ret < 0) {
> +		dev_err(&clientp->dev,
> +			"%s failed to read the chip ID register\n", __func__);
> +		return ret;
>  	}
>  
> -	if (!taos_tsl258x_device(buf)) {
> -		dev_info(&clientp->dev,
> -			 "i2c device found but does not match expected id in taos_probe()\n");
> +	if ((ret & TSL2583_CHIP_ID_MASK) != TSL2583_CHIP_ID) {
> +		dev_info(&clientp->dev, "%s received an unknown chip ID %x\n",
> +			 __func__, ret);
>  		return -EINVAL;
>  	}
>  
> 

  reply	other threads:[~2016-11-06 11:46 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-03 12:56 [PATCH 0/9] staging: iio: tsl2583: i2c cleanups Brian Masney
2016-11-03 12:56 ` [PATCH 1/9] staging: iio: tsl2583: i2c_smbus_write_byte() / i2c_smbus_read_byte() migration Brian Masney
2016-11-06 11:33   ` Jonathan Cameron
2016-11-06 11:35   ` Jonathan Cameron
2016-11-03 12:56 ` [PATCH 2/9] staging: iio: tsl2583: removed unused code from device probing Brian Masney
2016-11-06 11:46   ` Jonathan Cameron [this message]
2016-11-03 12:56 ` [PATCH 3/9] staging: iio: tsl2583: fixed ordering of comments Brian Masney
2016-11-06 11:48   ` Jonathan Cameron
2016-11-03 12:56 ` [PATCH 4/9] staging: iio: tsl2583: remove redundant power off sequence in taos_chip_on() Brian Masney
2016-11-06 11:51   ` Jonathan Cameron
2016-11-03 12:56 ` [PATCH 5/9] staging: iio: tsl2583: don't shutdown chip when updating the lux table Brian Masney
2016-11-06 11:53   ` Jonathan Cameron
2016-11-03 12:56 ` [PATCH 6/9] staging: iio: tsl2583: remove redudant i2c call in taos_als_calibrate() Brian Masney
2016-11-06 11:54   ` Jonathan Cameron
2016-11-03 12:56 ` [PATCH 7/9] staging: iio: tsl2583: fix issue with changes to calibscale and int_time not being set on the chip Brian Masney
2016-11-06 12:03   ` Jonathan Cameron
2016-11-06 14:23     ` Brian Masney
2016-11-06 17:55       ` Jonathan Cameron
2016-11-03 12:56 ` [PATCH 8/9] staging: iio: tsl2583: check if chip is suspended in in_illuminance_calibrate_store Brian Masney
2016-11-06 12:04   ` Jonathan Cameron
2016-11-03 12:56 ` [PATCH 9/9] staging: iio: tsl2583: remove redundant write to the control register in taos_probe() Brian Masney
2016-11-06 12:05   ` 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=1ebfaec1-fe18-5692-9fae-b4161c118c4c@kernel.org \
    --to=jic23@kernel.org \
    --cc=Jon.Brenner@ams.com \
    --cc=devel@driverdev.osuosl.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 \
    /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

Powered by JetHome