Hi,
it seems that the attached mail didn't arrive the mailing list.
- Hartmut
--- Begin Message ---
- To: linux-dvb@xxxxxxxxxxx
- Subject: [PATCH 2/3] Fix a timeout problem of the interrupt driven i2c-transfer of the SAA7146
- From: e9hack <e9hack@xxxxxxxxx>
- Date: Sat, 28 Oct 2006 11:30:50 +0200
- User-agent: Thunderbird 1.5.0.5 (Windows/20060719)
Hi,
the attached patch adds a timeout to the waiting for an interrupt after the executing of an i2c-operation. This prevents
against a endless waiting, if the SAA7146 does not hit the interrupt.
This patch needs my previous patch.
- Hartmut
Signed-of-by: Hartmut Birr <e9hack@xxxxxxxxxxxxxx>
Add a timeout to the wait for the i2c-interrupt.
The interrupt may never hit. The timeout prevents from endless waiting.
diff -r 5e9d301ef13b linux/drivers/media/common/saa7146_i2c.c
--- a/linux/drivers/media/common/saa7146_i2c.c Thu Oct 26 10:10:56 2006 -0300
+++ b/linux/drivers/media/common/saa7146_i2c.c Sat Oct 28 10:03:44 2006 +0200
@@ -193,10 +193,22 @@ static int saa7146_i2c_writeout(struct s
SAA7146_IER_ENABLE(dev, MASK_16|MASK_17);
saa7146_write(dev, MC2, (MASK_00 | MASK_16));
- wait_event_interruptible(dev->i2c_wq, dev->i2c_op == 0);
- if (signal_pending (current)) {
- /* a signal arrived */
- return -ERESTARTSYS;
+ timeout = HZ/100 + 1; /* 10ms */
+ timeout = wait_event_interruptible_timeout(dev->i2c_wq, dev->i2c_op == 0, timeout);
+ if (timeout == -ERESTARTSYS || dev->i2c_op) {
+ spin_lock_irqsave(&dev->slock, flags);
+ SAA7146_IER_DISABLE(dev, MASK_16|MASK_17);
+ saa7146_write(dev, ISR, MASK_16|MASK_17);
+ spin_unlock_irqrestore(&dev->slock, flags);
+ if (timeout == -ERESTARTSYS) {
+ /* a signal arrived */
+ return -ERESTARTSYS;
+ }
+ /* this is normal when probing the bus
+ * (no answer from nonexisistant device...)
+ */
+ DEB_I2C(("saa7146_i2c_writeout: timed out waiting for end of xfer\n"));
+ return -EIO;
}
status = saa7146_read(dev, I2C_STATUS);
} else {
--- End Message ---
_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb