]> Pileus Git - ~andy/linux/blobdiff - drivers/char/amiserial.c
Merge branch 'for-linus' of git://neil.brown.name/md
[~andy/linux] / drivers / char / amiserial.c
index 1b21a7adeb58fa1ca598d5a7241fbc2627574c14..a11c8c9ca3d4b858029205f9a265b6ee96b04fdb 100644 (file)
@@ -1528,6 +1528,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
 {
        struct async_struct * info = tty->driver_data;
        unsigned long orig_jiffies, char_time;
+       int tty_was_locked = tty_locked();
        int lsr;
 
        if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
@@ -1538,7 +1539,12 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
 
        orig_jiffies = jiffies;
 
-       tty_lock_nested(); /* tty_wait_until_sent is called from lots of places */
+       /*
+        * tty_wait_until_sent is called from lots of places,
+        * with or without the BTM.
+        */
+       if (!tty_was_locked)
+               tty_lock();
        /*
         * Set the check interval to be 1/5 of the estimated time to
         * send a single character, and make it at least 1.  The check
@@ -1579,7 +1585,8 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
                        break;
        }
        __set_current_state(TASK_RUNNING);
-       tty_unlock();
+       if (!tty_was_locked)
+               tty_unlock();
 #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
        printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
 #endif
@@ -1703,7 +1710,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
                printk("block_til_ready blocking: ttys%d, count = %d\n",
                       info->line, state->count);
 #endif
+               tty_unlock();
                schedule();
+               tty_lock();
        }
        __set_current_state(TASK_RUNNING);
        remove_wait_queue(&info->open_wait, &wait);