Commit b82217e7 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Jonathan Cameron

iio: pressure: dlhl60d: Don't take garbage into consideration when reading data

Both pressure and temperature are 24-bit long. Use proper accessors
instead of overlapping readings.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220726142048.4494-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 65f79b50
......@@ -129,9 +129,8 @@ static int dlh_read_direct(struct dlh_state *st,
if (ret)
return ret;
*pressure = get_unaligned_be32(&st->rx_buf[1]) >> 8;
*temperature = get_unaligned_be32(&st->rx_buf[3]) &
GENMASK(DLH_NUM_TEMP_BITS - 1, 0);
*pressure = get_unaligned_be24(&st->rx_buf[1]);
*temperature = get_unaligned_be24(&st->rx_buf[4]);
return 0;
}
......
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