fix timeouts

This commit is contained in:
Markus Fröschle
2016-12-18 07:14:13 +00:00
parent 52d1d95814
commit 784bb0c085

View File

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