Commit 84c1af4c authored by Jean Delvare's avatar Jean Delvare Committed by Jean Delvare

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: default avatarJean Delvare <khali@linux-fr.org>
Cc: Olivier Sobrie <olivier@sobrie.be>
parent 062737fb
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,
Philip Edelbrock <phil@netroedge.com>, and Mark D. Studebaker Philip Edelbrock <phil@netroedge.com>, and Mark D. Studebaker
<mdsxyz123@yahoo.com> <mdsxyz123@yahoo.com>
Copyright (C) 2007, 2008 Jean Delvare <khali@linux-fr.org> Copyright (C) 2007 - 2012 Jean Delvare <khali@linux-fr.org>
Copyright (C) 2010 Intel Corporation, Copyright (C) 2010 Intel Corporation,
David Woodhouse <dwmw2@infradead.org> David Woodhouse <dwmw2@infradead.org>
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
#define SMBHSTCNT_KILL 2 #define SMBHSTCNT_KILL 2
/* Other settings */ /* Other settings */
#define MAX_TIMEOUT 100 #define MAX_RETRIES 400
#define ENABLE_INT9 0 /* set to 0x01 to enable - untested */ #define ENABLE_INT9 0 /* set to 0x01 to enable - untested */
/* I801 command constants */ /* I801 command constants */
...@@ -217,7 +217,7 @@ static int i801_check_post(struct i801_priv *priv, int status, int timeout) ...@@ -217,7 +217,7 @@ static int i801_check_post(struct i801_priv *priv, int status, int timeout)
dev_dbg(&priv->pci_dev->dev, "Terminating the current operation\n"); dev_dbg(&priv->pci_dev->dev, "Terminating the current operation\n");
outb_p(inb_p(SMBHSTCNT(priv)) | SMBHSTCNT_KILL, outb_p(inb_p(SMBHSTCNT(priv)) | SMBHSTCNT_KILL,
SMBHSTCNT(priv)); SMBHSTCNT(priv));
msleep(1); usleep_range(1000, 2000);
outb_p(inb_p(SMBHSTCNT(priv)) & (~SMBHSTCNT_KILL), outb_p(inb_p(SMBHSTCNT(priv)) & (~SMBHSTCNT_KILL),
SMBHSTCNT(priv)); SMBHSTCNT(priv));
...@@ -274,11 +274,11 @@ static int i801_transaction(struct i801_priv *priv, int xact) ...@@ -274,11 +274,11 @@ static int i801_transaction(struct i801_priv *priv, int xact)
/* We will always wait for a fraction of a second! */ /* We will always wait for a fraction of a second! */
do { do {
msleep(1); usleep_range(250, 500);
status = inb_p(SMBHSTSTS(priv)); status = inb_p(SMBHSTSTS(priv));
} while ((status & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_TIMEOUT)); } while ((status & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_RETRIES));
result = i801_check_post(priv, status, timeout > MAX_TIMEOUT); result = i801_check_post(priv, status, timeout > MAX_RETRIES);
if (result < 0) if (result < 0)
return result; return result;
...@@ -293,12 +293,12 @@ static void i801_wait_hwpec(struct i801_priv *priv) ...@@ -293,12 +293,12 @@ static void i801_wait_hwpec(struct i801_priv *priv)
int status; int status;
do { do {
msleep(1); usleep_range(250, 500);
status = inb_p(SMBHSTSTS(priv)); status = inb_p(SMBHSTSTS(priv));
} while ((!(status & SMBHSTSTS_INTR)) } while ((!(status & SMBHSTSTS_INTR))
&& (timeout++ < MAX_TIMEOUT)); && (timeout++ < MAX_RETRIES));
if (timeout > MAX_TIMEOUT) if (timeout > MAX_RETRIES)
dev_dbg(&priv->pci_dev->dev, "PEC Timeout!\n"); dev_dbg(&priv->pci_dev->dev, "PEC Timeout!\n");
outb_p(status, SMBHSTSTS(priv)); outb_p(status, SMBHSTSTS(priv));
...@@ -382,12 +382,12 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, ...@@ -382,12 +382,12 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv,
/* We will always wait for a fraction of a second! */ /* We will always wait for a fraction of a second! */
timeout = 0; timeout = 0;
do { do {
msleep(1); usleep_range(250, 500);
status = inb_p(SMBHSTSTS(priv)); status = inb_p(SMBHSTSTS(priv));
} while ((!(status & SMBHSTSTS_BYTE_DONE)) } while ((!(status & SMBHSTSTS_BYTE_DONE))
&& (timeout++ < MAX_TIMEOUT)); && (timeout++ < MAX_RETRIES));
result = i801_check_post(priv, status, timeout > MAX_TIMEOUT); result = i801_check_post(priv, status, timeout > MAX_RETRIES);
if (result < 0) if (result < 0)
return result; return result;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment