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