fix timeouts
This commit is contained in:
@@ -34,7 +34,6 @@
|
|||||||
|
|
||||||
extern void start_timeout(void);
|
extern void start_timeout(void);
|
||||||
extern int end_timeout(long msec);
|
extern int end_timeout(long msec);
|
||||||
extern void udelay(long usec);
|
|
||||||
|
|
||||||
/* --- setting states on the bus with the right timing: --------------- */
|
/* --- setting states on the bus with the right timing: --------------- */
|
||||||
|
|
||||||
@@ -103,7 +102,7 @@ static void i2c_repstart(struct i2c_algo_bit_data *adap)
|
|||||||
/* scl, sda may not be high */
|
/* scl, sda may not be high */
|
||||||
setsda(adap, 1);
|
setsda(adap, 1);
|
||||||
sclhi(adap);
|
sclhi(adap);
|
||||||
wait_ms(adap->udelay);
|
wait_us(adap->udelay);
|
||||||
sdalo(adap);
|
sdalo(adap);
|
||||||
scllo(adap);
|
scllo(adap);
|
||||||
}
|
}
|
||||||
@@ -137,9 +136,10 @@ static int i2c_outb(struct i2c_adapter *i2c_adap, char c)
|
|||||||
{
|
{
|
||||||
sb = c & (1 << i);
|
sb = c & (1 << i);
|
||||||
setsda(adap,sb);
|
setsda(adap,sb);
|
||||||
wait_ms(adap->udelay);
|
wait_us(adap->udelay);
|
||||||
if (sclhi(adap) < 0)
|
if (sclhi(adap) < 0)
|
||||||
{ /* timed out */
|
{
|
||||||
|
/* timed out */
|
||||||
sdahi(adap); /* we don't want to block the net */
|
sdahi(adap); /* we don't want to block the net */
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
dbg("ETIMEDOUT\r\n");
|
dbg("ETIMEDOUT\r\n");
|
||||||
@@ -156,17 +156,17 @@ static int i2c_outb(struct i2c_adapter *i2c_adap, char c)
|
|||||||
if(sclhi(adap)<0)
|
if(sclhi(adap)<0)
|
||||||
{
|
{
|
||||||
/* timeout */
|
/* timeout */
|
||||||
#ifdef DEBUG
|
|
||||||
dbg("ETIMEDOUT\r\n");
|
dbg("ETIMEDOUT\r\n");
|
||||||
#endif
|
|
||||||
return -110;
|
return -110;
|
||||||
}
|
}
|
||||||
/* read ack: SDA should be pulled down by slave */
|
/* read ack: SDA should be pulled down by slave */
|
||||||
ack = getsda(adap); /* ack: sda is pulled low ->success. */
|
ack = getsda(adap); /* ack: sda is pulled low ->success. */
|
||||||
scllo(adap);
|
scllo(adap);
|
||||||
#ifdef DEBUG
|
|
||||||
dbg("0x%02x, ack=0x%02x\r\n", (unsigned long)(c & 0xff), ack);
|
dbg("0x%02x, ack=0x%02x\r\n", (unsigned long)(c & 0xff), ack);
|
||||||
#endif
|
|
||||||
return 0 == ack; /* return 1 if device acked */
|
return 0 == ack; /* return 1 if device acked */
|
||||||
/* assert: scl is low (sda undef) */
|
/* assert: scl is low (sda undef) */
|
||||||
}
|
}
|
||||||
@@ -185,9 +185,7 @@ static int i2c_inb(struct i2c_adapter *i2c_adap)
|
|||||||
if (sclhi(adap) < 0)
|
if (sclhi(adap) < 0)
|
||||||
{
|
{
|
||||||
/* timeout */
|
/* timeout */
|
||||||
#ifdef DEBUG
|
|
||||||
dbg("i2c_inb TIMEDOUT\r\n");
|
dbg("i2c_inb TIMEDOUT\r\n");
|
||||||
#endif
|
|
||||||
return -110;
|
return -110;
|
||||||
}
|
}
|
||||||
indata *= 2;
|
indata *= 2;
|
||||||
@@ -196,9 +194,8 @@ static int i2c_inb(struct i2c_adapter *i2c_adap)
|
|||||||
scllo(adap);
|
scllo(adap);
|
||||||
}
|
}
|
||||||
/* assert: scl is low */
|
/* assert: scl is low */
|
||||||
#ifdef DEBUG
|
|
||||||
dbg("0x%02x\r\n", (unsigned long)(indata & 0xff));
|
dbg("0x%02x\r\n", (unsigned long)(indata & 0xff));
|
||||||
#endif
|
|
||||||
return (int) (indata & 0xff);
|
return (int) (indata & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,7 +324,8 @@ static inline int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
|
|||||||
else
|
else
|
||||||
sdahi(adap); /* neg. ack on last byte */
|
sdahi(adap); /* neg. ack on last byte */
|
||||||
if (sclhi(adap) < 0)
|
if (sclhi(adap) < 0)
|
||||||
{ /* timeout */
|
{
|
||||||
|
/* timeout */
|
||||||
sdahi(adap);
|
sdahi(adap);
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
@@ -448,14 +446,14 @@ int i2c_bit_add_bus(struct i2c_adapter *adap)
|
|||||||
}
|
}
|
||||||
/* register new adapter to i2c module... */
|
/* register new adapter to i2c module... */
|
||||||
adap->algo = &i2c_bit_algo;
|
adap->algo = &i2c_bit_algo;
|
||||||
adap->timeout = 100; /* default values, should */
|
adap->timeout = 10; /* default values, should */
|
||||||
adap->retries = 3; /* be replaced by defines */
|
adap->retries = 3; /* be replaced by defines */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i2c_bit_del_bus(struct i2c_adapter *adap)
|
int i2c_bit_del_bus(struct i2c_adapter *adap)
|
||||||
{
|
{
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------
|
/* ----------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user