]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
i2c: Timeouts off by 1
authorRoel Kluin <roel.kluin@gmail.com>
Tue, 5 May 2009 06:39:24 +0000 (08:39 +0200)
committerJean Delvare <khali@linux-fr.org>
Tue, 5 May 2009 06:39:24 +0000 (08:39 +0200)
with while (timeout++ < MAX_TIMEOUT); timeout reaches MAX_TIMEOUT + 1
after the loop, so the tests below are off by one.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
drivers/i2c/busses/i2c-ali1535.c
drivers/i2c/busses/i2c-ali15x3.c
drivers/i2c/busses/i2c-amd756.c
drivers/i2c/busses/i2c-i801.c
drivers/i2c/busses/i2c-isch.c
drivers/i2c/busses/i2c-nforce2.c
drivers/i2c/busses/i2c-sis5595.c
drivers/i2c/busses/i2c-sis630.c
drivers/i2c/busses/i2c-sis96x.c

index 981e080b32aee0508e2fceb9e654ccf31cdfee9b..d108450df064552b56f5886200231f3e53e8c57b 100644 (file)
@@ -284,7 +284,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
                 && (timeout++ < MAX_TIMEOUT));
 
        /* If the SMBus is still busy, we give up */
-       if (timeout >= MAX_TIMEOUT) {
+       if (timeout > MAX_TIMEOUT) {
                result = -ETIMEDOUT;
                dev_err(&adap->dev, "SMBus Timeout!\n");
        }
index 39066dee46e3552a3ffee94ccfcfabb80521e1f1..d627fceb790b9e16c3fb2b15c1e544a653e1a46d 100644 (file)
@@ -306,7 +306,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
                 && (timeout++ < MAX_TIMEOUT));
 
        /* If the SMBus is still busy, we give up */
-       if (timeout >= MAX_TIMEOUT) {
+       if (timeout > MAX_TIMEOUT) {
                result = -ETIMEDOUT;
                dev_err(&adap->dev, "SMBus Timeout!\n");
        }
index 220f4a1eee1dc55460d686777736b6d22c2a6018..f7d6fe9c49baa3724c38463448acbcb5a4384cb4 100644 (file)
@@ -126,7 +126,7 @@ static int amd756_transaction(struct i2c_adapter *adap)
                } while ((temp & (GS_HST_STS | GS_SMB_STS)) &&
                         (timeout++ < MAX_TIMEOUT));
                /* If the SMBus is still busy, we give up */
-               if (timeout >= MAX_TIMEOUT) {
+               if (timeout > MAX_TIMEOUT) {
                        dev_dbg(&adap->dev, "Busy wait timeout (%04x)\n", temp);
                        goto abort;
                }
@@ -143,7 +143,7 @@ static int amd756_transaction(struct i2c_adapter *adap)
        } while ((temp & GS_HST_STS) && (timeout++ < MAX_TIMEOUT));
 
        /* If the SMBus is still busy, we give up */
-       if (timeout >= MAX_TIMEOUT) {
+       if (timeout > MAX_TIMEOUT) {
                dev_dbg(&adap->dev, "Completion timeout!\n");
                goto abort;
        }
index 10411848fd704f58e790cc3587a92e07bd6f22c6..9d2c5adf5d4fbbcf06c8baf68d98cb01c5b93706 100644 (file)
@@ -237,7 +237,7 @@ static int i801_transaction(int xact)
                status = inb_p(SMBHSTSTS);
        } while ((status & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_TIMEOUT));
 
-       result = i801_check_post(status, timeout >= MAX_TIMEOUT);
+       result = i801_check_post(status, timeout > MAX_TIMEOUT);
        if (result < 0)
                return result;
 
@@ -257,9 +257,9 @@ static void i801_wait_hwpec(void)
        } while ((!(status & SMBHSTSTS_INTR))
                 && (timeout++ < MAX_TIMEOUT));
 
