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

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
...@@ -357,10 +357,6 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, ...@@ -357,10 +357,6 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
outb_p(0xFF, SMBHSTSTS); outb_p(0xFF, SMBHSTSTS);
switch (size) { 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: case I2C_SMBUS_QUICK:
outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
SMBHSTADD); SMBHSTADD);
...@@ -418,6 +414,10 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, ...@@ -418,6 +414,10 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
outb_p(data->block[i], SMBBLKDAT); outb_p(data->block[i], SMBBLKDAT);
} }
break; break;
default:
dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
result = -EOPNOTSUPP;
goto EXIT;
} }
result = ali1535_transaction(adap); result = ali1535_transaction(adap);
......
...@@ -246,10 +246,6 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr, ...@@ -246,10 +246,6 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr,
/* Map the size to what the chip understands */ /* Map the size to what the chip understands */
switch (size) { 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: case I2C_SMBUS_QUICK:
size = HST_CNTL2_QUICK; size = HST_CNTL2_QUICK;
break; break;
...@@ -265,6 +261,10 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr, ...@@ -265,6 +261,10 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr,
case I2C_SMBUS_BLOCK_DATA: case I2C_SMBUS_BLOCK_DATA:
size = HST_CNTL2_BLOCK; size = HST_CNTL2_BLOCK;
break; 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); outb_p(((addr & 0x7f) << 1) | (rw & 0x01), SMB_HST_ADD);
......
...@@ -362,9 +362,6 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, ...@@ -362,9 +362,6 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
} }
switch (size) { switch (size) {
case I2C_SMBUS_PROC_CALL:
dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
return -EOPNOTSUPP;
case I2C_SMBUS_QUICK: case I2C_SMBUS_QUICK:
outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
SMBHSTADD); SMBHSTADD);
...@@ -417,6 +414,9 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, ...@@ -417,6 +414,9 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
} }
size = ALI15X3_BLOCK_DATA; size = ALI15X3_BLOCK_DATA;
break; break;
default:
dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
return -EOPNOTSUPP;
} }
outb_p(size, SMBHSTCNT); /* output command */ outb_p(size, SMBHSTCNT); /* output command */
......
...@@ -200,12 +200,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr, ...@@ -200,12 +200,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
int i, len; int i, len;
int status; int status;
/** TODO: Should I supporte the 10-bit transfers? */
switch (size) { 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: case I2C_SMBUS_QUICK:
outw_p(((addr & 0x7f) << 1) | (read_write & 0x01), outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
SMB_HOST_ADDRESS); SMB_HOST_ADDRESS);
...@@ -252,6 +247,9 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr, ...@@ -252,6 +247,9 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
} }
size = AMD756_BLOCK_DATA; size = AMD756_BLOCK_DATA;
break; break;
default:
dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
return -EOPNOTSUPP;
} }
/* How about enabling interrupts... */ /* How about enabling interrupts... */
......
...@@ -513,7 +513,6 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr, ...@@ -513,7 +513,6 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr,
outb_p(command, SMBHSTCMD); outb_p(command, SMBHSTCMD);
block = 1; block = 1;
break; break;
case I2C_SMBUS_PROC_CALL:
default: default:
dev_err(&I801_dev->dev, "Unsupported transaction %d\n", size); dev_err(&I801_dev->dev, "Unsupported transaction %d\n", size);
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
...@@ -307,9 +307,6 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr, ...@@ -307,9 +307,6 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
int status; int status;
switch (size) { switch (size) {
case I2C_SMBUS_PROC_CALL:
dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
return -EOPNOTSUPP;
case I2C_SMBUS_QUICK: case I2C_SMBUS_QUICK:
outb_p((addr << 1) | read_write, outb_p((addr << 1) | read_write,
SMBHSTADD); SMBHSTADD);
...@@ -355,6 +352,9 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr, ...@@ -355,6 +352,9 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
} }
size = PIIX4_BLOCK_DATA; size = PIIX4_BLOCK_DATA;
break; break;
default:
dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
return -EOPNOTSUPP;
} }
outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT); outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT);
......
...@@ -356,7 +356,8 @@ static s32 sis630_access(struct i2c_adapter *adap, u16 addr, ...@@ -356,7 +356,8 @@ static s32 sis630_access(struct i2c_adapter *adap, u16 addr,
size = SIS630_BLOCK_DATA; size = SIS630_BLOCK_DATA;
return sis630_block_data(adap, data, read_write); return sis630_block_data(adap, data, read_write);
default: default:
printk("Unsupported SMBus operation\n"); dev_warn(&adap->dev, "Unsupported transaction %d\n",
size);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -378,8 +379,6 @@ static s32 sis630_access(struct i2c_adapter *adap, u16 addr, ...@@ -378,8 +379,6 @@ static s32 sis630_access(struct i2c_adapter *adap, u16 addr,
case SIS630_WORD_DATA: case SIS630_WORD_DATA:
data->word = sis630_read(SMB_BYTE) + (sis630_read(SMB_BYTE + 1) << 8); data->word = sis630_read(SMB_BYTE) + (sis630_read(SMB_BYTE + 1) << 8);
break; break;
default:
return -EOPNOTSUPP;
} }
return 0; return 0;
......
...@@ -201,14 +201,8 @@ static s32 sis96x_access(struct i2c_adapter * adap, u16 addr, ...@@ -201,14 +201,8 @@ static s32 sis96x_access(struct i2c_adapter * adap, u16 addr,
SIS96x_PROC_CALL : SIS96x_WORD_DATA); SIS96x_PROC_CALL : SIS96x_WORD_DATA);
break; break;
case I2C_SMBUS_BLOCK_DATA:
/* TO DO: */
dev_info(&adap->dev, "SMBus block not implemented!\n");
return -EOPNOTSUPP;
break;
default: default:
dev_info(&adap->dev, "Unsupported SMBus operation\n"); dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
......
...@@ -96,9 +96,8 @@ static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr, ...@@ -96,9 +96,8 @@ static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
sprintf(p, "$%02X", command); sprintf(p, "$%02X", command);
break; break;
default: default:
dev_dbg(&adapter->dev, "Unsupported transaction size %d\n", dev_warn(&adapter->dev, "Unsupported transaction %d\n", size);
size); return -EOPNOTSUPP;
return -EINVAL;
} }
/* Send the transaction to the TAOS EVM */ /* Send the transaction to the TAOS EVM */
......
...@@ -287,7 +287,7 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr, ...@@ -287,7 +287,7 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
return 0; return 0;
exit_unsupported: exit_unsupported:
dev_warn(&vt596_adapter.dev, "Unsupported command invoked! (0x%02x)\n", dev_warn(&vt596_adapter.dev, "Unsupported transaction %d\n",
size); size);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment