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