Re: [PATCH v3] iio: imu: inv_icm45600: clamp the device-reported FIFO sample count
From: Bryam Vargas
Date: Mon Jun 22 2026 - 05:01:44 EST
On 2026-06-21, Jonathan Cameron wrote:
> So could we just do this instead?
> st->fifo.count = min(fifo_nb * packet_size, INV_ICM45600_FIFO_SIZE_MAX);
Yes, cleaner -- and safe here: fifo_nb isn't used past that line (the read, the
one-by-one fallback and the decode loop all bound on st->fifo.count), so
clamping the byte count is enough. fifo_nb is size_t and packet_size ssize_t, so
the multiply is 64-bit with no narrowing before the min. v4 will use it.
> can we actually use the define in the allocation in _core.c
Will do. It's devm_kzalloc(dev, 8192, ...) today and INV_ICM45600_FIFO_SIZE_MAX
is SZ_8K, so it's a no-op rename that ties the allocation to the clamp; folded
into the same patch with a changelog note.
v4 shortly.
Bryam