Commit 35e55255 authored by Hartmut Birr's avatar Hartmut Birr Committed by Mauro Carvalho Chehab

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: default avatarHartmut Birr <e9hack@googlemail.com>
Signed-off-by: default avatarOliver Endriss <o.endriss@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 88bbdf74
...@@ -189,13 +189,21 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d ...@@ -189,13 +189,21 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d
saa7146_write(dev, I2C_TRANSFER, *dword); saa7146_write(dev, I2C_TRANSFER, *dword);
dev->i2c_op = 1; dev->i2c_op = 1;
SAA7146_ISR_CLEAR(dev, MASK_16|MASK_17);
SAA7146_IER_ENABLE(dev, MASK_16|MASK_17); SAA7146_IER_ENABLE(dev, MASK_16|MASK_17);
saa7146_write(dev, MC2, (MASK_00 | MASK_16)); saa7146_write(dev, MC2, (MASK_00 | MASK_16));
wait_event_interruptible(dev->i2c_wq, dev->i2c_op == 0); timeout = HZ/100 + 1; /* 10ms */
if (signal_pending (current)) { timeout = wait_event_interruptible_timeout(dev->i2c_wq, dev->i2c_op == 0, timeout);
/* a signal arrived */ if (timeout == -ERESTARTSYS || dev->i2c_op) {
return -ERESTARTSYS; SAA7146_IER_DISABLE(dev, MASK_16|MASK_17);
SAA7146_ISR_CLEAR(dev, MASK_16|MASK_17);
if (timeout == -ERESTARTSYS)
/* a signal arrived */
return -ERESTARTSYS;
printk(KERN_WARNING "saa7146_i2c_writeout: timed out waiting for end of xfer\n");
return -EIO;
} }
status = saa7146_read(dev, I2C_STATUS); status = saa7146_read(dev, I2C_STATUS);
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment