Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] parport: fix-up schedule_timeout() usage

Use schedule_timeout_interruptible() instead of
set_current_state()/schedule_timeout() to reduce kernel size. Also use
human-time to jiffies units conversion functions rather than direct HZ
division to avoid rounding issues.

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Nishanth Aravamudan and committed by
Linus Torvalds
7b4ccf8d da4cd8df

+8 -12
+3 -4
drivers/parport/ieee1284.c
··· 196 196 return 1; 197 197 198 198 /* 40ms of slow polling. */ 199 - deadline = jiffies + (HZ + 24) / 25; 199 + deadline = jiffies + msecs_to_jiffies(40); 200 200 while (time_before (jiffies, deadline)) { 201 201 int ret; 202 202 ··· 205 205 206 206 /* Wait for 10ms (or until an interrupt occurs if 207 207 * the handler is set) */ 208 - if ((ret = parport_wait_event (port, (HZ + 99) / 100)) < 0) 208 + if ((ret = parport_wait_event (port, msecs_to_jiffies(10))) < 0) 209 209 return ret; 210 210 211 211 status = parport_read_status (port); ··· 216 216 /* parport_wait_event didn't time out, but the 217 217 * peripheral wasn't actually ready either. 218 218 * Wait for another 10ms. */ 219 - __set_current_state (TASK_INTERRUPTIBLE); 220 - schedule_timeout ((HZ+ 99) / 100); 219 + schedule_timeout_interruptible(msecs_to_jiffies(10)); 221 220 } 222 221 } 223 222
+4 -6
drivers/parport/ieee1284_ops.c
··· 60 60 parport_data_forward (port); 61 61 while (count < len) { 62 62 unsigned long expire = jiffies + dev->timeout; 63 - long wait = (HZ + 99) / 100; 63 + long wait = msecs_to_jiffies(10); 64 64 unsigned char mask = (PARPORT_STATUS_ERROR 65 65 | PARPORT_STATUS_BUSY); 66 66 unsigned char val = (PARPORT_STATUS_ERROR ··· 97 97 our interrupt handler called. */ 98 98 if (count && no_irq) { 99 99 parport_release (dev); 100 - __set_current_state (TASK_INTERRUPTIBLE); 101 - schedule_timeout (wait); 100 + schedule_timeout_interruptible(wait); 102 101 parport_claim_or_block (dev); 103 102 } 104 103 else ··· 541 542 /* Yield the port for a while. */ 542 543 if (count && dev->port->irq != PARPORT_IRQ_NONE) { 543 544 parport_release (dev); 544 - __set_current_state (TASK_INTERRUPTIBLE); 545 - schedule_timeout ((HZ + 24) / 25); 545 + schedule_timeout_interruptible(msecs_to_jiffies(40)); 546 546 parport_claim_or_block (dev); 547 547 } 548 548 else 549 549 /* We must have the device claimed here. */ 550 - parport_wait_event (port, (HZ + 24) / 25); 550 + parport_wait_event (port, msecs_to_jiffies(40)); 551 551 552 552 /* Is there a signal pending? */ 553 553 if (signal_pending (current))
+1 -2
drivers/parport/parport_pc.c
··· 173 173 if (time_after_eq (jiffies, expire)) 174 174 /* The FIFO is stuck. */ 175 175 return -EBUSY; 176 - __set_current_state (TASK_INTERRUPTIBLE); 177 - schedule_timeout ((HZ + 99) / 100); 176 + schedule_timeout_interruptible(msecs_to_jiffies(10)); 178 177 if (signal_pending (current)) 179 178 break; 180 179 }