On Thu, 23 Jul 2020 15:17:16 +0300 Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote: > On Wed, Jul 22, 2020 at 6:53 PM Jonathan Cameron <jic23@xxxxxxxxxx> wrote: > > > This one is unusual. We have to do an explicit memset each time > > as we are reading 3 bytes into a potential 4 byte channel which > > may sometimes be a 2 byte channel depending on what is enabled. > > As such, moving the buffer to the heap in the iio_priv structure > > doesn't save us much. We can't use a nice explicit structure > > on the stack either as the data channels have different storage > > sizes and are all separately controlled. > > I guess all non-standard cases (where no struct is applicable) deserve > for better comment in the code. > Sure can do that. I guess that will mean people actually think about it whilst copying examples form old into new drivers. In many ways the no struct applicable is the 'standard' case. It's mere coincidence that in some drivers there are sufficiently few channels that the struct 'trick' works. All the other channels are moving around even in those cases, it's just the timestamp that happens to only have one valid location. I'll probably do a v4 at the weekend. Jonathan