diff options
author | David Frey <dpfrey@gmail.com> | 2018-08-17 22:03:13 +0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2018-08-19 18:46:28 +0300 |
commit | 8a0ae7d83aa8427fd264404da3045994521b621f (patch) | |
tree | bdd467c54ee9118d5ab86b72412d362b155976bf /drivers/iio/chemical | |
parent | 7c14947e4d3d8585cc047b132cd1a4ac3167928c (diff) | |
download | linux-8a0ae7d83aa8427fd264404da3045994521b621f.tar.xz |
iio: chemical: bme680: use clamp macro
Signed-off-by: David Frey <dpfrey@gmail.com>
Reviewed-by: Himanshu Jha <himanshujha199640@gmail.com>
Tested-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/chemical')
-rw-r--r-- | drivers/iio/chemical/bme680_core.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c index 5de9e27c914a..4d98c2155810 100644 --- a/drivers/iio/chemical/bme680_core.c +++ b/drivers/iio/chemical/bme680_core.c @@ -408,10 +408,7 @@ static u32 bme680_compensate_humid(struct bme680_data *data, var6 = (var4 * var5) >> 1; calc_hum = (((var3 + var6) >> 10) * 1000) >> 12; - if (calc_hum > 100000) /* Cap at 100%rH */ - calc_hum = 100000; - else if (calc_hum < 0) - calc_hum = 0; + calc_hum = clamp(calc_hum, 0, 100000); /* clamp between 0-100 %rH */ return calc_hum; } |