public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dimitri Fedrau <dima.fedrau@gmail.com>
To: Javier Carrasco <javier.carrasco.cruz@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] iio: humidity: hdc3020: fix hysteresis representation
Date: Fri, 24 May 2024 10:09:48 +0200	[thread overview]
Message-ID: <20240524080948.GA560140@debian> (raw)
In-Reply-To: <17adc0d0-55c1-4608-a4c0-93f9911296f8@gmail.com>

Am Thu, May 23, 2024 at 05:45:34PM +0200 schrieb Javier Carrasco:
> On 23/05/2024 16:28, Dimitri Fedrau wrote:
> > Am Thu, May 23, 2024 at 04:12:37PM +0200 schrieb Javier Carrasco:
> >> Hi Dimitri, a few comments inline.
> >>
> >> On 23/05/2024 13:43, 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.
> >>>
> >>> Fixes: 3ad0e7e5f0cb ("iio: humidity: hdc3020: add threshold events support")
> >>> Signed-off-by: Dimitri Fedrau <dima.fedrau@gmail.com>
> >>> ---
> >>>
> >>> Since absolute values are used on the device, the hysteresis values are
> >>> influenced by setting thresholds. Is this behavior in line with the ABI docs ?
> >>> It can be fixed by readjusting the threshold clear value whenever setting
> >>> thresholds to have the same hysteresis value as before. See some example below:
> >>>
> >>> # echo 25 > /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_value
> >>> # cat /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_value
> >>> 24.727626459
> >>> # echo 5 > /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_hysteresis
> >>> # cat /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_hysteresis
> >>> 5.127031357
> >>> # echo 35 > /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_value
> >>> # cat /sys/bus/iio/devices/iio\:device0/events/in_temp_thresh_rising_hysteresis
> >>> 15.381094071
> >>>
> 
> > Hi Javier,
> > 
> > thanks for reviewing so quickly. Do you think I should correct the clear
> > threshold values once I changed the threshold. I have an example
> > provided where I set the threshold and hysteresis. After setting the
> > threshold again the hysteresis value also changes.
> > 
> > Dimitri
> 
> I am not sure if I got that right. Did the rising hysteresis change its
> value automatically from ~5 to ~15 by just adding 10 to the threshold?
> If we are treating the hysteresis as an offset, then it should not
> change its value i.e. it should keep the configured value.
>
> Best regards,
> Javier Carrasco

You got it right and I also think that the hysteresis value should keep
the configured value. The doc states that the hysteresis is represented
as offset to the threshold, but I didn't find anything related to the
changing hysteresis value. Propably because most devices implement the
hysteresis value as offset !? Would change this behavior in the next
version of the patch if Jonathan agrees.

Thanks again for taking time to review.

Dimitri

  reply	other threads:[~2024-05-24  8:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-23 11:43 [PATCH] iio: humidity: hdc3020: fix hysteresis representation Dimitri Fedrau
2024-05-23 14:12 ` Javier Carrasco
2024-05-23 14:28   ` Dimitri Fedrau
2024-05-23 15:45     ` Javier Carrasco
2024-05-24  8:09       ` Dimitri Fedrau [this message]
2024-05-26 12:28         ` 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=20240524080948.GA560140@debian \
    --to=dima.fedrau@gmail.com \
    --cc=579lpy@gmail.com \
    --cc=javier.carrasco.cruz@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