Browse Source

tools: i2ctransfer: add check for returned length from driver

Emit a warning if the bus master driver in the kernel did not set the
message length correctly with I2C_M_RECV_LEN. This can be determined
from the returned value in the buffer.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
tags/v4.2
Wolfram Sang 5 years ago
committed by Wolfram Sang
parent
commit
34806fc4e7
  1. 7
      tools/i2ctransfer.c

7
tools/i2ctransfer.c

@ -88,7 +88,12 @@ static void print_msgs(struct i2c_msg *msgs, __u32 nmsgs, unsigned flags)
int recv_len = msgs[i].flags & I2C_M_RECV_LEN;
int print_buf = (read && (flags & PRINT_READ_BUF)) ||
(!read && (flags & PRINT_WRITE_BUF));
__u16 len = recv_len ? msgs[i].buf[0] + 1 : msgs[i].len;
__u16 len = msgs[i].len;
if (recv_len && print_buf && len != msgs[i].buf[0] + 1) {
fprintf(stderr, "Correcting wrong msg length after recv_len! Please fix the I2C driver and/or report.\n");
len = msgs[i].buf[0] + 1;
}
if (flags & PRINT_HEADER) {
fprintf(output, "msg %u: addr 0x%02x, %s, len ",

Loading…
Cancel
Save