Added utility function i2c_delay(1), to replace various "do_pause"

(mmh) functions in bus drivers.  Backported from the 2.6 work of Greg KH.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1936 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Mark M. Hoffman committed 2003-08-03 05:11:58 +00:00
1 parent e49b5486aa
commit e035136982
11 files changed
+18 -101

No files matched your search

+2 -10
View File
@@ -136,7 +136,6 @@
/* -> Read = 1 */ /* -> Read = 1 */
#define ALI1535_SMBIO_EN 0x04 /* SMB I/O Space enable */ #define ALI1535_SMBIO_EN 0x04 /* SMB I/O Space enable */
static void ali1535_do_pause(unsigned int amount);
static int ali1535_transaction(void); static int ali1535_transaction(void);
static unsigned short ali1535_smba = 0; static unsigned short ali1535_smba = 0;
@@ -222,13 +221,6 @@ int ali1535_setup(struct pci_dev *ALI1535_dev)
} }
/* Internally used pause function */
void ali1535_do_pause(unsigned int amount)
{
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(amount);
}
/* Another internally used function */ /* Another internally used function */
int ali1535_transaction(void) int ali1535_transaction(void)
{ {
@@ -315,7 +307,7 @@ int ali1535_transaction(void)
/* 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));
@@ -401,7 +393,7 @@ 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) {
+2 -9
View File
@@ -223,13 +223,6 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)
return 0; return 0;
} }
/* 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)
{ {
@@ -302,7 +295,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));
@@ -359,7 +352,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) {
+3 -10
View File
@@ -94,13 +94,6 @@ static unsigned short amd756_ioport = 0;
*/ */
/* 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 +125,7 @@ static int amd756_transaction(void)
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)) {
pr_debug(DRV_NAME ": SMBus busy (%04x). Waiting... \n", temp); pr_debug(DRV_NAME ": 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 +142,7 @@ static int amd756_transaction(void)
/* 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 +189,7 @@ static int amd756_transaction(void)
abort: abort:
printk(KERN_WARNING DRV_NAME ": Sending abort.\n"); printk(KERN_WARNING DRV_NAME ": 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;
} }
+1 -2
View File
@@ -281,8 +281,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);
} }
+3 -10
View File
@@ -110,7 +110,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);
@@ -186,12 +185,6 @@ END:
} }
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;
@@ -221,7 +214,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));
@@ -349,7 +342,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));
@@ -409,7 +402,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));
+2 -17
View File
@@ -112,9 +112,6 @@ struct nforce2_smbus {
static s32 nforce2_access(struct i2c_adapter *adap, u16 addr, static s32 nforce2_access(struct i2c_adapter *adap, u16 addr,
unsigned short flags, char read_write, unsigned short flags, char read_write,
u8 command, int size, union i2c_smbus_data *data); u8 command, int size, union i2c_smbus_data *data);
#if 0
static void nforce2_do_pause(unsigned int amount);
#endif
/* /*
static int nforce2_block_transaction(union i2c_smbus_data *data, static int nforce2_block_transaction(union i2c_smbus_data *data,
char read_write, int i2c_enable); char read_write, int i2c_enable);
@@ -129,17 +126,6 @@ static struct i2c_algorithm smbus_algorithm = {
.functionality = nforce2_func, .functionality = nforce2_func,
}; };
#if 0
/* Internally used pause function */
void nforce2_do_pause(unsigned int amount)
{
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(amount);
}
#endif
/* Return -1 on error. See smbus.h for more information */ /* Return -1 on error. See smbus.h for more information */
s32 nforce2_access(struct i2c_adapter * adap, u16 addr, unsigned short flags, s32 nforce2_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
char read_write, u8 command, int size, char read_write, u8 command, int size,
@@ -250,7 +236,7 @@ s32 nforce2_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
#if 0 #if 0
do { do {
nforce2_do_pause(1); i2c_delay(1);
temp = inb_p(NVIDIA_SMB_STS); temp = inb_p(NVIDIA_SMB_STS);
} while (((temp & NVIDIA_SMB_STS_DONE) == 0) && (timeout++ < MAX_TIMEOUT)); } while (((temp & NVIDIA_SMB_STS_DONE) == 0) && (timeout++ < MAX_TIMEOUT));
#endif #endif
@@ -259,8 +245,7 @@ s32 nforce2_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
temp = inb_p(NVIDIA_SMB_STS); temp = inb_p(NVIDIA_SMB_STS);
} }
if (~temp & NVIDIA_SMB_STS_DONE) { if (~temp & NVIDIA_SMB_STS_DONE) {
current->state = TASK_INTERRUPTIBLE; i2c_delay(HZ/100);
schedule_timeout(HZ/100);
temp = inb_p(NVIDIA_SMB_STS); temp = inb_p(NVIDIA_SMB_STS);
} }
+1 -9
View File
@@ -100,7 +100,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);
@@ -235,13 +234,6 @@ static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id
} }
/* Internally used pause function */
void piix4_do_pause(unsigned int amount)
{
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(amount);
}
/* Another internally used function */ /* Another internally used function */
int piix4_transaction(void) int piix4_transaction(void)
{ {
@@ -280,7 +272,7 @@ 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));
+1 -9
View File
@@ -131,7 +131,6 @@ MODULE_PARM(force_addr, "i");
MODULE_PARM_DESC(force_addr, MODULE_PARM_DESC(force_addr,
"Initialize the base address of the i2c controller"); "Initialize the base address of the i2c controller");
static void sis5595_do_pause(unsigned int amount);
static int sis5595_transaction(void); static int sis5595_transaction(void);
static unsigned short sis5595_base = 0; static unsigned short sis5595_base = 0;
@@ -228,13 +227,6 @@ int sis5595_setup(struct pci_dev *SIS5595_dev)
} }
/* Internally used pause function */
void sis5595_do_pause(unsigned int amount)
{
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(amount);
}
/* Another internally used function */ /* Another internally used function */
int sis5595_transaction(void) int sis5595_transaction(void)
{ {
@@ -273,7 +265,7 @@ int sis5595_transaction(void)
/* We will always wait for a fraction of a second! */ /* We will always wait for a fraction of a second! */
do { do {
sis5595_do_pause(1); i2c_delay(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));
+1 -9
View File
@@ -127,14 +127,6 @@ static inline void sis630_write(u8 reg, u8 data) {
outb(data, acpi_base + reg); outb(data, acpi_base + reg);
} }
/* Internally used pause function */
static void sis630_do_pause(unsigned int amount)
{
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(amount);
}
static int sis630_transaction_start(int size, u8 *oldclock) { static int sis630_transaction_start(int size, u8 *oldclock) {
int temp; int temp;
@@ -180,7 +172,7 @@ static int sis630_transaction_wait(int size) {
/* We will always wait for a fraction of a second! */ /* We will always wait for a fraction of a second! */
do { do {
sis630_do_pause(1); i2c_delay(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))
+1 -8
View File
@@ -294,13 +294,6 @@ static int __devinit sis645_hotplug_smbus(void)
} }
#endif /* CONFIG_HOTPLUG */ #endif /* CONFIG_HOTPLUG */
/* Internally used pause function */
static void sis645_do_pause(unsigned int amount)
{
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(amount);
}
/* Execute a SMBus transaction. /* Execute a SMBus transaction.
int size is from SIS645_QUICK to SIS645_BLOCK_DATA int size is from SIS645_QUICK to SIS645_BLOCK_DATA
*/ */
@@ -345,7 +338,7 @@ static int sis645_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 {
sis645_do_pause(1); i2c_delay(1);
temp = sis645_read(SMB_STS); temp = sis645_read(SMB_STS);
} while (!(temp & 0x0e) && (timeout++ < MAX_TIMEOUT)); } while (!(temp & 0x0e) && (timeout++ < MAX_TIMEOUT));
+1 -8
View File
@@ -105,13 +105,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)
{ {
@@ -145,7 +138,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));