i2c: Timeouts off by 1

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>

authored by Roel Kluin and committed by Jean Delvare 4ccc28f7 b4348f32

+13 -13
+1 -1
drivers/i2c/busses/i2c-ali1535.c
··· 284 284 && (timeout++ < MAX_TIMEOUT)); 285 285 286 286 /* If the SMBus is still busy, we give up */ 287 - if (timeout >= MAX_TIMEOUT) { 287 + if (timeout > MAX_TIMEOUT) { 288 288 result = -ETIMEDOUT; 289 289 dev_err(&adap->dev, "SMBus Timeout!\n"); 290 290 }
+1 -1
drivers/i2c/busses/i2c-ali15x3.c
··· 306 306 && (timeout++ < MAX_TIMEOUT)); 307 307 308 308 /* If the SMBus is still busy, we give up */ 309 - if (timeout >= MAX_TIMEOUT) { 309 + if (timeout > MAX_TIMEOUT) { 310 310 result = -ETIMEDOUT; 311 311 dev_err(&adap->dev, "SMBus Timeout!\n"); 312 312 }
+2 -2
drivers/i2c/busses/i2c-amd756.c
··· 126 126 } while ((temp & (GS_HST_STS | GS_SMB_STS)) && 127 127 (timeout++ < MAX_TIMEOUT)); 128 128 /* If the SMBus is still busy, we give up */ 129 - if (timeout >= MAX_TIMEOUT) { 129 + if (timeout > MAX_TIMEOUT) { 130 130 dev_dbg(&adap->dev, "Busy wait timeout (%04x)\n", temp); 131 131 goto abort; 132 132 } ··· 143 143 } while ((temp & GS_HST_STS) && (timeout++ < MAX_TIMEOUT)); 144 144 145 145 /* If the SMBus is still busy, we give up */ 146 - if (timeout >= MAX_TIMEOUT) { 146 + if (timeout > MAX_TIMEOUT) { 147 147 dev_dbg(&adap->dev, "Completion timeout!\n"); 148 148 goto abort; 149 149 }
+4 -4
drivers/i2c/busses/i2c-i801.c
··· 237 237 status = inb_p(SMBHSTSTS); 238 238 } while ((status & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_TIMEOUT)); 239 239 240 - result = i801_check_post(status, timeout >= MAX_TIMEOUT); 240 + result = i801_check_post(status, timeout > MAX_TIMEOUT); 241 241 if (result < 0) 242 242 return result; 243 243 ··· 257 257 } while ((!(status & SMBHSTSTS_INTR)) 258 258 && (timeout++ < MAX_TIMEOUT)); 259 259 260 - if (timeout >= MAX_TIMEOUT) { 260 + if (timeout > MAX_TIMEOUT) 261 261 dev_dbg(&I801_dev->dev, "PEC Timeout!\n"); 262 - } 262 + 263 263 outb_p(status, SMBHSTSTS); 264 264 } 265 265 ··· 344 344 while ((!(status & SMBHSTSTS_BYTE_DONE)) 345 345 && (timeout++ < MAX_TIMEOUT)); 346 346 347 - result = i801_check_post(status, timeout >= MAX_TIMEOUT); 347 + result = i801_check_post(status, timeout > MAX_TIMEOUT); 348 348 if (result < 0) 349 349 return result; 350 350
+1 -1
drivers/i2c/busses/i2c-isch.c
··· 112 112 } while ((temp & 0x08) && (timeout++ < MAX_TIMEOUT)); 113 113 114 114 /* If the SMBus is still busy, we give up */ 115 - if (timeout >= MAX_TIMEOUT) { 115 + if (timeout > MAX_TIMEOUT) { 116 116 dev_err(&sch_adapter.dev, "SMBus Timeout!\n"); 117 117 result = -ETIMEDOUT; 118 118 }
+1 -1
drivers/i2c/busses/i2c-nforce2.c
··· 173 173 temp = inb_p(NVIDIA_SMB_STS); 174 174 } while ((!temp) && (timeout++ < MAX_TIMEOUT)); 175 175 176 - if (timeout >= MAX_TIMEOUT) { 176 + if (timeout > MAX_TIMEOUT) { 177 177 dev_dbg(&adap->dev, "SMBus Timeout!\n"); 178 178 if (smbus->can_abort) 179 179 nforce2_abort(adap);
+1 -1
drivers/i2c/busses/i2c-sis5595.c
··· 256 256 } while (!(temp & 0x40) && (timeout++ < MAX_TIMEOUT)); 257 257 258 258 /* If the SMBus is still busy, we give up */ 259 - if (timeout >= MAX_TIMEOUT) { 259 + if (timeout > MAX_TIMEOUT) { 260 260 dev_dbg(&adap->dev, "SMBus Timeout!\n"); 261 261 result = -ETIMEDOUT; 262 262 }
+1 -1
drivers/i2c/busses/i2c-sis630.c
··· 173 173 } while (!(temp & 0x0e) && (timeout++ < MAX_TIMEOUT)); 174 174 175 175 /* If the SMBus is still busy, we give up */ 176 - if (timeout >= MAX_TIMEOUT) { 176 + if (timeout > MAX_TIMEOUT) { 177 177 dev_dbg(&adap->dev, "SMBus Timeout!\n"); 178 178 result = -ETIMEDOUT; 179 179 }
+1 -1
drivers/i2c/busses/i2c-sis96x.c
··· 132 132 } while (!(temp & 0x0e) && (timeout++ < MAX_TIMEOUT)); 133 133 134 134 /* If the SMBus is still busy, we give up */ 135 - if (timeout >= MAX_TIMEOUT) { 135 + if (timeout > MAX_TIMEOUT) { 136 136 dev_dbg(&sis96x_adapter.dev, "SMBus Timeout! (0x%02x)\n", temp); 137 137 result = -ETIMEDOUT; 138 138 }