|
205 | 205 | #define STATUS_FLAGS (SMBHSTSTS_BYTE_DONE | SMBHSTSTS_INTR | \
|
206 | 206 | STATUS_ERROR_FLAGS)
|
207 | 207 |
|
| 208 | +#define SMBUS_LEN_SENTINEL (I2C_SMBUS_BLOCK_MAX + 1) |
| 209 | + |
208 | 210 | /* Older devices have their ID defined in <linux/pci_ids.h> */
|
209 | 211 | #define PCI_DEVICE_ID_INTEL_COMETLAKE_SMBUS 0x02a3
|
210 | 212 | #define PCI_DEVICE_ID_INTEL_COMETLAKE_H_SMBUS 0x06a3
|
@@ -541,9 +543,12 @@ static int i801_block_transaction_by_block(struct i801_priv *priv,
|
541 | 543 | static void i801_isr_byte_done(struct i801_priv *priv)
|
542 | 544 | {
|
543 | 545 | if (priv->is_read) {
|
544 |
| - /* For SMBus block reads, length is received with first byte */ |
545 |
| - if (((priv->cmd & 0x1c) == I801_BLOCK_DATA) && |
546 |
| - (priv->count == 0)) { |
| 546 | + /* |
| 547 | + * At transfer start i801_smbus_block_transaction() marks |
| 548 | + * the block length as invalid. Check for this sentinel value |
| 549 | + * and read the block length from SMBHSTDAT0. |
| 550 | + */ |
| 551 | + if (priv->len == SMBUS_LEN_SENTINEL) { |
547 | 552 | priv->len = inb_p(SMBHSTDAT0(priv));
|
548 | 553 | if (priv->len < 1 || priv->len > I2C_SMBUS_BLOCK_MAX) {
|
549 | 554 | dev_err(&priv->pci_dev->dev,
|
@@ -698,8 +703,12 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv,
|
698 | 703 | if (status)
|
699 | 704 | return status;
|
700 | 705 |
|
701 |
| - if (i == 1 && read_write == I2C_SMBUS_READ |
702 |
| - && command != I2C_SMBUS_I2C_BLOCK_DATA) { |
| 706 | + /* |
| 707 | + * At transfer start i801_smbus_block_transaction() marks |
| 708 | + * the block length as invalid. Check for this sentinel value |
| 709 | + * and read the block length from SMBHSTDAT0. |
| 710 | + */ |
| 711 | + if (len == SMBUS_LEN_SENTINEL) { |
703 | 712 | len = inb_p(SMBHSTDAT0(priv));
|
704 | 713 | if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) {
|
705 | 714 | dev_err(&priv->pci_dev->dev,
|
@@ -806,7 +815,8 @@ static int i801_smbus_block_transaction(struct i801_priv *priv, union i2c_smbus_
|
806 | 815 | u8 addr, u8 hstcmd, char read_write, int command)
|
807 | 816 | {
|
808 | 817 | if (read_write == I2C_SMBUS_READ && command == I2C_SMBUS_BLOCK_DATA)
|
809 |
| - data->block[0] = I2C_SMBUS_BLOCK_MAX; |
| 818 | + /* Mark block length as invalid */ |
| 819 | + data->block[0] = SMBUS_LEN_SENTINEL; |
810 | 820 | else if (data->block[0] < 1 || data->block[0] > I2C_SMBUS_BLOCK_MAX)
|
811 | 821 | return -EPROTO;
|
812 | 822 |
|
|
0 commit comments