hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/i2c/busses/i2c-designware-master.c
....@@ -432,8 +432,19 @@
432432
433433 regmap_read(dev->map, DW_IC_DATA_CMD, &tmp);
434434 /* Ensure length byte is a valid value */
435
- if (flags & I2C_M_RECV_LEN &&
436
- tmp <= I2C_SMBUS_BLOCK_MAX && tmp > 0) {
435
+ if (flags & I2C_M_RECV_LEN) {
436
+ /*
437
+ * if IC_EMPTYFIFO_HOLD_MASTER_EN is set, which cannot be
438
+ * detected from the registers, the controller can be
439
+ * disabled if the STOP bit is set. But it is only set
440
+ * after receiving block data response length in
441
+ * I2C_FUNC_SMBUS_BLOCK_DATA case. That needs to read
442
+ * another byte with STOP bit set when the block data
443
+ * response length is invalid to complete the transaction.
444
+ */
445
+ if (!tmp || tmp > I2C_SMBUS_BLOCK_MAX)
446
+ tmp = 1;
447
+
437448 len = i2c_dw_recv_len(dev, tmp);
438449 }
439450 *buf++ = tmp;