Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac7fc4fb authored by Jean Delvare's avatar Jean Delvare Committed by Jean Delvare
Browse files

i2c: Consistently reject unsupported transactions



Many PC SMBus host controller drivers don't properly handle the case
where they are requested to achieve a transaction they do not support.
Update them so that the consistently print a warning message and
return a single error value in this case.

Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent fa63cd56
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -357,10 +357,6 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
	outb_p(0xFF, SMBHSTSTS);

	switch (size) {
	case I2C_SMBUS_PROC_CALL:
		dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
		result = -EOPNOTSUPP;
		goto EXIT;
	case I2C_SMBUS_QUICK:
		outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
		       SMBHSTADD);
@@ -418,6 +414,10 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
				outb_p(data->block[i], SMBBLKDAT);
		}
		break;
	default:
		dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
		result = -EOPNOTSUPP;
		goto EXIT;
	}

	result = ali1535_transaction(adap);
+4 −4
Original line number Diff line number Diff line
@@ -246,10 +246,6 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr,

	/* Map the size to what the chip understands */
	switch (size) {
	case I2C_SMBUS_PROC_CALL:
		dev_err(&a->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
		error = -EINVAL;
		break;
	case I2C_SMBUS_QUICK:
		size = HST_CNTL2_QUICK;
		break;
@@ -265,6 +261,10 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr,
	case I2C_SMBUS_BLOCK_DATA:
		size = HST_CNTL2_BLOCK;
		break;
	default:
		dev_warn(&a->dev, "Unsupported transaction %d\n", size);
		error = -EOPNOTSUPP;
		goto Done;
	}

	outb_p(((addr & 0x7f) << 1) | (rw & 0x01), SMB_HST_ADD);
+3 −3
Original line number Diff line number Diff line
@@ -362,9 +362,6 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
	}

	switch (size) {
	case I2C_SMBUS_PROC_CALL:
		dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
		return -EOPNOTSUPP;
	case I2C_SMBUS_QUICK:
		outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
		       SMBHSTADD);
@@ -417,6 +414,9 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
		}
		size = ALI15X3_BLOCK_DATA;
		break;
	default:
		dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
		return -EOPNOTSUPP;
	}

	outb_p(size, SMBHSTCNT);	/* output command */
+3 −5
Original line number Diff line number Diff line
@@ -200,12 +200,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
	int i, len;
	int status;

	/** TODO: Should I supporte the 10-bit transfers? */
	switch (size) {
	case I2C_SMBUS_PROC_CALL:
		dev_dbg(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
		/* TODO: Well... It is supported, I'm just not sure what to do here... */
		return -EOPNOTSUPP;
	case I2C_SMBUS_QUICK:
		outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
		       SMB_HOST_ADDRESS);
@@ -252,6 +247,9 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
		}
		size = AMD756_BLOCK_DATA;
		break;
	default:
		dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
		return -EOPNOTSUPP;
	}

	/* How about enabling interrupts... */
+0 −1
Original line number Diff line number Diff line
@@ -513,7 +513,6 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr,
			outb_p(command, SMBHSTCMD);
		block = 1;
		break;
	case I2C_SMBUS_PROC_CALL:
	default:
		dev_err(&I801_dev->dev, "Unsupported transaction %d\n", size);
		return -EOPNOTSUPP;
Loading