Merge tag 'perf-tools-for-v5.14-2021-07-10' of git://git.kernel.org/pub/scm/linux...
[linux-2.6-microblaze.git] / drivers / tty / pty.c
index 9b5d4ae..74bfabe 100644 (file)
@@ -57,9 +57,9 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
        set_bit(TTY_IO_ERROR, &tty->flags);
        wake_up_interruptible(&tty->read_wait);
        wake_up_interruptible(&tty->write_wait);
-       spin_lock_irq(&tty->ctrl_lock);
-       tty->packet = 0;
-       spin_unlock_irq(&tty->ctrl_lock);
+       spin_lock_irq(&tty->ctrl.lock);
+       tty->ctrl.packet = false;
+       spin_unlock_irq(&tty->ctrl.lock);
        /* Review - krefs on tty_link ?? */
        if (!tty->link)
                return;
@@ -113,7 +113,7 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
        struct tty_struct *to = tty->link;
        unsigned long flags;
 
-       if (tty->stopped)
+       if (tty->flow.stopped)
                return 0;
 
        if (c > 0) {
@@ -136,26 +136,13 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
  *     the other device.
  */
 
-static int pty_write_room(struct tty_struct *tty)
+static unsigned int pty_write_room(struct tty_struct *tty)
 {
-       if (tty->stopped)
+       if (tty->flow.stopped)
                return 0;
        return tty_buffer_space_avail(tty->link->port);
 }
 
-/**
- *     pty_chars_in_buffer     -       characters currently in our tx queue
- *     @tty: our tty
- *
- *     Report how much we have in the transmit queue. As everything is
- *     instantly at the other end this is easy to implement.
- */
-
-static int pty_chars_in_buffer(struct tty_struct *tty)
-{
-       return 0;
-}
-
 /* Set the lock flag on a pty */
 static int pty_set_lock(struct tty_struct *tty, int __user *arg)
 {
@@ -185,16 +172,16 @@ static int pty_set_pktmode(struct tty_struct *tty, int __user *arg)
        if (get_user(pktmode, arg))
                return -EFAULT;
 
-       spin_lock_irq(&tty->ctrl_lock);
+       spin_lock_irq(&tty->ctrl.lock);
        if (pktmode) {
-               if (!tty->packet) {
-                       tty->link->ctrl_status = 0;
+               if (!tty->ctrl.packet) {
+                       tty->link->ctrl.pktstatus = 0;
                        smp_mb();
-                       tty->packet = 1;
+                       tty->ctrl.packet = true;
                }
        } else
-               tty->packet = 0;
-       spin_unlock_irq(&tty->ctrl_lock);
+               tty->ctrl.packet = false;
+       spin_unlock_irq(&tty->ctrl.lock);
 
        return 0;
 }
@@ -202,7 +189,7 @@ static int pty_set_pktmode(struct tty_struct *tty, int __user *arg)
 /* Get the packet mode of a pty */
 static int pty_get_pktmode(struct tty_struct *tty, int __user *arg)
 {
-       int pktmode = tty->packet;
+       int pktmode = tty->ctrl.packet;
 
        return put_user(pktmode, arg);
 }
@@ -232,11 +219,11 @@ static void pty_flush_buffer(struct tty_struct *tty)
                return;
 
        tty_buffer_flush(to, NULL);
-       if (to->packet) {
-               spin_lock_irq(&tty->ctrl_lock);
-               tty->ctrl_status |= TIOCPKT_FLUSHWRITE;
+       if (to->ctrl.packet) {
+               spin_lock_irq(&tty->ctrl.lock);
+               tty->ctrl.pktstatus |= TIOCPKT_FLUSHWRITE;
                wake_up_interruptible(&to->read_wait);
-               spin_unlock_irq(&tty->ctrl_lock);
+               spin_unlock_irq(&tty->ctrl.lock);
        }
 }
 
@@ -266,7 +253,7 @@ static void pty_set_termios(struct tty_struct *tty,
                                        struct ktermios *old_termios)
 {
        /* See if packet mode change of state. */
-       if (tty->link && tty->link->packet) {
+       if (tty->link && tty->link->ctrl.packet) {
                int extproc = (old_termios->c_lflag & EXTPROC) | L_EXTPROC(tty);
                int old_flow = ((old_termios->c_iflag & IXON) &&
                                (old_termios->c_cc[VSTOP] == '\023') &&
@@ -275,17 +262,17 @@ static void pty_set_termios(struct tty_struct *tty,
                                STOP_CHAR(tty) == '\023' &&
                                START_CHAR(tty) == '\021');
                if ((old_flow != new_flow) || extproc) {
-                       spin_lock_irq(&tty->ctrl_lock);
+                       spin_lock_irq(&tty->ctrl.lock);
                        if (old_flow != new_flow) {
-                               tty->ctrl_status &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP);
+                               tty->ctrl.pktstatus &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP);
                                if (new_flow)
-                                       tty->ctrl_status |= TIOCPKT_DOSTOP;
+                                       tty->ctrl.pktstatus |= TIOCPKT_DOSTOP;
                                else
-                                       tty->ctrl_status |= TIOCPKT_NOSTOP;
+                                       tty->ctrl.pktstatus |= TIOCPKT_NOSTOP;
                        }
                        if (extproc)
-                               tty->ctrl_status |= TIOCPKT_IOCTL;
-                       spin_unlock_irq(&tty->ctrl_lock);
+                               tty->ctrl.pktstatus |= TIOCPKT_IOCTL;
+                       spin_unlock_irq(&tty->ctrl.lock);
                        wake_up_interruptible(&tty->link->read_wait);
                }
        }
@@ -295,7 +282,7 @@ static void pty_set_termios(struct tty_struct *tty,
 }
 
 /**
- *     pty_do_resize           -       resize event
+ *     pty_resize              -       resize event
  *     @tty: tty being resized
  *     @ws: window size being set.
  *
@@ -346,11 +333,11 @@ static void pty_start(struct tty_struct *tty)
 {
        unsigned long flags;
 
-       if (tty->link && tty->link->packet) {
-               spin_lock_irqsave(&tty->ctrl_lock, flags);
-               tty->ctrl_status &= ~TIOCPKT_STOP;
-               tty->ctrl_status |= TIOCPKT_START;
-               spin_unlock_irqrestore(&tty->ctrl_lock, flags);
+       if (tty->link && tty->link->ctrl.packet) {
+               spin_lock_irqsave(&tty->ctrl.lock, flags);
+               tty->ctrl.pktstatus &= ~TIOCPKT_STOP;
+               tty->ctrl.pktstatus |= TIOCPKT_START;
+               spin_unlock_irqrestore(&tty->ctrl.lock, flags);
                wake_up_interruptible_poll(&tty->link->read_wait, EPOLLIN);
        }
 }
@@ -359,11 +346,11 @@ static void pty_stop(struct tty_struct *tty)
 {
        unsigned long flags;
 
-       if (tty->link && tty->link->packet) {
-               spin_lock_irqsave(&tty->ctrl_lock, flags);
-               tty->ctrl_status &= ~TIOCPKT_START;
-               tty->ctrl_status |= TIOCPKT_STOP;
-               spin_unlock_irqrestore(&tty->ctrl_lock, flags);
+       if (tty->link && tty->link->ctrl.packet) {
+               spin_lock_irqsave(&tty->ctrl.lock, flags);
+               tty->ctrl.pktstatus &= ~TIOCPKT_START;
+               tty->ctrl.pktstatus |= TIOCPKT_STOP;
+               spin_unlock_irqrestore(&tty->ctrl.lock, flags);
                wake_up_interruptible_poll(&tty->link->read_wait, EPOLLIN);
        }
 }
@@ -525,7 +512,6 @@ static const struct tty_operations master_pty_ops_bsd = {
        .write = pty_write,
        .write_room = pty_write_room,
        .flush_buffer = pty_flush_buffer,
-       .chars_in_buffer = pty_chars_in_buffer,
        .unthrottle = pty_unthrottle,
        .ioctl = pty_bsd_ioctl,
        .compat_ioctl = pty_bsd_compat_ioctl,
@@ -541,7 +527,6 @@ static const struct tty_operations slave_pty_ops_bsd = {
        .write = pty_write,
        .write_room = pty_write_room,
        .flush_buffer = pty_flush_buffer,
-       .chars_in_buffer = pty_chars_in_buffer,
        .unthrottle = pty_unthrottle,
        .set_termios = pty_set_termios,
        .cleanup = pty_cleanup,
@@ -626,7 +611,7 @@ static struct cdev ptmx_cdev;
  */
 int ptm_open_peer(struct file *master, struct tty_struct *tty, int flags)
 {
-       int fd = -1;
+       int fd;
        struct file *filp;
        int retval = -EINVAL;
        struct path path;
@@ -776,7 +761,6 @@ static const struct tty_operations ptm_unix98_ops = {
        .write = pty_write,
        .write_room = pty_write_room,
        .flush_buffer = pty_flush_buffer,
-       .chars_in_buffer = pty_chars_in_buffer,
        .unthrottle = pty_unthrottle,
        .ioctl = pty_unix98_ioctl,
        .compat_ioctl = pty_unix98_compat_ioctl,
@@ -794,7 +778,6 @@ static const struct tty_operations pty_unix98_ops = {
        .write = pty_write,
        .write_room = pty_write_room,
        .flush_buffer = pty_flush_buffer,
-       .chars_in_buffer = pty_chars_in_buffer,
        .unthrottle = pty_unthrottle,
        .set_termios = pty_set_termios,
        .start = pty_start,