Commit 8a0ae7d8 authored by David Frey's avatar David Frey Committed by Jonathan Cameron

iio: chemical: bme680: use clamp macro

Signed-off-by: default avatarDavid Frey <dpfrey@gmail.com>
Reviewed-by: default avatarHimanshu Jha <himanshujha199640@gmail.com>
Tested-by: default avatarHimanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 7c14947e
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment