From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: Dimitri Fedrau <dima.fedrau@gmail.com>
Cc: Li peiyu <579lpy@gmail.com>, Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] iio: humidity: hdc3020: fix hysteresis representation
Date: Thu, 6 Jun 2024 16:34:39 +0200 [thread overview]
Message-ID: <6481f8ab-5082-4952-a29c-075a57239472@gmail.com> (raw)
In-Reply-To: <20240605192136.38146-1-dima.fedrau@gmail.com>
On 05/06/2024 21:21, Dimitri Fedrau wrote:
> According to the ABI docs hysteresis values are represented as offsets to
> threshold values. Current implementation represents hysteresis values as
> absolute values which is wrong. Nevertheless the device stores them as
> absolute values and the datasheet refers to them as clear thresholds. Fix
> the reading and writing of hysteresis values by including thresholds into
> calculations. Hysteresis values that result in threshold clear values
> that are out of limits will be truncated.
>
> To check that the threshold clear values are correct, registers are read
> out using i2ctransfer and the corresponding temperature and relative
> humidity thresholds are calculated using the formulas in the datasheet.
>
> Fixes: 3ad0e7e5f0cb ("iio: humidity: hdc3020: add threshold events support")
> Signed-off-by: Dimitri Fedrau <dima.fedrau@gmail.com>
> ---
>
> Changes in V3:
> - Add missing changes
> - Remove math.h, already included in math64.h
> - Drop range comments
> - Fix typo devide divide
> - Add empty line before return in hdc3020_write_thresh
> - Keep hysteresis value when changing the threshold
>
> ---
> drivers/iio/humidity/hdc3020.c | 325 +++++++++++++++++++++++++--------
> 1 file changed, 249 insertions(+), 76 deletions(-)
>
> diff --git a/drivers/iio/humidity/hdc3020.c b/drivers/iio/humidity/hdc3020.c
> index cdc4789213ba..cf00999b826d 100644
> --- a/drivers/iio/humidity/hdc3020.c
> +++ b/drivers/iio/humidity/hdc3020.c
> @@ -19,6 +19,7 @@
> #include <linux/i2c.h>
> #include <linux/init.h>
> #include <linux/interrupt.h>
> +#include <linux/math64.h>
> #include <linux/module.h>
> #include <linux/mutex.h>
> #include <linux/pm.h>
> @@ -66,8 +67,10 @@
>
> #define HDC3020_CRC8_POLYNOMIAL 0x31
>
> -#define HDC3020_MIN_TEMP -40
> -#define HDC3020_MAX_TEMP 125
> +#define HDC3020_MIN_TEMP_MICRO -39872968
> +#define HDC3020_MAX_TEMP_MICRO 124875639
> +#define HDC3020_MAX_TEMP_HYST_MICRO 164748607
> +#define HDC3020_MAX_HUM_MICRO 99220264
>
> struct hdc3020_data {
> struct i2c_client *client;
> @@ -368,6 +371,105 @@ static int hdc3020_write_raw(struct iio_dev *indio_dev,
> return -EINVAL;
> }
>
Nit: "thresh" instead of "tresh" (applies to several lines of your patch).
> +static int hdc3020_tresh_get_temp(u16 thresh)
> +{
> + int temp;
> +
> + /*
Reviewed-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
next prev parent reply other threads:[~2024-06-06 14:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 19:21 [PATCH v3] iio: humidity: hdc3020: fix hysteresis representation Dimitri Fedrau
2024-06-06 14:34 ` Javier Carrasco [this message]
2024-06-09 10:05 ` Jonathan Cameron
2024-06-09 11:18 ` Dimitri Fedrau
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=6481f8ab-5082-4952-a29c-075a57239472@gmail.com \
--to=javier.carrasco.cruz@gmail.com \
--cc=579lpy@gmail.com \
--cc=dima.fedrau@gmail.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.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