-       if (timeout >= MAX_TIMEOUT) {
+       if (timeout > MAX_TIMEOUT)
                dev_dbg(&I801_dev->dev, "PEC Timeout!\n");
-       }
+
        outb_p(status, SMBHSTSTS);
 }
 
@@ -344,7 +344,7 @@ static int i801_block_transaction_byte_by_byte(union i2c_smbus_data *data,
                while ((!(status & SMBHSTSTS_BYTE_DONE))
                       && (timeout++ < MAX_TIMEOUT));
 
-               result = i801_check_post(status, timeout >= MAX_TIMEOUT);
+               result = i801_check_post(status, timeout > MAX_TIMEOUT);
                if (result < 0)
                        return result;
 
index b9c01aa90036d49eb30fa841ca0e2924f98ddb82..9f6b8e0f8632af44c2eb4c49667277e0656bec7b 100644 (file)
@@ -112,7 +112,7 @@ static int sch_transaction(void)
        } while ((temp & 0x08) && (timeout++ < MAX_TIMEOUT));
 
        /* If the SMBus is still busy, we give up */
-       if (timeout >= MAX_TIMEOUT) {
+       if (timeout > MAX_TIMEOUT) {
                dev_err(&sch_adapter.dev, "SMBus Timeout!\n");
                result = -ETIMEDOUT;
        }
index 2ff4683703a8ddfc9871040d0a9c79406e71bd41..ec11d1c4e77bdbcd79e45e337ce05dffa0894bb8 100644 (file)
@@ -173,7 +173,7 @@ static int nforce2_check_status(struct i2c_adapter *adap)
                temp = inb_p(NVIDIA_SMB_STS);
        } while ((!temp) && (timeout++ < MAX_TIMEOUT));
 
-       if (timeout >= MAX_TIMEOUT) {
+       if (timeout > MAX_TIMEOUT) {
                dev_dbg(&adap->dev, "SMBus Timeout!\n");
                if (smbus->can_abort)
                        nforce2_abort(adap);
index f320ab27da463ae26b4d2ed078d250fa7c72d2c9..139f0c7f12a406db35d9b73f08ce4ab2f47132a3 100644 (file)
@@ -256,7 +256,7 @@ static int sis5595_transaction(struct i2c_adapter *adap)
        } while (!(temp & 0x40) && (timeout++ < MAX_TIMEOUT));
 
        /* If the SMBus is still busy, we give up */
-       if (timeout >= MAX_TIMEOUT) {
+       if (timeout > MAX_TIMEOUT) {
                dev_dbg(&adap->dev, "SMBus Timeout!\n");
                result = -ETIMEDOUT;
        }
index 50c3610e60288d0cd123d52b7040b5ad3217cb70..70ca41e90e58741d9e0a1cce9088e380f69fa48c 100644 (file)
@@ -173,7 +173,7 @@ static int sis630_transaction_wait(struct i2c_adapter *adap, int size)
        } while (!(temp & 0x0e) && (timeout++ < MAX_TIMEOUT));
 
        /* If the SMBus is still busy, we give up */
-       if (timeout >= MAX_TIMEOUT) {
+       if (timeout > MAX_TIMEOUT) {
                dev_dbg(&adap->dev, "SMBus Timeout!\n");
                result = -ETIMEDOUT;
        }
index 7e1594b40579f78561814070eb71a5a20c66bcd2..8295885b2fdb9417c18f19becc3a3ce045240d18 100644 (file)
@@ -132,7 +132,7 @@ static int sis96x_transaction(int size)
        } while (!(temp & 0x0e) && (timeout++ < MAX_TIMEOUT));
 
        /* If the SMBus is still busy, we give up */
-       if (timeout >= MAX_TIMEOUT) {
+       if (timeout > MAX_TIMEOUT) {
                dev_dbg(&sis96x_adapter.dev, "SMBus Timeout! (0x%02x)\n", temp);
                result = -ETIMEDOUT;
        }