iio: pressure: dlhl60d: Don't take garbage into consideration when reading data
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 26 Jul 2022 14:20:48 +0000 (17:20 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 15 Aug 2022 21:30:04 +0000 (22:30 +0100)
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>
drivers/iio/pressure/dlhl60d.c

index 5f6bb36..f0b0d19 100644 (file)
@@ -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;
 }