Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c-isch: Decrease delay in command completion check loop

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>

authored by

Olivier Sobrie and committed by
Jean Delvare
b3240e68 c54c3557

+5 -5
+5 -5
drivers/i2c/busses/i2c-isch.c
··· 47 47 #define SMBBLKDAT (0x20 + sch_smba) 48 48 49 49 /* Other settings */ 50 - #define MAX_TIMEOUT 500 50 + #define MAX_RETRIES 5000 51 51 52 52 /* I2C constants */ 53 53 #define SCH_QUICK 0x00 ··· 68 68 { 69 69 int temp; 70 70 int result = 0; 71 - int timeout = 0; 71 + int retries = 0; 72 72 73 73 dev_dbg(&sch_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, " 74 74 "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb(SMBHSTCNT), ··· 100 100 outb(inb(SMBHSTCNT) | 0x10, SMBHSTCNT); 101 101 102 102 do { 103 - msleep(1); 103 + usleep_range(100, 200); 104 104 temp = inb(SMBHSTSTS) & 0x0f; 105 - } while ((temp & 0x08) && (timeout++ < MAX_TIMEOUT)); 105 + } while ((temp & 0x08) && (retries++ < MAX_RETRIES)); 106 106 107 107 /* If the SMBus is still busy, we give up */ 108 - if (timeout > MAX_TIMEOUT) { 108 + if (retries > MAX_RETRIES) { 109 109 dev_err(&sch_adapter.dev, "SMBus Timeout!\n"); 110 110 result = -ETIMEDOUT; 111 111 }