Skip to content

Commit de18e97

Browse files
dlechjic23
authored andcommitted
iio: proximity: isl29501: fix buffered read on big-endian systems
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: 1c28799 ("iio: light: isl29501: Add support for the ISL29501 ToF sensor.") Signed-off-by: David Lechner <[email protected]> Link: https://patch.msgid.link/20250722-iio-use-more-iio_declare_buffer_with_ts-7-v2-1-d3ebeb001ed3@baylibre.com Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 4e5b705 commit de18e97

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

drivers/iio/proximity/isl29501.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -938,12 +938,18 @@ static irqreturn_t isl29501_trigger_handler(int irq, void *p)
938938
struct iio_dev *indio_dev = pf->indio_dev;
939939
struct isl29501_private *isl29501 = iio_priv(indio_dev);
940940
const unsigned long *active_mask = indio_dev->active_scan_mask;
941-
u32 buffer[4] __aligned(8) = {}; /* 1x16-bit + naturally aligned ts */
942-
943-
if (test_bit(ISL29501_DISTANCE_SCAN_INDEX, active_mask))
944-
isl29501_register_read(isl29501, REG_DISTANCE, buffer);
941+
u32 value;
942+
struct {
943+
u16 data;
944+
aligned_s64 ts;
945+
} scan = { };
946+
947+
if (test_bit(ISL29501_DISTANCE_SCAN_INDEX, active_mask)) {
948+
isl29501_register_read(isl29501, REG_DISTANCE, &value);
949+
scan.data = value;
950+
}
945951

946-
iio_push_to_buffers_with_timestamp(indio_dev, buffer, pf->timestamp);
952+
iio_push_to_buffers_with_timestamp(indio_dev, &scan, pf->timestamp);
947953
iio_trigger_notify_done(indio_dev->trig);
948954

949955
return IRQ_HANDLED;

0 commit comments

Comments
 (0)