linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Melissa Wen <melissa.srw@gmail.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Stefan Popa <stefan.popa@analog.com>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Barry Song <21cnbao@gmail.com>,
	linux-iio@vger.kernel.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com
Subject: Re: [PATCH] staging:iio:ad7150: fix threshold mode config bit
Date: Sun, 19 May 2019 11:29:52 +0100	[thread overview]
Message-ID: <20190519112952.58142fb0@archlinux> (raw)
In-Reply-To: <20190519010456.lwq7n2e6nkqa6niz@smtp.gmail.com>

On Sat, 18 May 2019 22:04:56 -0300
Melissa Wen <melissa.srw@gmail.com> wrote:

> According to the AD7150 configuration register description, bit 7 assumes
> value 1 when the threshold mode is fixed and 0 when it is adaptive,
> however, the operation that identifies this mode was considering the
> opposite values.
> 
> This patch renames the boolean variable to describe it correctly and
> properly replaces it in the places where it is used.
> 
> Fixes: 531efd6aa0991 ("staging:iio:adc:ad7150: chan_spec conv + i2c_smbus commands + drop unused poweroff timeout control.")
> Signed-off-by: Melissa Wen <melissa.srw@gmail.com>

Looks good to me.  Applied to the fixes-togreg branch of iio.git pushed out as
as testing-fixes for the autobuilders to see if they can find anything
we have missed.

Thanks,

Jonathan

> ---
>  drivers/staging/iio/cdc/ad7150.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c
> index dd7fcab8e19e..e075244c602b 100644
> --- a/drivers/staging/iio/cdc/ad7150.c
> +++ b/drivers/staging/iio/cdc/ad7150.c
> @@ -5,6 +5,7 @@
>   * Copyright 2010-2011 Analog Devices Inc.
>   */
>  
> +#include <linux/bitfield.h>
>  #include <linux/interrupt.h>
>  #include <linux/device.h>
>  #include <linux/kernel.h>
> @@ -130,7 +131,7 @@ static int ad7150_read_event_config(struct iio_dev *indio_dev,
>  {
>  	int ret;
>  	u8 threshtype;
> -	bool adaptive;
> +	bool thrfixed;
>  	struct ad7150_chip_info *chip = iio_priv(indio_dev);
>  
>  	ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG);
> @@ -138,21 +139,23 @@ static int ad7150_read_event_config(struct iio_dev *indio_dev,
>  		return ret;
>  
>  	threshtype = (ret >> 5) & 0x03;
> -	adaptive = !!(ret & 0x80);
> +
> +	/*check if threshold mode is fixed or adaptive*/
> +	thrfixed = FIELD_GET(AD7150_CFG_FIX, ret);
>  
>  	switch (type) {
>  	case IIO_EV_TYPE_MAG_ADAPTIVE:
>  		if (dir == IIO_EV_DIR_RISING)
> -			return adaptive && (threshtype == 0x1);
> -		return adaptive && (threshtype == 0x0);
> +			return !thrfixed && (threshtype == 0x1);
> +		return !thrfixed && (threshtype == 0x0);
>  	case IIO_EV_TYPE_THRESH_ADAPTIVE:
>  		if (dir == IIO_EV_DIR_RISING)
> -			return adaptive && (threshtype == 0x3);
> -		return adaptive && (threshtype == 0x2);
> +			return !thrfixed && (threshtype == 0x3);
> +		return !thrfixed && (threshtype == 0x2);
>  	case IIO_EV_TYPE_THRESH:
>  		if (dir == IIO_EV_DIR_RISING)
> -			return !adaptive && (threshtype == 0x1);
> -		return !adaptive && (threshtype == 0x0);
> +			return thrfixed && (threshtype == 0x1);
> +		return thrfixed && (threshtype == 0x0);
>  	default:
>  		break;
>  	}


  reply	other threads:[~2019-05-19 17:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-19  1:04 [PATCH] staging:iio:ad7150: fix threshold mode config bit Melissa Wen
2019-05-19 10:29 ` Jonathan Cameron [this message]
2019-05-20  9:59   ` Alexandru Ardelean

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=20190519112952.58142fb0@archlinux \
    --to=jic23@kernel.org \
    --cc=21cnbao@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-usp@googlegroups.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=melissa.srw@gmail.com \
    --cc=pmeerw@pmeerw.net \
    --cc=stefan.popa@analog.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;
as well as URLs for NNTP newsgroup(s).