Skip to content

Commit

Permalink
hwmon/ams: Fix I2C read retry logic
Browse files Browse the repository at this point in the history
Fix sleep and retry logic in ams-i2c.

Signed-off-by: Stelian Pop <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
  • Loading branch information
stelian42 authored and Jean Delvare committed May 8, 2007
1 parent 2d8dd65 commit 63232dc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/hwmon/ams/ams-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,17 @@ static int ams_i2c_write(u8 reg, u8 value)
static int ams_i2c_cmd(enum ams_i2c_cmd cmd)
{
s32 result;
int remaining = HZ / 20;
int count = 3;

ams_i2c_write(AMS_COMMAND, cmd);
mdelay(5);
msleep(5);

while (remaining) {
while (count--) {
result = ams_i2c_read(AMS_COMMAND);
if (result == 0 || result & 0x80)
return 0;

remaining = schedule_timeout(remaining);
schedule_timeout_uninterruptible(HZ / 20);
}

return -1;
Expand Down

0 comments on commit 63232dc

Please sign in to comment.