summaryrefslogtreecommitdiff
path: root/linux/drivers/media/common
diff options
context:
space:
mode:
authorMichael Hunold <devnull@localhost>2002-12-25 20:18:26 +0000
committerMichael Hunold <devnull@localhost>2002-12-25 20:18:26 +0000
commit2f1f60e8ab3a7541e13d25e0f50f23ed86eb4066 (patch)
treede2d7ef4aacc921e42f0bb806aa2afbd08fc59dc /linux/drivers/media/common
parent96dc63cd3ca635f5e626e16a04b9f15887d026f6 (diff)
downloadmediapointer-dvb-s2-2f1f60e8ab3a7541e13d25e0f50f23ed86eb4066.tar.gz
mediapointer-dvb-s2-2f1f60e8ab3a7541e13d25e0f50f23ed86eb4066.tar.bz2
As promised, I changed the "retry-loop" to the style of the "old" saa7146
driver. I doesn't do any harm for my analog drivers and apparently fixes some bugs related to some frontends/tuners, who expect certain start/stop cycles. Please check if these tuners work now...
Diffstat (limited to 'linux/drivers/media/common')
-rw-r--r--linux/drivers/media/common/saa7146_i2c.c46
1 files changed, 15 insertions, 31 deletions
diff --git a/linux/drivers/media/common/saa7146_i2c.c b/linux/drivers/media/common/saa7146_i2c.c
index 1a2781da6..1b3455dac 100644
--- a/linux/drivers/media/common/saa7146_i2c.c
+++ b/linux/drivers/media/common/saa7146_i2c.c
@@ -68,7 +68,8 @@ int saa7146_i2c_msg_prepare(const struct i2c_msg m[], int num, u32 *op)
for(i = 0; i < num; i++) {
/* insert the address of the i2c-slave.
- note: we get 7 bit i2c-addresses, so we have to perform a translation */
+ note: we get 7 bit i2c-addresses,
+ so we have to perform a translation */
addr = (m[i].addr*2) + ( (0 != (m[i].flags & I2C_M_RD)) ? 1 : 0);
h1 = op_count/3; h2 = op_count%3;
op[h1] |= ( (u8)addr << ((3-h2)*8));
@@ -77,7 +78,6 @@ int saa7146_i2c_msg_prepare(const struct i2c_msg m[], int num, u32 *op)
/* loop through all bytes of message i */
for(j = 0; j < m[i].len; j++) {
-
/* insert the data bytes */
h1 = op_count/3; h2 = op_count%3;
op[h1] |= ( (u32)((u8)m[i].buf[j]) << ((3-h2)*8));
@@ -278,15 +278,12 @@ if( 0 != use_i2c_irq ) {
*dword = saa7146_read(dev, I2C_TRANSFER);
DEB_I2C(("after: 0x%08x\n",*dword));
-
- saa7146_i2c_status(dev);
-
return 0;
}
-int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg msgs[], int num, int retries)
+int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg msgs[], int num, int retries)
{
- int i = 0, result = 0, count = 0;
+ int i = 0, count = 0;
u32* buffer = dev->i2c_mem;
int err = 0;
@@ -303,43 +300,33 @@ int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg msgs[], i
err = -1;
goto out;
}
-
- /* loop through number of retries ... */
- for(; retries >= 0; retries--) {
-
+
+ do {
/* reset the i2c-device if necessary */
- result = saa7146_i2c_reset(dev);
- if ( 0 > result ) {
+ err = saa7146_i2c_reset(dev);
+ if ( 0 > err ) {
DEB_I2C(("could not reset i2c-device.\n"));
- err = -1;
goto out;
}
/* write out the u32s one after another */
for(i = 0; i < count; i++) {
-
- result = saa7146_i2c_writeout(dev, &buffer[i] );
- if ( 0 != result) {
+ err = saa7146_i2c_writeout(dev, &buffer[i] );
+ if ( 0 != err) {
/* if address-error occured, donīt retry */
- if ( -2 == result ) {
- err = -1;
+ if ( -2 == err ) {
goto out;
}
DEB_I2C(("error while sending message(s). starting again.\n"));
break;
}
}
-
- /* see if an error occured & the last retry failed */
- if( (0 != result) && (0 == retries) ) {
- DEB_I2C(("could not transfer i2c-message(s).\n"));
- err = -1;
- goto out;
+ if( 0 == err ) {
+ err = num;
+ break;
}
- if( 0 == result )
- break;
- }
+ } while (err != num && retries--);
/* if any things had to be read, get the results */
if ( 0 != saa7146_i2c_msg_cleanup(msgs, num, buffer)) {
@@ -348,8 +335,6 @@ int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg msgs[], i
goto out;
}
- saa7146_i2c_status(dev);
-
/* another bug in revision 0: the i2c-registers get uploaded randomly by other
uploads, so we better clear them out before continueing */
if( 0 == dev->revision ) {
@@ -360,7 +345,6 @@ int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg msgs[], i
}
/* return the number of delivered messages */
- err = num;
DEB_I2C(("transmission successful. (msg:%d).\n",err));
out:
up(&dev->i2c_lock);