]> err.no Git - linux-2.6/commitdiff
i2c: Consistently reject unsupported transactions
authorJean Delvare <khali@linux-fr.org>
Mon, 14 Jul 2008 20:38:25 +0000 (22:38 +0200)
committerJean Delvare <khali@mahadeva.delvare>
Mon, 14 Jul 2008 20:38:25 +0000 (22:38 +0200)
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: Jean Delvare <khali@linux-fr.org>
drivers/i2c/busses/i2c-ali1535.c
drivers/i2c/busses/i2c-ali1563.c
drivers/i2c/busses/i2c-ali15x3.c
drivers/i2c/busses/i2c-amd756.c
drivers/i2c/busses/i2c-i801.c
drivers/i2c/busses/i2c-piix4.c
drivers/i2c/busses/i2c-sis630.c
drivers/i2c/busses/i2c-sis96x.c
drivers/i2c/busses/i2c-taos-evm.c
drivers/i2c/busses/i2c-viapro.c

index c21e4d96382ea4d37dcdaa727bead406afe2ce09..704436cdec8e62769e2a69ed39a7302e7e2c3fab 100644 (file)
@@ -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);
index 30bd3ee7038607da867f4818d82b340c1e0c1085..da5a382eee93f9b94d1fb9bff4d20313f912ae78 100644 (file)
@@ -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);
index 3d752561dc3769bb5d079a23e0187dc30a48e95f..7b029b147a8e70a95b509440953dca7dc2468d09 100644 (file)
@@ -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 */
index 3d5bcb65e9e01cd9283f31a71498333f7acdc987..f0baea62067d3d59ed004ea75efd5833cd413665 100644 (file)
@@ -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... */
index 7d6d9dfcc58a6bb8a40a5492b0b428664e5b861a..213119211e58711413e99bf5c3427b9ef154ec3d 100644 (file)
@@ -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;
index 77aaa5fe5e38b0f6b9c6d3f3e8bf7f3f20e779f5..2bde47509e1a4c4243de0dcc4f81eead5deb6561 100644 (file)
@@ -307,9 +307,6 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
        int status;
 
        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 << 1) | read_write,
                       SMBHSTADD);
@@ -355,6 +352,9 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
                }
                size = PIIX4_BLOCK_DATA;
                break;
+       default:
+               dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
+               return -EOPNOTSUPP;
        }
 
        outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT);
index c4cc5eddf50dc10f0f658833d693c3db85a81952..d7e6ff3e018737af93e2f083db1d153a14f93a48 100644 (file)
@@ -356,7 +356,8 @@ static s32 sis630_access(struct i2c_adapter *adap, u16 addr,
                        size = SIS630_BLOCK_DATA;
                        return sis630_block_data(adap, data, read_write);
                default:
-                       printk("Unsupported SMBus operation\n");
+                       dev_warn(&adap->dev, "Unsupported transaction %d\n",
+                                size);
                        return -EOPNOTSUPP;
        }
 
@@ -378,8 +379,6 @@ static s32 sis630_access(struct i2c_adapter *adap, u16 addr,
                case SIS630_WORD_DATA:
                        data->word = sis630_read(SMB_BYTE) + (sis630_read(SMB_BYTE + 1) << 8);
                        break;
-               default:
-                       return -EOPNOTSUPP;
        }
 
        return 0;
index 29757b2e11dd81280d7cd35d87a5b0fc59175b0e..cde8e5880368afd23a6d2a551f441fbe01e9b7f7 100644 (file)
@@ -201,14 +201,8 @@ static s32 sis96x_access(struct i2c_adapter * adap, u16 addr,
                        SIS96x_PROC_CALL : SIS96x_WORD_DATA);
                break;
 
-       case I2C_SMBUS_BLOCK_DATA:
-               /* TO DO: */
-               dev_info(&adap->dev, "SMBus block not implemented!\n");
-               return -EOPNOTSUPP;
-               break;
-
        default:
-               dev_info(&adap->dev, "Unsupported SMBus operation\n");
+               dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
                return -EOPNOTSUPP;
        }
 
index de9db49e54d93d8785f0beef0df4c5df28036a12..224aa12ee7c85d880118db61cac79a2b564e6af1 100644 (file)
@@ -96,9 +96,8 @@ static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
                        sprintf(p, "$%02X", command);
                break;
        default:
-               dev_dbg(&adapter->dev, "Unsupported transaction size %d\n",
-                       size);
-               return -EINVAL;
+               dev_warn(&adapter->dev, "Unsupported transaction %d\n", size);
+               return -EOPNOTSUPP;
        }
 
        /* Send the transaction to the TAOS EVM */
index 7628fe8e0946b1a7dcc6ec5fc48900fe800428d2..c611905df009bcc9521035c4a27a831da5f301f1 100644 (file)
@@ -287,7 +287,7 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
        return 0;
 
 exit_unsupported:
-       dev_warn(&vt596_adapter.dev, "Unsupported command invoked! (0x%02x)\n",
+       dev_warn(&vt596_adapter.dev, "Unsupported transaction %d\n",
                 size);
        return -EOPNOTSUPP;
 }