From 74bf4482f441f45adb2b84655ac8a2abfa8598b3 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 18 Mar 2009 09:33:04 +0000 Subject: [PATCH] Patch from Roel Kluin, backported from Linux 2.6. 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. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-2.10@5687 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + kernel/busses/i2c-amd8111.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index b9e183af..ce9dbbed 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ lm_sensors CHANGES file SVN-HEAD File lm_sensors.lsm: Delete, don't advertise a legacy branch File doc/developers/release_checklist: Skip mail to lsm + Module i2c-amd8111: Fix timeout handling (2.6 backport) Module it87: Properly decode -128 degrees C (2.6 backport) Program sensors-detect: Fix detection of older DS1621 diff --git a/kernel/busses/i2c-amd8111.c b/kernel/busses/i2c-amd8111.c index a6bc973a..d3b7bfa4 100644 --- a/kernel/busses/i2c-amd8111.c +++ b/kernel/busses/i2c-amd8111.c @@ -79,7 +79,7 @@ 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) { @@ -94,7 +94,7 @@ 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) {