Skip to content

Commit

Permalink
i2c-isch: Decrease delay in command completion check loop
Browse files Browse the repository at this point in the history
Generally it is not needed to wait for 1 msec, the SMBus get often ready
in less than 200 usecs.

msleep(1) can wait up to 20 msecs... It has a significant impact when
there is a burst of transactions on the bus.

Signed-off-by: Olivier Sobrie <olivier@sobrie.be>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
  • Loading branch information
Olivier Sobrie authored and Jean Delvare committed Mar 26, 2012
1 parent c54c355 commit b3240e6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/i2c/busses/i2c-isch.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#define SMBBLKDAT (0x20 + sch_smba)

/* Other settings */
#define MAX_TIMEOUT 500
#define MAX_RETRIES 5000

/* I2C constants */
#define SCH_QUICK 0x00
Expand All @@ -68,7 +68,7 @@ static int sch_transaction(void)
{
int temp;
int result = 0;
int timeout = 0;
int retries = 0;

dev_dbg(&sch_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, "
"ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb(SMBHSTCNT),
Expand Down Expand Up @@ -100,12 +100,12 @@ static int sch_transaction(void)
outb(inb(SMBHSTCNT) | 0x10, SMBHSTCNT);

do {
msleep(1);
usleep_range(100, 200);
temp = inb(SMBHSTSTS) & 0x0f;
} while ((temp & 0x08) && (timeout++ < MAX_TIMEOUT));
} while ((temp & 0x08) && (retries++ < MAX_RETRIES));

/* If the SMBus is still busy, we give up */
if (timeout > MAX_TIMEOUT) {
if (retries > MAX_RETRIES) {
dev_err(&sch_adapter.dev, "SMBus Timeout!\n");
result = -ETIMEDOUT;
}
Expand Down

0 comments on commit b3240e6

Please sign in to comment.