Commit 051efe45 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] I2C: consolidate the i2c delay functions.

parent 943295a9
......@@ -206,12 +206,6 @@ static int ali1535_setup(struct pci_dev *dev)
return retval;
}
static void ali1535_do_pause(unsigned int amount)
{
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(amount);
}
static int ali1535_transaction(struct i2c_adapter *adap)
{
int temp;
......@@ -283,7 +277,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
/* We will always wait for a fraction of a second! */
timeout = 0;
do {
ali1535_do_pause(1);
i2c_delay(1);
temp = inb_p(SMBHSTSTS);
} while (((temp & ALI1535_STS_BUSY) && !(temp & ALI1535_STS_IDLE))
&& (timeout++ < MAX_TIMEOUT));
......@@ -357,7 +351,7 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
for (timeout = 0;
(timeout < MAX_TIMEOUT) && !(temp & ALI1535_STS_IDLE);
timeout++) {
ali1535_do_pause(1);
i2c_delay(1);
temp = inb_p(SMBHSTSTS);
}
if (timeout >= MAX_TIMEOUT)
......
......@@ -225,13 +225,6 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)
return -ENODEV;
}
/* Internally used pause function */
static void ali15x3_do_pause(unsigned int amount)
{
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(amount);
}
/* Another internally used function */
static int ali15x3_transaction(struct i2c_adapter *adap)
{
......@@ -304,7 +297,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
/* We will always wait for a fraction of a second! */
timeout = 0;
do {
ali15x3_do_pause(1);
i2c_delay(1);
temp = inb_p(SMBHSTSTS);
} while ((!(temp & (ALI15X3_STS_ERR | ALI15X3_STS_DONE)))
&& (timeout++ < MAX_TIMEOUT));
......@@ -361,7 +354,7 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
for (timeout = 0;
(timeout < MAX_TIMEOUT) && !(temp & ALI15X3_STS_IDLE);
timeout++) {
ali15x3_do_pause(1);
i2c_delay(1);
temp = inb_p(SMBHSTSTS);
}
if (timeout >= MAX_TIMEOUT) {
......
......@@ -93,14 +93,6 @@ static unsigned short amd756_ioport = 0;
see E0 for the status bits and enabled in E2
*/
/* Internally used pause function */
static void amd756_do_pause(unsigned int amount)
{
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(amount);
}
#define GS_ABRT_STS (1 << 0)
#define GS_COL_STS (1 << 1)
#define GS_PRERR_STS (1 << 2)
......@@ -132,7 +124,7 @@ static int amd756_transaction(struct i2c_adapter *adap)
if ((temp = inw_p(SMB_GLOBAL_STATUS)) & (GS_HST_STS | GS_SMB_STS)) {
dev_dbg(&adap->dev, ": SMBus busy (%04x). Waiting... \n", temp);
do {
amd756_do_pause(1);
i2c_delay(1);
temp = inw_p(SMB_GLOBAL_STATUS);
} while ((temp & (GS_HST_STS | GS_SMB_STS)) &&
(timeout++ < MAX_TIMEOUT));
......@@ -149,7 +141,7 @@ static int amd756_transaction(struct i2c_adapter *adap)
/* We will always wait for a fraction of a second! */
do {
amd756_do_pause(1);
i2c_delay(1);
temp = inw_p(SMB_GLOBAL_STATUS);
} while ((temp & GS_HST_STS) && (timeout++ < MAX_TIMEOUT));
......@@ -196,7 +188,7 @@ static int amd756_transaction(struct i2c_adapter *adap)
abort:
dev_warn(&adap->dev, ": Sending abort.\n");
outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE);
amd756_do_pause(100);
i2c_delay(100);
outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS);
return -1;
}
......
......@@ -275,8 +275,7 @@ s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
}
if (~temp[0] & AMD_SMB_STS_DONE) {
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(HZ/100);
i2c_delay(HZ/100);
amd_ec_read(smbus, AMD_SMB_STS, temp + 0);
}
......
......@@ -103,7 +103,6 @@ MODULE_PARM_DESC(force_addr,
"Forcibly enable the I801 at the given address. "
"EXTREMELY DANGEROUS!");
static void i801_do_pause(unsigned int amount);
static int i801_transaction(void);
static int i801_block_transaction(union i2c_smbus_data *data,
char read_write, int command);
......@@ -178,13 +177,6 @@ static int i801_setup(struct pci_dev *dev)
return error_return;
}
static void i801_do_pause(unsigned int amount)
{
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(amount);
}
static int i801_transaction(void)
{
int temp;
......@@ -214,7 +206,7 @@ static int i801_transaction(void)
/* We will always wait for a fraction of a second! */
do {
i801_do_pause(1);
i2c_delay(1);
temp = inb_p(SMBHSTSTS);
} while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
......@@ -342,7 +334,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
timeout = 0;
do {
temp = inb_p(SMBHSTSTS);
i801_do_pause(1);
i2c_delay(1);
}
while ((!(temp & 0x80))
&& (timeout++ < MAX_TIMEOUT));
......@@ -402,7 +394,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
timeout = 0;
do {
temp = inb_p(SMBHSTSTS);
i801_do_pause(1);
i2c_delay(1);
} while ((!(temp & 0x02))
&& (timeout++ < MAX_TIMEOUT));
......
......@@ -99,7 +99,6 @@ MODULE_PARM_DESC(force_addr,
"Forcibly enable the PIIX4 at the given address. "
"EXTREMELY DANGEROUS!");
static void piix4_do_pause(unsigned int amount);
static int piix4_transaction(void);
......@@ -208,13 +207,6 @@ static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id
return error_return;
}
/* Internally used pause function */
static void piix4_do_pause(unsigned int amount)
{
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(amount);
}
/* Another internally used function */
static int piix4_transaction(void)
{
......@@ -245,7 +237,7 @@ static int piix4_transaction(void)
/* We will always wait for a fraction of a second! (See PIIX4 docs errata) */
do {
piix4_do_pause(1);
i2c_delay(1);
temp = inb_p(SMBHSTSTS);
} while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
......
......@@ -99,13 +99,6 @@ static inline void sis96x_write(u8 reg, u8 data)
outb(data, sis96x_smbus_base + reg) ;
}
/* Internally used pause function */
static void sis96x_do_pause(unsigned int amount)
{
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(amount);
}
/* Execute a SMBus transaction.
int size is from SIS96x_QUICK to SIS96x_BLOCK_DATA
*/
......@@ -147,7 +140,7 @@ static int sis96x_transaction(int size)
/* We will always wait for a fraction of a second! */
do {
sis96x_do_pause(1);
i2c_delay(1);
temp = sis96x_read(SMB_STS);
} while (!(temp & 0x0e) && (timeout++ < MAX_TIMEOUT));
......
......@@ -103,13 +103,6 @@ MODULE_PARM_DESC(force_addr,
static struct i2c_adapter vt596_adapter;
/* Internally used pause function */
static void vt596_do_pause(unsigned int amount)
{
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(amount);
}
/* Another internally used function */
static int vt596_transaction(void)
{
......@@ -143,7 +136,7 @@ static int vt596_transaction(void)
/* We will always wait for a fraction of a second!
I don't know if VIA needs this, Intel did */
do {
vt596_do_pause(1);
i2c_delay(1);
temp = inb_p(SMBHSTSTS);
} while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
......
......@@ -594,4 +594,11 @@ union i2c_smbus_data {
#define i2c_is_isa_adapter(adapptr) \
((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 */
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