Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Re: Erroneous unsupported PLL synthesizer: found it!!



> >>No. The right fix for this problem is to insert real delays (preferably
> >>ddelay() calls of the average length of one or two i2c messages) in the
> >>retry loop in the saa-i2c driver. Otherwise you'll get into these
> >>problems again when you buy your next, faster PC.
> >>
> >>Would you be willing to implement this and send a patch?

Here you are.. this should also still report address errors correctly.


-- 
adq

-- 
adq
Index: linux/drivers/media/common/saa7146_i2c.c
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/common/saa7146_i2c.c,v
retrieving revision 1.11
diff -u -r1.11 saa7146_i2c.c
--- linux/drivers/media/common/saa7146_i2c.c	13 Jan 2003 17:24:16 -0000	1.11
+++ linux/drivers/media/common/saa7146_i2c.c	18 Mar 2003 12:27:42 -0000
@@ -285,6 +285,7 @@
 	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 @@
 		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 @@
 			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 */	
@@ -341,6 +337,18 @@
 		if( 0 != saa7146_i2c_writeout(dev, &zero)) {
 			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 */

Home | Main Index | Thread Index