Commit 3113fa59 authored by Maximilian Attems's avatar Maximilian Attems Committed by Russell King

[SERIAL] replace schedule_timeout() with msleep/msleep_interruptible()

Use msleep()/msleep_interruptible() [as appropriate]
instead of schedule_timeout() to guarantee the task delays
as expected.

Signed-off-by: Nishanth Aravamudan
Signed-off-by: Maximilian Attems
Signed-off-by: default avatarRussell King <rmk@arm.linux.org.uk>
parent eff783a1
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/delay.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/irq.h> #include <asm/irq.h>
...@@ -997,7 +998,7 @@ static void send_break( struct m68k_serial * info, int duration) ...@@ -997,7 +998,7 @@ static void send_break( struct m68k_serial * info, int duration)
unsigned long flags; unsigned long flags;
if (!info->port) if (!info->port)
return; return;
current->state = TASK_INTERRUPTIBLE; set_current_state(TASK_INTERRUPTIBLE);
save_flags(flags); save_flags(flags);
cli(); cli();
#ifdef USE_INTS #ifdef USE_INTS
...@@ -1189,8 +1190,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) ...@@ -1189,8 +1190,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
#endif #endif
if (info->blocked_open) { if (info->blocked_open) {
if (info->close_delay) { if (info->close_delay) {
current->state = TASK_INTERRUPTIBLE; msleep_interruptible(jiffies_to_msecs(info->close_delay));
schedule_timeout(info->close_delay);
} }
wake_up_interruptible(&info->open_wait); wake_up_interruptible(&info->open_wait);
} }
......
...@@ -1396,7 +1396,7 @@ static void end_break(ser_info_t *info) ...@@ -1396,7 +1396,7 @@ static void end_break(ser_info_t *info)
*/ */
static void send_break(ser_info_t *info, int duration) static void send_break(ser_info_t *info, int duration)
{ {
current->state = TASK_INTERRUPTIBLE; set_current_state(TASK_INTERRUPTIBLE);
#ifdef SERIAL_DEBUG_SEND_BREAK #ifdef SERIAL_DEBUG_SEND_BREAK
printk("rs_send_break(%d) jiff=%lu...", duration, jiffies); printk("rs_send_break(%d) jiff=%lu...", duration, jiffies);
#endif #endif
...@@ -1707,8 +1707,7 @@ static void rs_360_close(struct tty_struct *tty, struct file * filp) ...@@ -1707,8 +1707,7 @@ static void rs_360_close(struct tty_struct *tty, struct file * filp)
info->tty = 0; info->tty = 0;
if (info->blocked_open) { if (info->blocked_open) {
if (info->close_delay) { if (info->close_delay) {
current->state = TASK_INTERRUPTIBLE; msleep_interruptible(jiffies_to_msecs(info->close_delay));
schedule_timeout(info->close_delay);
} }
wake_up_interruptible(&info->open_wait); wake_up_interruptible(&info->open_wait);
} }
...@@ -1761,9 +1760,8 @@ static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout) ...@@ -1761,9 +1760,8 @@ static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout)
#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
printk("lsr = %d (jiff=%lu)...", lsr, jiffies); printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
#endif #endif
current->state = TASK_INTERRUPTIBLE;
/* current->counter = 0; make us low-priority */ /* current->counter = 0; make us low-priority */
schedule_timeout(char_time); msleep_interruptible(jiffies_to_msecs(char_time));
if (signal_pending(current)) if (signal_pending(current))
break; break;
if (timeout && ((orig_jiffies + timeout) < jiffies)) if (timeout && ((orig_jiffies + timeout) < jiffies))
......
...@@ -140,12 +140,6 @@ static inline void trace(struct icom_port *, char *, unsigned long) {}; ...@@ -140,12 +140,6 @@ static inline void trace(struct icom_port *, char *, unsigned long) {};
static inline void trace(struct icom_port *icom_port, char *trace_pt, unsigned long trace_data) {}; static inline void trace(struct icom_port *icom_port, char *trace_pt, unsigned long trace_data) {};
#endif #endif
static void msleep(unsigned long msecs)
{
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(MSECS_TO_JIFFIES(msecs));
}
static void free_port_memory(struct icom_port *icom_port) static void free_port_memory(struct icom_port *icom_port)
{ {
struct pci_dev *dev = icom_port->adapter->pci_dev; struct pci_dev *dev = icom_port->adapter->pci_dev;
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/console.h> #include <linux/console.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/delay.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/irq.h> #include <asm/irq.h>
...@@ -978,7 +979,7 @@ static void send_break( struct mcf_serial * info, int duration) ...@@ -978,7 +979,7 @@ static void send_break( struct mcf_serial * info, int duration)
if (!info->addr) if (!info->addr)
return; return;
current->state = TASK_INTERRUPTIBLE; set_current_state(TASK_INTERRUPTIBLE);
uartp = info->addr; uartp = info->addr;
local_irq_save(flags); local_irq_save(flags);
...@@ -1230,8 +1231,7 @@ static void mcfrs_close(struct tty_struct *tty, struct file * filp) ...@@ -1230,8 +1231,7 @@ static void mcfrs_close(struct tty_struct *tty, struct file * filp)
#endif #endif
if (info->blocked_open) { if (info->blocked_open) {
if (info->close_delay) { if (info->close_delay) {
current->state = TASK_INTERRUPTIBLE; msleep_interruptible(jiffies_to_msecs(info->close_delay));
schedule_timeout(info->close_delay);
} }
wake_up_interruptible(&info->open_wait); wake_up_interruptible(&info->open_wait);
} }
...@@ -1296,8 +1296,7 @@ mcfrs_wait_until_sent(struct tty_struct *tty, int timeout) ...@@ -1296,8 +1296,7 @@ mcfrs_wait_until_sent(struct tty_struct *tty, int timeout)
fifo_cnt++; fifo_cnt++;
if (fifo_cnt == 0) if (fifo_cnt == 0)
break; break;
set_current_state(TASK_INTERRUPTIBLE); msleep_interruptible(jiffies_to_msecs(char_time));
schedule_timeout(char_time);
if (signal_pending(current)) if (signal_pending(current))
break; break;
if (timeout && time_after(jiffies, orig_jiffies + timeout)) if (timeout && time_after(jiffies, orig_jiffies + timeout))
......
...@@ -949,8 +949,7 @@ static int pmz_startup(struct uart_port *port) ...@@ -949,8 +949,7 @@ static int pmz_startup(struct uart_port *port)
*/ */
if (pwr_delay != 0) { if (pwr_delay != 0) {
pmz_debug("pmz: delaying %d ms\n", pwr_delay); pmz_debug("pmz: delaying %d ms\n", pwr_delay);
set_current_state(TASK_UNINTERRUPTIBLE); msleep(pwr_delay);
schedule_timeout((pwr_delay * HZ)/1000);
} }
/* IrDA reset is done now */ /* IrDA reset is done now */
...@@ -1684,8 +1683,7 @@ static int pmz_resume(struct macio_dev *mdev) ...@@ -1684,8 +1683,7 @@ static int pmz_resume(struct macio_dev *mdev)
*/ */
if (pwr_delay != 0) { if (pwr_delay != 0) {
pmz_debug("pmz: delaying %d ms\n", pwr_delay); pmz_debug("pmz: delaying %d ms\n", pwr_delay);
set_current_state(TASK_UNINTERRUPTIBLE); msleep(pwr_delay);
schedule_timeout((pwr_delay * HZ)/1000);
} }
pmz_debug("resume, switching complete\n"); pmz_debug("resume, switching complete\n");
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/serial.h> /* for serial_state and serial_icounter_struct */ #include <linux/serial.h> /* for serial_state and serial_icounter_struct */
#include <linux/delay.h>
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -1219,8 +1220,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp) ...@@ -1219,8 +1220,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
if (state->info->blocked_open) { if (state->info->blocked_open) {
if (state->close_delay) { if (state->close_delay) {
set_current_state(TASK_INTERRUPTIBLE); msleep_interruptible(jiffies_to_msecs(state->close_delay));
schedule_timeout(state->close_delay);
} }
} else if (!uart_console(port)) { } else if (!uart_console(port)) {
uart_change_pm(state, 3); uart_change_pm(state, 3);
...@@ -1285,8 +1285,7 @@ static void uart_wait_until_sent(struct tty_struct *tty, int timeout) ...@@ -1285,8 +1285,7 @@ static void uart_wait_until_sent(struct tty_struct *tty, int timeout)
* we wait. * we wait.
*/ */
while (!port->ops->tx_empty(port)) { while (!port->ops->tx_empty(port)) {
set_current_state(TASK_INTERRUPTIBLE); msleep_interruptible(jiffies_to_msecs(char_time));
schedule_timeout(char_time);
if (signal_pending(current)) if (signal_pending(current))
break; break;
if (time_after(jiffies, expire)) if (time_after(jiffies, expire))
...@@ -1843,10 +1842,8 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *port) ...@@ -1843,10 +1842,8 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *port)
* Wait for the transmitter to empty. * Wait for the transmitter to empty.
*/ */
while (!ops->tx_empty(port)) { while (!ops->tx_empty(port)) {
set_current_state(TASK_UNINTERRUPTIBLE); msleep(10);
schedule_timeout(10*HZ/1000);
} }
set_current_state(TASK_RUNNING);
ops->shutdown(port); ops->shutdown(port);
} }
......
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