diff options
author | Hartmut Birr <e9hack@googlemail.com> | 2006-11-01 11:01:42 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-12-10 06:05:34 -0500 |
commit | 35e55255bbe1775c3cdb5d9cff494d72d5a49bf3 (patch) | |
tree | 20846c296d0d4c7c7335cd5b55a2440e47ef4eed | |
parent | 88bbdf74fcfa7ed1fd1a3c825ee5575752344326 (diff) |
V4L/DVB (4915): Saa7146: Add timeout protection for I2C interrupt
Add a timeout to the wait for the i2c-interrupt.
The timeout prevents from endless waiting if the
interrupt gets lost.
Signed-off-by: Hartmut Birr <e9hack@googlemail.com>
Signed-off-by: Oliver Endriss <o.endriss@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | drivers/media/common/saa7146_i2c.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c index 5297a365c928..8c85efc26527 100644 --- a/drivers/media/common/saa7146_i2c.c +++ b/drivers/media/common/saa7146_i2c.c | |||
@@ -189,13 +189,21 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d | |||
189 | saa7146_write(dev, I2C_TRANSFER, *dword); | 189 | saa7146_write(dev, I2C_TRANSFER, *dword); |
190 | 190 | ||
191 | dev->i2c_op = 1; | 191 | dev->i2c_op = 1; |
192 | SAA7146_ISR_CLEAR(dev, MASK_16|MASK_17); | ||
192 | SAA7146_IER_ENABLE(dev, MASK_16|MASK_17); | 193 | SAA7146_IER_ENABLE(dev, MASK_16|MASK_17); |
193 | saa7146_write(dev, MC2, (MASK_00 | MASK_16)); | 194 | saa7146_write(dev, MC2, (MASK_00 | MASK_16)); |
194 | 195 | ||
195 | wait_event_interruptible(dev->i2c_wq, dev->i2c_op == 0); | 196 | timeout = HZ/100 + 1; /* 10ms */ |
196 | if (signal_pending (current)) { | 197 | timeout = wait_event_interruptible_timeout(dev->i2c_wq, dev->i2c_op == 0, timeout); |
197 | /* a signal arrived */ | 198 | if (timeout == -ERESTARTSYS || dev->i2c_op) { |
198 | return -ERESTARTSYS; | 199 | SAA7146_IER_DISABLE(dev, MASK_16|MASK_17); |
200 | SAA7146_ISR_CLEAR(dev, MASK_16|MASK_17); | ||
201 | if (timeout == -ERESTARTSYS) | ||
202 | /* a signal arrived */ | ||
203 | return -ERESTARTSYS; | ||
204 | |||
205 | printk(KERN_WARNING "saa7146_i2c_writeout: timed out waiting for end of xfer\n"); | ||
206 | return -EIO; | ||
199 | } | 207 | } |
200 | status = saa7146_read(dev, I2C_STATUS); | 208 | status = saa7146_read(dev, I2C_STATUS); |
201 | } else { | 209 | } else { |