diff options
author | Holger Waechtler <devnull@localhost> | 2003-03-19 06:29:05 +0000 |
---|---|---|
committer | Holger Waechtler <devnull@localhost> | 2003-03-19 06:29:05 +0000 |
commit | ffa323cf87fe8eddbdcaeb4f8ee1ed6a57700e68 (patch) | |
tree | 430daddc28566e406bc2f42a8e4cf466e51293d4 /linux/drivers/media/common | |
parent | 8348d0b85fea1dba5f500b1bb5dbc8ecfd3fcd5a (diff) | |
download | mediapointer-dvb-s2-ffa323cf87fe8eddbdcaeb4f8ee1ed6a57700e68.tar.gz mediapointer-dvb-s2-ffa323cf87fe8eddbdcaeb4f8ee1ed6a57700e68.tar.bz2 |
wait between i2c retries and don't bail out on adress errors,
patch conributed by Andrew de Quincey <adq_dvb@lidskialf.net>
Diffstat (limited to 'linux/drivers/media/common')
-rw-r--r-- | linux/drivers/media/common/saa7146_i2c.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/linux/drivers/media/common/saa7146_i2c.c b/linux/drivers/media/common/saa7146_i2c.c index b73803310..9a0092635 100644 --- a/linux/drivers/media/common/saa7146_i2c.c +++ b/linux/drivers/media/common/saa7146_i2c.c @@ -285,6 +285,7 @@ int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg msgs[], i int i = 0, count = 0; u32* buffer = dev->i2c_mem; int err = 0; + int address_err = 0; if (down_interruptible (&dev->i2c_lock)) return -ERESTARTSYS; @@ -312,9 +313,8 @@ int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg msgs[], i for(i = 0; i < count; i++) { err = saa7146_i2c_writeout(dev, &buffer[i] ); if ( 0 != err) { - /* if address-error occured, donīt retry */ if ( -EREMOTEIO == err ) { - goto out; + address_err++; } DEB_I2C(("error while sending message(s). starting again.\n")); break; @@ -324,15 +324,11 @@ int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg msgs[], i err = num; break; } + + /* delay a bit before retrying */ + my_wait(dev, 10); } while (err != num && retries--); - - /* if any things had to be read, get the results */ - if ( 0 != saa7146_i2c_msg_cleanup(msgs, num, buffer)) { - DEB_I2C(("could not cleanup i2c-message.\n")); - err = -1; - goto out; - } /* another bug in revision 0: the i2c-registers get uploaded randomly by other uploads, so we better clear them out before continueing */ @@ -342,6 +338,18 @@ int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg msgs[], i INFO(("revision 0 error. this should never happen.\n")); } } + + /* if every retry had an address error, exit right away */ + if (address_err == retries) { + goto out; + } + + /* if any things had to be read, get the results */ + if ( 0 != saa7146_i2c_msg_cleanup(msgs, num, buffer)) { + DEB_I2C(("could not cleanup i2c-message.\n")); + err = -1; + goto out; + } /* return the number of delivered messages */ DEB_I2C(("transmission successful. (msg:%d).\n",err)); |