headers: remove sched.h from interrupt.h
[safe/jmp/linux-2.6] / arch / um / drivers / line.c
index 83bf15a..cf8a97f 100644 (file)
@@ -5,9 +5,11 @@
 
 #include "linux/irqreturn.h"
 #include "linux/kd.h"
+#include "linux/sched.h"
 #include "chan_kern.h"
 #include "irq_kern.h"
 #include "irq_user.h"
+#include "kern_util.h"
 #include "os.h"
 
 #define LINE_BUFSIZE 4096
@@ -48,7 +50,7 @@ static int write_room(struct line *line)
        n = line->head - line->tail;
 
        if (n <= 0)
-               n = LINE_BUFSIZE + n; /* The other case */
+               n += LINE_BUFSIZE; /* The other case */
        return n - 1;
 }
 
@@ -58,17 +60,10 @@ int line_write_room(struct tty_struct *tty)
        unsigned long flags;
        int room;
 
-       if (tty->stopped)
-               return 0;
-
        spin_lock_irqsave(&line->lock, flags);
        room = write_room(line);
        spin_unlock_irqrestore(&line->lock, flags);
 
-       /*XXX: Warning to remove */
-       if (0 == room)
-               printk(KERN_DEBUG "%s: %s: no room left in buffer\n",
-                      __FUNCTION__,tty->name);
        return room;
 }
 
@@ -79,8 +74,7 @@ int line_chars_in_buffer(struct tty_struct *tty)
        int ret;
 
        spin_lock_irqsave(&line->lock, flags);
-
-       /*write_room subtracts 1 for the needed NULL, so we readd it.*/
+       /* write_room subtracts 1 for the needed NULL, so we readd it.*/
        ret = LINE_BUFSIZE - (write_room(line) + 1);
        spin_unlock_irqrestore(&line->lock, flags);
 
@@ -184,10 +178,6 @@ void line_flush_buffer(struct tty_struct *tty)
        unsigned long flags;
        int err;
 
-       /*XXX: copied from line_write, verify if it is correct!*/
-       if (tty->stopped)
-               return;
-
        spin_lock_irqsave(&line->lock, flags);
        err = flush_buffer(line);
        spin_unlock_irqrestore(&line->lock, flags);
@@ -202,9 +192,9 @@ void line_flush_chars(struct tty_struct *tty)
        line_flush_buffer(tty);
 }
 
-void line_put_char(struct tty_struct *tty, unsigned char ch)
+int line_put_char(struct tty_struct *tty, unsigned char ch)
 {
-       line_write(tty, &ch, sizeof(ch));
+       return line_write(tty, &ch, sizeof(ch));
 }
 
 int line_write(struct tty_struct *tty, const unsigned char *buf, int len)
@@ -213,9 +203,6 @@ int line_write(struct tty_struct *tty, const unsigned char *buf, int len)
        unsigned long flags;
        int n, ret = 0;
 
-       if (tty->stopped)
-               return 0;
-
        spin_lock_irqsave(&line->lock, flags);
        if (line->head != line->tail)
                ret = buffer_data(line, buf, len);
@@ -289,6 +276,8 @@ int line_ioctl(struct tty_struct *tty, struct file * file,
        case TIOCGLTC:
        case TIOCSLTC:
 #endif
+       /* Note: these are out of date as we now have TCGETS2 etc but this
+          whole lot should probably go away */
        case TCGETS:
        case TCSETSF:
        case TCSETSW:
@@ -318,7 +307,7 @@ int line_ioctl(struct tty_struct *tty, struct file * file,
                                break;
                if (i == ARRAY_SIZE(tty_ioctls)) {
                        printk(KERN_ERR "%s: %s: unknown ioctl: 0x%x\n",
-                              __FUNCTION__, tty->name, cmd);
+                              __func__, tty->name, cmd);
                }
                ret = -ENOIOCTLCMD;
                break;
@@ -376,19 +365,7 @@ static irqreturn_t line_write_interrupt(int irq, void *data)
        if (tty == NULL)
                return IRQ_NONE;
 
-       if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) &&
-          (tty->ldisc.write_wakeup != NULL))
-               (tty->ldisc.write_wakeup)(tty);
-
-       /*
-        * BLOCKING mode
-        * In blocking mode, everything sleeps on tty->write_wait.
-        * Sleeping in the console driver would break non-blocking
-        * writes.
-        */
-
-       if (waitqueue_active(&tty->write_wait))
-               wake_up_interruptible(&tty->write_wait);
+       tty_wakeup(tty);
        return IRQ_HANDLED;
 }
 
@@ -788,9 +765,11 @@ static irqreturn_t winch_interrupt(int irq, void *data)
        tty = winch->tty;
        if (tty != NULL) {
                line = tty->driver_data;
-               chan_window_size(&line->chan_list, &tty->winsize.ws_row,
-                                &tty->winsize.ws_col);
-               kill_pgrp(tty->pgrp, SIGWINCH, 1);
+               if (line != NULL) {
+                       chan_window_size(&line->chan_list, &tty->winsize.ws_row,
+                                        &tty->winsize.ws_col);
+                       kill_pgrp(tty->pgrp, SIGWINCH, 1);
+               }
        }
  out:
        if (winch->fd != -1)