linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] iio: pressure: dlhl60d: Don't take garbage into consideration when reading data
@ 2022-07-26 14:20 Andy Shevchenko
  2022-07-31 12:33 ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2022-07-26 14:20 UTC (permalink / raw)
  To: Andy Shevchenko, linux-iio, linux-kernel
  Cc: Tomislav Denis, Jonathan Cameron, Lars-Peter Clausen

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>
---
 drivers/iio/pressure/dlhl60d.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/pressure/dlhl60d.c b/drivers/iio/pressure/dlhl60d.c
index 5f6bb3603a8b..f0b0d198c6d4 100644
--- a/drivers/iio/pressure/dlhl60d.c
+++ b/drivers/iio/pressure/dlhl60d.c
@@ -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;
 }
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-14 17:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-26 14:20 [PATCH v1 1/1] iio: pressure: dlhl60d: Don't take garbage into consideration when reading data Andy Shevchenko
2022-07-31 12:33 ` Jonathan Cameron
2022-08-14 17:15   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).