summaryrefslogtreecommitdiff
path: root/drivers/i2c/busses/i2c-amd8111.c
diff options
context:
space:
mode:
authorRoel Kluin <roel.kluin@gmail.com>2009-02-24 18:19:48 (GMT)
committerJean Delvare <khali@linux-fr.org>2009-02-24 18:19:48 (GMT)
commita746b578d8406b2db0e9f0d040061bc1f78433cf (patch)
treece79fc247342fa9fde8ad184a4ec39d70ce0012a /drivers/i2c/busses/i2c-amd8111.c
parentf29d2e0275a4f03ef2fd158e484508dcb0c64efb (diff)
downloadlinux-fsl-qoriq-a746b578d8406b2db0e9f0d040061bc1f78433cf.tar.xz
i2c: Timeouts reach -1
With a postfix decrement these timeouts reach -1 rather than 0, but after the loop it is tested whether they have become 0. As pointed out by Jean Delvare, the condition we are waiting for should also be tested before the timeout. With the current order, you could exit with a timeout error while the job is actually done. Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c/busses/i2c-amd8111.c')
-rw-r--r--drivers/i2c/busses/i2c-amd8111.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c
index edab519..a7c5990 100644
--- a/drivers/i2c/busses/i2c-amd8111.c
+++ b/drivers/i2c/busses/i2c-amd8111.c
@@ -72,7 +72,7 @@ static unsigned int amd_ec_wait_write(struct amd_smbus *smbus)
{
int timeout = 500;
- while (timeout-- && (inb(smbus->base + AMD_EC_SC) & AMD_EC_SC_IBF))
+ while ((inb(smbus->base + AMD_EC_SC) & AMD_EC_SC_IBF) && --timeout)
udelay(1);
if (!timeout) {
@@ -88,7 +88,7 @@ static unsigned int amd_ec_wait_read(struct amd_smbus *smbus)
{
int timeout = 500;
- while (timeout-- && (~inb(smbus->base + AMD_EC_SC) & AMD_EC_SC_OBF))
+ while ((~inb(smbus->base + AMD_EC_SC) & AMD_EC_SC_OBF) && --timeout)
udelay(1);
if (!timeout) {