aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2012-03-26 15:47:19 -0400
committerJean Delvare <khali@endymion.delvare>2012-03-26 15:47:19 -0400
commit84c1af4c21d645a02a4780cdf61c7551d8e7bb56 (patch)
tree47ad0ea490045e73c6f4d757123ac4c95ea0a676 /drivers/i2c
parent062737fb6d90c632439b1f77ad6a4965cfc84a20 (diff)
i2c-i801: Use usleep_range to wait for command completion
Use usleep_range instead of msleep when waiting for command completion. Most SMBus commands complete in less than 2 jiffies so this brings a pleasant performance boost. Strongly inspired from a similar change by Olivier Sobrie to the i2c-isch driver. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Olivier Sobrie <olivier@sobrie.be>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-i801.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 07d0c9565fc5..ae2945a5e007 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -2,7 +2,7 @@
2 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, 2 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,
3 Philip Edelbrock <phil@netroedge.com>, and Mark D. Studebaker 3 Philip Edelbrock <phil@netroedge.com>, and Mark D. Studebaker
4 <mdsxyz123@yahoo.com> 4 <mdsxyz123@yahoo.com>
5 Copyright (C) 2007, 2008 Jean Delvare <khali@linux-fr.org> 5 Copyright (C) 2007 - 2012 Jean Delvare <khali@linux-fr.org>
6 Copyright (C) 2010 Intel Corporation, 6 Copyright (C) 2010 Intel Corporation,
7 David Woodhouse <dwmw2@infradead.org> 7 David Woodhouse <dwmw2@infradead.org>
8 8
@@ -106,7 +106,7 @@
106#define SMBHSTCNT_KILL 2 106#define SMBHSTCNT_KILL 2
107 107
108/* Other settings */ 108/* Other settings */
109#define MAX_TIMEOUT 100 109#define MAX_RETRIES 400
110#define ENABLE_INT9 0 /* set to 0x01 to enable - untested */ 110#define ENABLE_INT9 0 /* set to 0x01 to enable - untested */
111 111
112/* I801 command constants */ 112/* I801 command constants */
@@ -217,7 +217,7 @@ static int i801_check_post(struct i801_priv *priv, int status, int timeout)
217 dev_dbg(&priv->pci_dev->dev, "Terminating the current operation\n"); 217 dev_dbg(&priv->pci_dev->dev, "Terminating the current operation\n");
218 outb_p(inb_p(SMBHSTCNT(priv)) | SMBHSTCNT_KILL, 218 outb_p(inb_p(SMBHSTCNT(priv)) | SMBHSTCNT_KILL,
219 SMBHSTCNT(priv)); 219 SMBHSTCNT(priv));
220 msleep(1); 220 usleep_range(1000, 2000);
221 outb_p(inb_p(SMBHSTCNT(priv)) & (~SMBHSTCNT_KILL), 221 outb_p(inb_p(SMBHSTCNT(priv)) & (~SMBHSTCNT_KILL),
222 SMBHSTCNT(priv)); 222 SMBHSTCNT(priv));
223 223
@@ -274,11 +274,11 @@ static int i801_transaction(struct i801_priv *priv, int xact)
274 274
275 /* We will always wait for a fraction of a second! */ 275 /* We will always wait for a fraction of a second! */
276 do { 276 do {
277 msleep(1); 277 usleep_range(250, 500);
278 status = inb_p(SMBHSTSTS(priv)); 278 status = inb_p(SMBHSTSTS(priv));
279 } while ((status & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_TIMEOUT)); 279 } while ((status & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_RETRIES));
280 280
281 result = i801_check_post(priv, status, timeout > MAX_TIMEOUT); 281 result = i801_check_post(priv, status, timeout > MAX_RETRIES);
282 if (result < 0) 282 if (result < 0)
283 return result; 283 return result;
284 284
@@ -293,12 +293,12 @@ static void i801_wait_hwpec(struct i801_priv *priv)
293 int status; 293 int status;
294 294
295 do { 295 do {
296 msleep(1); 296 usleep_range(250, 500);
297 status = inb_p(SMBHSTSTS(priv)); 297 status = inb_p(SMBHSTSTS(priv));
298 } while ((!(status & SMBHSTSTS_INTR)) 298 } while ((!(status & SMBHSTSTS_INTR))
299 && (timeout++ < MAX_TIMEOUT)); 299 && (timeout++ < MAX_RETRIES));
300 300
301 if (timeout > MAX_TIMEOUT) 301 if (timeout > MAX_RETRIES)
302 dev_dbg(&priv->pci_dev->dev, "PEC Timeout!\n"); 302 dev_dbg(&priv->pci_dev->dev, "PEC Timeout!\n");
303 303
304 outb_p(status, SMBHSTSTS(priv)); 304 outb_p(status, SMBHSTSTS(priv));
@@ -382,12 +382,12 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv,
382 /* We will always wait for a fraction of a second! */ 382 /* We will always wait for a fraction of a second! */
383 timeout = 0; 383 timeout = 0;
384 do { 384 do {
385 msleep(1); 385 usleep_range(250, 500);
386 status = inb_p(SMBHSTSTS(priv)); 386 status = inb_p(SMBHSTSTS(priv));
387 } while ((!(status & SMBHSTSTS_BYTE_DONE)) 387 } while ((!(status & SMBHSTSTS_BYTE_DONE))
388 && (timeout++ < MAX_TIMEOUT)); 388 && (timeout++ < MAX_RETRIES));
389 389
390 result = i801_check_post(priv, status, timeout > MAX_TIMEOUT); 390 result = i801_check_post(priv, status, timeout > MAX_RETRIES);
391 if (result < 0) 391 if (result < 0)
392 return result; 392 return result;
393 393