> On Aug 2, 2020, at 2:38 PM, Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx> wrote: > > Hi Daniel, > >>> + __u16 len = recv_len ? msgs[i].buf[0] + 1 : msgs[i].len; >> >> This is post-ioctl()? (Sorry, still not familiar enough with i2c-tools.) > > Yes, read buffers are only printed after the ioctl. And 'print_msgs' is > probably the most complex function within this tool :/ > >> It isn’t wrong, but shouldn’t be necessary. >> Unless the adapter driver you’re using went astray. Not ruling that out. > > I have just checked existing I2C_M_RECV_LEN handling. Quite some drivers > do it wrong. And there is no consistency in what they return. Lots of > things to fix there... Would be curious about what variants are there. Note that msgs[i].len isn’t updated, you only get <extra_bytes> of data back, so the difference would be severe: msgs[i].len is what guides copy_to_user(). https://github.com/torvalds/linux/blob/master/drivers/i2c/i2c-dev.c#L301 Daniel