Based almost entirely upon a patch by Joerg Friedrich
Signed-off-by: David S. Miller <davem@davemloft.net>
bp->waiting = 1;
add_wait_queue(&bp->wq, &wait);
while (limit-- > 0) {
bp->waiting = 1;
add_wait_queue(&bp->wq, &wait);
while (limit-- > 0) {
- u8 val;
-
- set_current_state(TASK_INTERRUPTIBLE);
- *status = val = readb(bp->i2c_control_regs + 0);
- if ((val & I2C_PCF_PIN) == 0) {
+ unsigned long val;
+
+ val = wait_event_interruptible_timeout(
+ bp->wq,
+ (((*status = readb(bp->i2c_control_regs + 0))
+ & I2C_PCF_PIN) == 0),
+ msecs_to_jiffies(250));
+ if (val > 0) {
- msleep_interruptible(250);
}
remove_wait_queue(&bp->wq, &wait);
bp->waiting = 0;
}
remove_wait_queue(&bp->wq, &wait);
bp->waiting = 0;
- current->state = TASK_RUNNING;
*/
if (bp->waiting &&
!(readb(bp->i2c_control_regs + 0x0) & I2C_PCF_PIN))
*/
if (bp->waiting &&
!(readb(bp->i2c_control_regs + 0x0) & I2C_PCF_PIN))
+ wake_up_interruptible(&bp->wq);