[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>
This commit is contained in:
Родитель
da4cd8dfe1
Коммит
7b4ccf8db4
|
@ -196,7 +196,7 @@ int parport_wait_peripheral(struct parport *port,
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* 40ms of slow polling. */
|
/* 40ms of slow polling. */
|
||||||
deadline = jiffies + (HZ + 24) / 25;
|
deadline = jiffies + msecs_to_jiffies(40);
|
||||||
while (time_before (jiffies, deadline)) {
|
while (time_before (jiffies, deadline)) {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ int parport_wait_peripheral(struct parport *port,
|
||||||
|
|
||||||
/* Wait for 10ms (or until an interrupt occurs if
|
/* Wait for 10ms (or until an interrupt occurs if
|
||||||
* the handler is set) */
|
* the handler is set) */
|
||||||
if ((ret = parport_wait_event (port, (HZ + 99) / 100)) < 0)
|
if ((ret = parport_wait_event (port, msecs_to_jiffies(10))) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
status = parport_read_status (port);
|
status = parport_read_status (port);
|
||||||
|
@ -216,8 +216,7 @@ int parport_wait_peripheral(struct parport *port,
|
||||||
/* parport_wait_event didn't time out, but the
|
/* parport_wait_event didn't time out, but the
|
||||||
* peripheral wasn't actually ready either.
|
* peripheral wasn't actually ready either.
|
||||||
* Wait for another 10ms. */
|
* Wait for another 10ms. */
|
||||||
__set_current_state (TASK_INTERRUPTIBLE);
|
schedule_timeout_interruptible(msecs_to_jiffies(10));
|
||||||
schedule_timeout ((HZ+ 99) / 100);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ size_t parport_ieee1284_write_compat (struct parport *port,
|
||||||
parport_data_forward (port);
|
parport_data_forward (port);
|
||||||
while (count < len) {
|
while (count < len) {
|
||||||
unsigned long expire = jiffies + dev->timeout;
|
unsigned long expire = jiffies + dev->timeout;
|
||||||
long wait = (HZ + 99) / 100;
|
long wait = msecs_to_jiffies(10);
|
||||||
unsigned char mask = (PARPORT_STATUS_ERROR
|
unsigned char mask = (PARPORT_STATUS_ERROR
|
||||||
| PARPORT_STATUS_BUSY);
|
| PARPORT_STATUS_BUSY);
|
||||||
unsigned char val = (PARPORT_STATUS_ERROR
|
unsigned char val = (PARPORT_STATUS_ERROR
|
||||||
|
@ -97,8 +97,7 @@ size_t parport_ieee1284_write_compat (struct parport *port,
|
||||||
our interrupt handler called. */
|
our interrupt handler called. */
|
||||||
if (count && no_irq) {
|
if (count && no_irq) {
|
||||||
parport_release (dev);
|
parport_release (dev);
|
||||||
__set_current_state (TASK_INTERRUPTIBLE);
|
schedule_timeout_interruptible(wait);
|
||||||
schedule_timeout (wait);
|
|
||||||
parport_claim_or_block (dev);
|
parport_claim_or_block (dev);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -542,13 +541,12 @@ size_t parport_ieee1284_ecp_read_data (struct parport *port,
|
||||||
/* Yield the port for a while. */
|
/* Yield the port for a while. */
|
||||||
if (count && dev->port->irq != PARPORT_IRQ_NONE) {
|
if (count && dev->port->irq != PARPORT_IRQ_NONE) {
|
||||||
parport_release (dev);
|
parport_release (dev);
|
||||||
__set_current_state (TASK_INTERRUPTIBLE);
|
schedule_timeout_interruptible(msecs_to_jiffies(40));
|
||||||
schedule_timeout ((HZ + 24) / 25);
|
|
||||||
parport_claim_or_block (dev);
|
parport_claim_or_block (dev);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* We must have the device claimed here. */
|
/* We must have the device claimed here. */
|
||||||
parport_wait_event (port, (HZ + 24) / 25);
|
parport_wait_event (port, msecs_to_jiffies(40));
|
||||||
|
|
||||||
/* Is there a signal pending? */
|
/* Is there a signal pending? */
|
||||||
if (signal_pending (current))
|
if (signal_pending (current))
|
||||||
|
|
|
@ -173,8 +173,7 @@ static int change_mode(struct parport *p, int m)
|
||||||
if (time_after_eq (jiffies, expire))
|
if (time_after_eq (jiffies, expire))
|
||||||
/* The FIFO is stuck. */
|
/* The FIFO is stuck. */
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
__set_current_state (TASK_INTERRUPTIBLE);
|
schedule_timeout_interruptible(msecs_to_jiffies(10));
|
||||||
schedule_timeout ((HZ + 99) / 100);
|
|
||||||
if (signal_pending (current))
|
if (signal_pending (current))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче