Commit 3b36fb8471f8639d565b69c9a456a3ef9413df59
1 parent
abfd336cd7
[SPARC64] bbc_i2c: Fix kenvctrld eating %100 cpu.
Based almost entirely upon a patch by Joerg Friedrich Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 9 additions and 8 deletions Side-by-side Diff
drivers/sbus/char/bbc_i2c.c
... | ... | @@ -187,19 +187,20 @@ |
187 | 187 | bp->waiting = 1; |
188 | 188 | add_wait_queue(&bp->wq, &wait); |
189 | 189 | while (limit-- > 0) { |
190 | - u8 val; | |
190 | + unsigned long val; | |
191 | 191 | |
192 | - set_current_state(TASK_INTERRUPTIBLE); | |
193 | - *status = val = readb(bp->i2c_control_regs + 0); | |
194 | - if ((val & I2C_PCF_PIN) == 0) { | |
192 | + val = wait_event_interruptible_timeout( | |
193 | + bp->wq, | |
194 | + (((*status = readb(bp->i2c_control_regs + 0)) | |
195 | + & I2C_PCF_PIN) == 0), | |
196 | + msecs_to_jiffies(250)); | |
197 | + if (val > 0) { | |
195 | 198 | ret = 0; |
196 | 199 | break; |
197 | 200 | } |
198 | - msleep_interruptible(250); | |
199 | 201 | } |
200 | 202 | remove_wait_queue(&bp->wq, &wait); |
201 | 203 | bp->waiting = 0; |
202 | - current->state = TASK_RUNNING; | |
203 | 204 | |
204 | 205 | return ret; |
205 | 206 | } |
... | ... | @@ -340,7 +341,7 @@ |
340 | 341 | */ |
341 | 342 | if (bp->waiting && |
342 | 343 | !(readb(bp->i2c_control_regs + 0x0) & I2C_PCF_PIN)) |
343 | - wake_up(&bp->wq); | |
344 | + wake_up_interruptible(&bp->wq); | |
344 | 345 | |
345 | 346 | return IRQ_HANDLED; |
346 | 347 | } |