Merge ../linux-2.6 by hand
[powerpc.git] / drivers / i2c / busses / i2c-i801.c
index 413930c..4f63195 100644 (file)
@@ -102,8 +102,8 @@ MODULE_PARM_DESC(force_addr,
                 "EXTREMELY DANGEROUS!");
 
 static int i801_transaction(void);
-static int i801_block_transaction(union i2c_smbus_data *data,
-                                 char read_write, int command);
+static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
+                                 int command, int hwpec);
 
 static unsigned short i801_smba;
 static struct pci_driver i801_driver;
@@ -249,7 +249,7 @@ static int i801_transaction(void)
 
 /* All-inclusive block transaction function */
 static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
-                                 int command)
+                                 int command, int hwpec)
 {
        int i, len;
        int smbcmd;
@@ -388,7 +388,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
                        goto END;
        }
 
-       if(isich4 && command == I2C_SMBUS_BLOCK_DATA_PEC) {
+       if (hwpec) {
                /* wait for INTR bit as advised by Intel */
                timeout = 0;
                do {
@@ -416,12 +416,13 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr,
                       unsigned short flags, char read_write, u8 command,
                       int size, union i2c_smbus_data * data)
 {
-       int hwpec = 0;
+       int hwpec;
        int block = 0;
        int ret, xact = 0;
 
-       if(isich4)
-               hwpec = (flags & I2C_CLIENT_PEC) != 0;
+       hwpec = isich4 && (flags & I2C_CLIENT_PEC)
+               && size != I2C_SMBUS_QUICK
+               && size != I2C_SMBUS_I2C_BLOCK_DATA;
 
        switch (size) {
        case I2C_SMBUS_QUICK:
@@ -456,9 +457,6 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr,
                break;
        case I2C_SMBUS_BLOCK_DATA:
        case I2C_SMBUS_I2C_BLOCK_DATA:
-       case I2C_SMBUS_BLOCK_DATA_PEC:
-               if(hwpec && size == I2C_SMBUS_BLOCK_DATA)
-                       size = I2C_SMBUS_BLOCK_DATA_PEC;
                outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
                       SMBHSTADD);
                outb_p(command, SMBHSTCMD);
@@ -470,23 +468,18 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr,
                return -1;
        }
 
-       if(isich4 && hwpec) {
-               if(size != I2C_SMBUS_QUICK &&
-                  size != I2C_SMBUS_I2C_BLOCK_DATA)
-                       outb_p(1, SMBAUXCTL);   /* enable HW PEC */
-       }
+       if (hwpec)
+               outb_p(1, SMBAUXCTL);   /* enable hardware PEC */
+
        if(block)
-               ret = i801_block_transaction(data, read_write, size);
+               ret = i801_block_transaction(data, read_write, size, hwpec);
        else {
                outb_p(xact | ENABLE_INT9, SMBHSTCNT);
                ret = i801_transaction();
        }
 
-       if(isich4 && hwpec) {
-               if(size != I2C_SMBUS_QUICK &&
-                  size != I2C_SMBUS_I2C_BLOCK_DATA)
-                       outb_p(0, SMBAUXCTL);
-       }
+       if (hwpec)
+               outb_p(0, SMBAUXCTL);   /* disable hardware PEC */
 
        if(block)
                return ret;
@@ -513,8 +506,7 @@ static u32 i801_func(struct i2c_adapter *adapter)
        return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
            I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
            I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK
-            | (isich4 ? I2C_FUNC_SMBUS_BLOCK_DATA_PEC |
-                        I2C_FUNC_SMBUS_HWPEC_CALC : 0);
+            | (isich4 ? I2C_FUNC_SMBUS_HWPEC_CALC : 0);
 }
 
 static struct i2c_algorithm smbus_algorithm = {
@@ -568,6 +560,7 @@ static void __devexit i801_remove(struct pci_dev *dev)
 }
 
 static struct pci_driver i801_driver = {
+       .owner          = THIS_MODULE,
        .name           = "i801_smbus",
        .id_table       = i801_ids,
        .probe          = i801_probe,