Skip to content

Commit efdcbff

Browse files
epontangregkh
authored andcommitted
i2c: ismt: Separate I2C block read from SMBus block read
commit c6ebcedbab7ca78984959386012a17b21183e1a3 upstream. Commit b6c159a9cb69 ("i2c: ismt: Don't duplicate the receive length for block reads") broke I2C block reads. It aimed to fix normal SMBus block read, but changed the correct behavior of I2C block read in the process. According to Documentation/i2c/smbus-protocol, one vital difference between normal SMBus block read and I2C block read is that there is no byte count prefixed in the data sent on the wire: SMBus Block Read: i2c_smbus_read_block_data() S Addr Wr [A] Comm [A] S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P I2C Block Read: i2c_smbus_read_i2c_block_data() S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P Therefore the two transaction types need to be processed differently in the driver by copying of the dma_buffer as done previously for the I2C_SMBUS_I2C_BLOCK_DATA case. Fixes: b6c159a9cb69 ("i2c: ismt: Don't duplicate the receive length for block reads") Signed-off-by: Pontus Andersson <epontan@gmail.com> Tested-by: Stephen Douthit <stephend@adiengineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 68c6107 commit efdcbff

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/i2c/busses/i2c-ismt.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,15 @@ static int ismt_process_desc(const struct ismt_desc *desc,
338338
data->word = dma_buffer[0] | (dma_buffer[1] << 8);
339339
break;
340340
case I2C_SMBUS_BLOCK_DATA:
341-
case I2C_SMBUS_I2C_BLOCK_DATA:
342341
if (desc->rxbytes != dma_buffer[0] + 1)
343342
return -EMSGSIZE;
344343

345344
memcpy(data->block, dma_buffer, desc->rxbytes);
346345
break;
346+
case I2C_SMBUS_I2C_BLOCK_DATA:
347+
memcpy(&data->block[1], dma_buffer, desc->rxbytes);
348+
data->block[0] = desc->rxbytes;
349+
break;
347350
}
348351
return 0;
349352
}

0 commit comments

Comments
 (0)