mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-02 23:27:06 +00:00
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20220726142048.4494-1-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
65f79b5010
commit
b82217e73b
1 changed files with 2 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue