iio: proximity: isl29501: fix buffered read on big-endian systems
commit de18e978d0cda23e4c102e18092b63a5b0b3a800 upstream.
Fix passing a u32 value as a u16 buffer scan item. This works on little-
endian systems, but not on big-endian systems.
A new local variable is introduced for getting the register value and
the array is changed to a struct to make the data layout more explicit
rather than just changing the type and having to recalculate the proper
length needed for the timestamp.
Fixes: 1c28799257 ("iio: light: isl29501: Add support for the ISL29501 ToF sensor.")
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250722-iio-use-more-iio_declare_buffer_with_ts-7-v2-1-d3ebeb001ed3@baylibre.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
This commit is contained in:
committed by
Ulrich Hecht
parent
c4010ef5a7
commit
755a7fca21
@@ -946,12 +946,18 @@ static irqreturn_t isl29501_trigger_handler(int irq, void *p)
|
||||
struct iio_dev *indio_dev = pf->indio_dev;
|
||||
struct isl29501_private *isl29501 = iio_priv(indio_dev);
|
||||
const unsigned long *active_mask = indio_dev->active_scan_mask;
|
||||
u32 buffer[4] __aligned(8) = {}; /* 1x16-bit + naturally aligned ts */
|
||||
u32 value;
|
||||
struct {
|
||||
u16 data;
|
||||
aligned_s64 ts;
|
||||
} scan = { };
|
||||
|
||||
if (test_bit(ISL29501_DISTANCE_SCAN_INDEX, active_mask))
|
||||
isl29501_register_read(isl29501, REG_DISTANCE, buffer);
|
||||
if (test_bit(ISL29501_DISTANCE_SCAN_INDEX, active_mask)) {
|
||||
isl29501_register_read(isl29501, REG_DISTANCE, &value);
|
||||
scan.data = value;
|
||||
}
|
||||
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, buffer, pf->timestamp);
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, &scan, pf->timestamp);
|
||||
iio_trigger_notify_done(indio_dev->trig);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
|
||||
Reference in New Issue
Block a user