]> git.ipfire.org Git - thirdparty/linux.git/commit
iio: humidity: hdc3020: fix hysteresis representation
authorDimitri Fedrau <dima.fedrau@gmail.com>
Wed, 5 Jun 2024 19:21:35 +0000 (21:21 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 9 Jun 2024 10:05:03 +0000 (11:05 +0100)
commit9547d6a4c65e975e40e203900322342ef7379c52
tree6627971e92d677ee1e8ed5d5b01c183b3391ec2f
parent75183e461ce033605c3e85518a9f3d4e4ef848a3
iio: humidity: hdc3020: fix hysteresis representation

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>
Reviewed-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240605192136.38146-1-dima.fedrau@gmail.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/humidity/hdc3020.c