Commit a8e9fcec authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

I2C: change i2c_delay() to use msleep() instead.

parent 3f3f36e1
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/delay.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -276,7 +277,7 @@ static int ali1535_transaction(struct i2c_adapter *adap) ...@@ -276,7 +277,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
/* 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 {
i2c_delay(1); msleep(1);
temp = inb_p(SMBHSTSTS); temp = inb_p(SMBHSTSTS);
} while (((temp & ALI1535_STS_BUSY) && !(temp & ALI1535_STS_IDLE)) } while (((temp & ALI1535_STS_BUSY) && !(temp & ALI1535_STS_IDLE))
&& (timeout++ < MAX_TIMEOUT)); && (timeout++ < MAX_TIMEOUT));
...@@ -350,7 +351,7 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, ...@@ -350,7 +351,7 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
for (timeout = 0; for (timeout = 0;
(timeout < MAX_TIMEOUT) && !(temp & ALI1535_STS_IDLE); (timeout < MAX_TIMEOUT) && !(temp & ALI1535_STS_IDLE);
timeout++) { timeout++) {
i2c_delay(1); msleep(1);
temp = inb_p(SMBHSTSTS); temp = inb_p(SMBHSTSTS);
} }
if (timeout >= MAX_TIMEOUT) if (timeout >= MAX_TIMEOUT)
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/delay.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -82,7 +83,7 @@ static int ali1563_transaction(struct i2c_adapter * a) ...@@ -82,7 +83,7 @@ static int ali1563_transaction(struct i2c_adapter * a)
timeout = ALI1563_MAX_TIMEOUT; timeout = ALI1563_MAX_TIMEOUT;
do do
i2c_delay(1); msleep(1);
while (((data = inb_p(SMB_HST_STS)) & HST_STS_BUSY) && --timeout); while (((data = inb_p(SMB_HST_STS)) & HST_STS_BUSY) && --timeout);
dev_dbg(&a->dev, "Transaction (post): STS=%02x, CNTL1=%02x, " dev_dbg(&a->dev, "Transaction (post): STS=%02x, CNTL1=%02x, "
...@@ -137,7 +138,7 @@ static int ali1563_block_start(struct i2c_adapter * a) ...@@ -137,7 +138,7 @@ static int ali1563_block_start(struct i2c_adapter * a)
timeout = ALI1563_MAX_TIMEOUT; timeout = ALI1563_MAX_TIMEOUT;
do do
i2c_delay(1); msleep(1);
while (!((data = inb_p(SMB_HST_STS)) & HST_STS_DONE) && --timeout); while (!((data = inb_p(SMB_HST_STS)) & HST_STS_DONE) && --timeout);
dev_dbg(&a->dev, "Block (post): STS=%02x, CNTL1=%02x, " dev_dbg(&a->dev, "Block (post): STS=%02x, CNTL1=%02x, "
......
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/delay.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/init.h> #include <linux/init.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -296,7 +297,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap) ...@@ -296,7 +297,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
/* 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 {
i2c_delay(1); msleep(1);
temp = inb_p(SMBHSTSTS); temp = inb_p(SMBHSTSTS);
} while ((!(temp & (ALI15X3_STS_ERR | ALI15X3_STS_DONE))) } while ((!(temp & (ALI15X3_STS_ERR | ALI15X3_STS_DONE)))
&& (timeout++ < MAX_TIMEOUT)); && (timeout++ < MAX_TIMEOUT));
...@@ -353,7 +354,7 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, ...@@ -353,7 +354,7 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
for (timeout = 0; for (timeout = 0;
(timeout < MAX_TIMEOUT) && !(temp & ALI15X3_STS_IDLE); (timeout < MAX_TIMEOUT) && !(temp & ALI15X3_STS_IDLE);
timeout++) { timeout++) {
i2c_delay(1); msleep(1);
temp = inb_p(SMBHSTSTS); temp = inb_p(SMBHSTSTS);
} }
if (timeout >= MAX_TIMEOUT) { if (timeout >= MAX_TIMEOUT) {
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/ioport.h> #include <linux/ioport.h>
...@@ -124,7 +125,7 @@ static int amd756_transaction(struct i2c_adapter *adap) ...@@ -124,7 +125,7 @@ static int amd756_transaction(struct i2c_adapter *adap)
if ((temp = inw_p(SMB_GLOBAL_STATUS)) & (GS_HST_STS | GS_SMB_STS)) { if ((temp = inw_p(SMB_GLOBAL_STATUS)) & (GS_HST_STS | GS_SMB_STS)) {
dev_dbg(&adap->dev, ": SMBus busy (%04x). Waiting... \n", temp); dev_dbg(&adap->dev, ": SMBus busy (%04x). Waiting... \n", temp);
do { do {
i2c_delay(1); msleep(1);
temp = inw_p(SMB_GLOBAL_STATUS); temp = inw_p(SMB_GLOBAL_STATUS);
} while ((temp & (GS_HST_STS | GS_SMB_STS)) && } while ((temp & (GS_HST_STS | GS_SMB_STS)) &&
(timeout++ < MAX_TIMEOUT)); (timeout++ < MAX_TIMEOUT));
...@@ -141,7 +142,7 @@ static int amd756_transaction(struct i2c_adapter *adap) ...@@ -141,7 +142,7 @@ static int amd756_transaction(struct i2c_adapter *adap)
/* We will always wait for a fraction of a second! */ /* We will always wait for a fraction of a second! */
do { do {
i2c_delay(1); msleep(1);
temp = inw_p(SMB_GLOBAL_STATUS); temp = inw_p(SMB_GLOBAL_STATUS);
} while ((temp & GS_HST_STS) && (timeout++ < MAX_TIMEOUT)); } while ((temp & GS_HST_STS) && (timeout++ < MAX_TIMEOUT));
...@@ -188,7 +189,7 @@ static int amd756_transaction(struct i2c_adapter *adap) ...@@ -188,7 +189,7 @@ static int amd756_transaction(struct i2c_adapter *adap)
abort: abort:
dev_warn(&adap->dev, ": Sending abort.\n"); dev_warn(&adap->dev, ": Sending abort.\n");
outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE); outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE);
i2c_delay(100); msleep(100);
outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS); outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS);
return -1; return -1;
} }
......
...@@ -276,7 +276,7 @@ s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags, ...@@ -276,7 +276,7 @@ s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
} }
if (~temp[0] & AMD_SMB_STS_DONE) { if (~temp[0] & AMD_SMB_STS_DONE) {
i2c_delay(HZ/100); msleep(1);
amd_ec_read(smbus, AMD_SMB_STS, temp + 0); amd_ec_read(smbus, AMD_SMB_STS, temp + 0);
} }
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/delay.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -207,7 +208,7 @@ static int i801_transaction(void) ...@@ -207,7 +208,7 @@ static int i801_transaction(void)
/* We will always wait for a fraction of a second! */ /* We will always wait for a fraction of a second! */
do { do {
i2c_delay(1); msleep(1);
temp = inb_p(SMBHSTSTS); temp = inb_p(SMBHSTSTS);
} while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT)); } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
...@@ -335,7 +336,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write, ...@@ -335,7 +336,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
timeout = 0; timeout = 0;
do { do {
temp = inb_p(SMBHSTSTS); temp = inb_p(SMBHSTSTS);
i2c_delay(1); msleep(1);
} }
while ((!(temp & 0x80)) while ((!(temp & 0x80))
&& (timeout++ < MAX_TIMEOUT)); && (timeout++ < MAX_TIMEOUT));
...@@ -395,7 +396,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write, ...@@ -395,7 +396,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
timeout = 0; timeout = 0;
do { do {
temp = inb_p(SMBHSTSTS); temp = inb_p(SMBHSTSTS);
i2c_delay(1); msleep(1);
} while ((!(temp & 0x02)) } while ((!(temp & 0x02))
&& (timeout++ < MAX_TIMEOUT)); && (timeout++ < MAX_TIMEOUT));
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/ioport.h> #include <linux/ioport.h>
...@@ -260,7 +261,7 @@ static int piix4_transaction(void) ...@@ -260,7 +261,7 @@ static int piix4_transaction(void)
/* We will always wait for a fraction of a second! (See PIIX4 docs errata) */ /* We will always wait for a fraction of a second! (See PIIX4 docs errata) */
do { do {
i2c_delay(1); msleep(1);
temp = inb_p(SMBHSTSTS); temp = inb_p(SMBHSTSTS);
} while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT)); } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/delay.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -239,7 +240,7 @@ static int sis5595_transaction(struct i2c_adapter *adap) ...@@ -239,7 +240,7 @@ static int sis5595_transaction(struct i2c_adapter *adap)
/* We will always wait for a fraction of a second! */ /* We will always wait for a fraction of a second! */
do { do {
i2c_delay(1); msleep(1);
temp = sis5595_read(SMB_STS_LO); temp = sis5595_read(SMB_STS_LO);
} while (!(temp & 0x40) && (timeout++ < MAX_TIMEOUT)); } while (!(temp & 0x40) && (timeout++ < MAX_TIMEOUT));
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/delay.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -165,7 +166,7 @@ static int sis630_transaction_wait(struct i2c_adapter *adap, int size) ...@@ -165,7 +166,7 @@ static int sis630_transaction_wait(struct i2c_adapter *adap, int size)
/* We will always wait for a fraction of a second! */ /* We will always wait for a fraction of a second! */
do { do {
i2c_delay(1); msleep(1);
temp = sis630_read(SMB_STS); temp = sis630_read(SMB_STS);
/* check if block transmitted */ /* check if block transmitted */
if (size == SIS630_BLOCK_DATA && (temp & 0x10)) if (size == SIS630_BLOCK_DATA && (temp & 0x10))
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/ioport.h> #include <linux/ioport.h>
...@@ -139,7 +140,7 @@ static int sis96x_transaction(int size) ...@@ -139,7 +140,7 @@ static int sis96x_transaction(int size)
/* We will always wait for a fraction of a second! */ /* We will always wait for a fraction of a second! */
do { do {
i2c_delay(1); msleep(1);
temp = sis96x_read(SMB_STS); temp = sis96x_read(SMB_STS);
} while (!(temp & 0x0e) && (timeout++ < MAX_TIMEOUT)); } while (!(temp & 0x0e) && (timeout++ < MAX_TIMEOUT));
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/delay.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/stddef.h> #include <linux/stddef.h>
...@@ -138,7 +139,7 @@ static int vt596_transaction(void) ...@@ -138,7 +139,7 @@ static int vt596_transaction(void)
/* We will always wait for a fraction of a second! /* We will always wait for a fraction of a second!
I don't know if VIA needs this, Intel did */ I don't know if VIA needs this, Intel did */
do { do {
i2c_delay(1); msleep(1);
temp = inb_p(SMBHSTSTS); temp = inb_p(SMBHSTSTS);
} while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT)); } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/delay.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/i2c.h> #include <linux/i2c.h>
...@@ -284,7 +285,7 @@ static u8 w83l785ts_read_value(struct i2c_client *client, u8 reg, u8 defval) ...@@ -284,7 +285,7 @@ static u8 w83l785ts_read_value(struct i2c_client *client, u8 reg, u8 defval)
if (value >= 0) if (value >= 0)
return value; return value;
dev_dbg(&client->dev, "Read failed, will retry in %d.\n", i); dev_dbg(&client->dev, "Read failed, will retry in %d.\n", i);
i2c_delay(i); msleep(i);
} }
dev_err(&client->dev, "Couldn't read value from register. " dev_err(&client->dev, "Couldn't read value from register. "
......
...@@ -601,11 +601,4 @@ union i2c_smbus_data { ...@@ -601,11 +601,4 @@ union i2c_smbus_data {
#define i2c_is_isa_adapter(adapptr) \ #define i2c_is_isa_adapter(adapptr) \
((adapptr)->algo->id == I2C_ALGO_ISA) ((adapptr)->algo->id == I2C_ALGO_ISA)
/* Tiny delay function used by the i2c bus drivers */
static inline void i2c_delay(signed long timeout)
{
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(timeout);
}
#endif /* _LINUX_I2C_H */ #endif /* _LINUX_I2C_H */
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