[PATCH 0/8] iio: timestamp declaration cleanup
David Lechner
dlechner at baylibre.com
Sun May 17 12:22:03 PDT 2026
On 5/17/26 1:17 PM, David Lechner wrote:
> While looking around the code, I noticed that there are a lot of places
> were we are manually filling all of the fields of an IIO timestamp.
>
> This is error-prone (as seen in the first patch) and more verbose than
> it needs to be.
>
> I went with the approach of using the existing IIO_CHAN_SOFT_TIMESTAMP()
> macro for doing a struct assignment. This does require a cast, which
> makes it a bit more verbose, but we were already doing that in to
> drivers, so I went with it anyway.
>
> If we want to consider alternatives, we could make a iio helper function
> or macro like the first and second patches did.
>
I should have looked harder for existing alternatives. Just found one
more that avoids the cast via a local variable (in ad4170-4.c):
/* Add timestamp channel */
struct iio_chan_spec ts_chan = IIO_CHAN_SOFT_TIMESTAMP(chan_num);
st->chans[chan_num] = ts_chan;
And similar code is found in ad7192.c.
More information about the linux-arm-kernel
mailing list