]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
tty: Replace TTY_IO_ERROR bit tests with tty_io_error()
authorPeter Hurley <peter@hurleysoftware.com>
Sun, 10 Apr 2016 00:06:48 +0000 (17:06 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 30 Apr 2016 16:26:55 +0000 (09:26 -0700)
Abstract TTY_IO_ERROR status test treewide with tty_io_error().
NB: tty->flags uses atomic bit ops; replace non-atomic bit test
with test_bit().

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18 files changed:
arch/ia64/hp/sim/simserial.c
drivers/char/pcmcia/synclink_cs.c
drivers/isdn/i4l/isdn_tty.c
drivers/s390/char/tty3270.c
drivers/staging/dgnc/dgnc_tty.c
drivers/tty/amiserial.c
drivers/tty/mxser.c
drivers/tty/pty.c
drivers/tty/serial/crisv10.c
drivers/tty/serial/serial_core.c
drivers/tty/synclink.c
drivers/tty/synclink_gt.c
drivers/tty/synclinkmp.c
drivers/tty/tty_io.c
drivers/tty/tty_port.c
include/linux/tty.h
net/irda/ircomm/ircomm_tty.c
net/irda/ircomm/ircomm_tty_ioctl.c

index e70cadec7ce68feaa895108254b5d776227b97b9..21fd50def2708b70965caf4de877e5dfa079eb67 100644 (file)
@@ -300,7 +300,7 @@ static int rs_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
        if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
            (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) &&
            (cmd != TIOCMIWAIT)) {
-               if (tty->flags & (1 << TTY_IO_ERROR))
+               if (tty_io_error(tty))
                    return -EIO;
        }
 
index 22c27652e46a8dd6851a56edd408e39095eaa4ad..825db423b7a86ed396aae7f4d900c58c2b9d69eb 100644 (file)
@@ -2246,7 +2246,7 @@ static int mgslpc_ioctl(struct tty_struct *tty,
 
        if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
            (cmd != TIOCMIWAIT)) {
-               if (tty->flags & (1 << TTY_IO_ERROR))
+               if (tty_io_error(tty))
                    return -EIO;
        }
 
index 947d5c978b8f7559708d2b0337e84eec52f8231a..f1edc0814120fdb71b4f76d2304d55d52c4cca22 100644 (file)
@@ -1351,7 +1351,7 @@ isdn_tty_tiocmget(struct tty_struct *tty)
 
        if (isdn_tty_paranoia_check(info, tty->name, __func__))
                return -ENODEV;
-       if (tty->flags & (1 << TTY_IO_ERROR))
+       if (tty_io_error(tty))
                return -EIO;
 
        mutex_lock(&modem_info_mutex);
@@ -1378,7 +1378,7 @@ isdn_tty_tiocmset(struct tty_struct *tty,
 
        if (isdn_tty_paranoia_check(info, tty->name, __func__))
                return -ENODEV;
-       if (tty->flags & (1 << TTY_IO_ERROR))
+       if (tty_io_error(tty))
                return -EIO;
 
 #ifdef ISDN_DEBUG_MODEM_IOCTL
@@ -1419,7 +1419,7 @@ isdn_tty_ioctl(struct tty_struct *tty, uint cmd, ulong arg)
 
        if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_ioctl"))
                return -ENODEV;
-       if (tty->flags & (1 << TTY_IO_ERROR))
+       if (tty_io_error(tty))
                return -EIO;
        switch (cmd) {
        case TCSBRK:   /* SVID version: non-zero arg --> no break */
index e96fc7fd9498458b5506789f4b900b813885adda..080a9872c68fb7cec7fc38f7aa4b7285d29acefd 100644 (file)
@@ -1804,7 +1804,7 @@ static int tty3270_ioctl(struct tty_struct *tty, unsigned int cmd,
        tp = tty->driver_data;
        if (!tp)
                return -ENODEV;
-       if (tty->flags & (1 << TTY_IO_ERROR))
+       if (tty_io_error(tty))
                return -EIO;
        return kbd_ioctl(tp->kbd, cmd, arg);
 }
@@ -1818,7 +1818,7 @@ static long tty3270_compat_ioctl(struct tty_struct *tty,
        tp = tty->driver_data;
        if (!tp)
                return -ENODEV;
-       if (tty->flags & (1 << TTY_IO_ERROR))
+       if (tty_io_error(tty))
                return -EIO;
        return kbd_ioctl(tp->kbd, cmd, (unsigned long)compat_ptr(arg));
 }
index bcd2bdfb9c8f60fbb868044ce1cc61e70174a369..5c221593a0c6d4b2d7fe398549edf9405e26d457 100644 (file)
@@ -1255,7 +1255,7 @@ static int dgnc_block_til_ready(struct tty_struct *tty,
                        if (file->f_flags & O_NONBLOCK)
                                break;
 
-                       if (tty->flags & (1 << TTY_IO_ERROR)) {
+                       if (tty_io_error(tty)) {
                                retval = -EIO;
                                break;
                        }
index eacf4c9f3b299b8f7f92a5cc52a5c347fb0bd541..183e98e84d09fb5546a29ca386b976ba692945ee 100644 (file)
@@ -1143,7 +1143,7 @@ static int rs_tiocmget(struct tty_struct *tty)
 
        if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
                return -ENODEV;
-       if (tty->flags & (1 << TTY_IO_ERROR))
+       if (tty_io_error(tty))
                return -EIO;
 
        control = info->MCR;
@@ -1165,7 +1165,7 @@ static int rs_tiocmset(struct tty_struct *tty, unsigned int set,
 
        if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
                return -ENODEV;
-       if (tty->flags & (1 << TTY_IO_ERROR))
+       if (tty_io_error(tty))
                return -EIO;
 
        local_irq_save(flags);
@@ -1250,7 +1250,7 @@ static int rs_ioctl(struct tty_struct *tty,
        if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
            (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) &&
            (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
-               if (tty->flags & (1 << TTY_IO_ERROR))
+               if (tty_io_error(tty))
                    return -EIO;
        }
 
index 2f12bb9f4336d761d0a5fba2f81cd4fb65a2bc45..f23c2a101688c344ba20b23ae48523782e09f58b 100644 (file)
@@ -1334,7 +1334,7 @@ static int mxser_tiocmget(struct tty_struct *tty)
 
        if (tty->index == MXSER_PORTS)
                return -ENOIOCTLCMD;
-       if (test_bit(TTY_IO_ERROR, &tty->flags))
+       if (tty_io_error(tty))
                return -EIO;
 
        control = info->MCR;
@@ -1361,7 +1361,7 @@ static int mxser_tiocmset(struct tty_struct *tty,
 
        if (tty->index == MXSER_PORTS)
                return -ENOIOCTLCMD;
-       if (test_bit(TTY_IO_ERROR, &tty->flags))
+       if (tty_io_error(tty))
                return -EIO;
 
        spin_lock_irqsave(&info->slock, flags);
@@ -1715,8 +1715,7 @@ static int mxser_ioctl(struct tty_struct *tty,
                return 0;
        }
 
-       if (cmd != TIOCGSERIAL && cmd != TIOCMIWAIT &&
-                       test_bit(TTY_IO_ERROR, &tty->flags))
+       if (cmd != TIOCGSERIAL && cmd != TIOCMIWAIT && tty_io_error(tty))
                return -EIO;
 
        switch (cmd) {
index 0058d9fbf9314b4938fb9009c201ac1bc0a20573..a8a292fd564f50ada77c50bbfd49492a0c5dbc4f 100644 (file)
@@ -44,7 +44,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
        if (tty->driver->subtype == PTY_TYPE_MASTER)
                WARN_ON(tty->count > 1);
        else {
-               if (test_bit(TTY_IO_ERROR, &tty->flags))
+               if (tty_io_error(tty))
                        return;
                if (tty->count > 2)
                        return;
index c0172bf54a9b3d8052fc6416f6731d1a45a6c9eb..5469903348153c91301b5cf62035d0451e055406 100644 (file)
@@ -3445,7 +3445,7 @@ rs_ioctl(struct tty_struct *tty,
        if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
            (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGWILD)  &&
            (cmd != TIOCSERSWILD) && (cmd != TIOCSERGSTRUCT)) {
-               if (tty->flags & (1 << TTY_IO_ERROR))
+               if (tty_io_error(tty))
                        return -EIO;
        }
 
@@ -3755,8 +3755,7 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
         * If non-blocking mode is set, or the port is not enabled,
         * then make the check up front and then exit.
         */
-       if ((filp->f_flags & O_NONBLOCK) ||
-           (tty->flags & (1 << TTY_IO_ERROR))) {
+       if ((filp->f_flags & O_NONBLOCK) || tty_io_error(tty)) {
                info->port.flags |= ASYNC_NORMAL_ACTIVE;
                return 0;
        }
index a126a603b0837916ad1046da7640c0170300bab4..67b395031347c07abdc956ad99e3f851625e1e04 100644 (file)
@@ -969,7 +969,7 @@ static int uart_tiocmget(struct tty_struct *tty)
        int result = -EIO;
 
        mutex_lock(&port->mutex);
-       if (!(tty->flags & (1 << TTY_IO_ERROR))) {
+       if (!tty_io_error(tty)) {
                result = uport->mctrl;
                spin_lock_irq(&uport->lock);
                result |= uport->ops->get_mctrl(uport);
@@ -989,7 +989,7 @@ uart_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear)
        int ret = -EIO;
 
        mutex_lock(&port->mutex);
-       if (!(tty->flags & (1 << TTY_IO_ERROR))) {
+       if (!tty_io_error(tty)) {
                uart_update_mctrl(uport, set, clear);
                ret = 0;
        }
@@ -1238,7 +1238,7 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd,
        if (ret != -ENOIOCTLCMD)
                goto out;
 
-       if (tty->flags & (1 << TTY_IO_ERROR)) {
+       if (tty_io_error(tty)) {
                ret = -EIO;
                goto out;
        }
@@ -1257,7 +1257,7 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd,
 
        mutex_lock(&port->mutex);
 
-       if (tty->flags & (1 << TTY_IO_ERROR)) {
+       if (tty_io_error(tty)) {
                ret = -EIO;
                goto out_up;
        }
index f5476e270734b24a030a2b20db04628209a25994..8b2277223ee79e43e6b80c2c34ab90d891fff523 100644 (file)
@@ -2972,7 +2972,7 @@ static int mgsl_ioctl(struct tty_struct *tty,
 
        if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
            (cmd != TIOCMIWAIT)) {
-               if (tty->flags & (1 << TTY_IO_ERROR))
+               if (tty_io_error(tty))
                    return -EIO;
        }
 
@@ -3270,7 +3270,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
                printk("%s(%d):block_til_ready on %s\n",
                         __FILE__,__LINE__, tty->driver->name );
 
-       if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){
+       if (filp->f_flags & O_NONBLOCK || tty_io_error(tty)) {
                /* nonblock mode is set or port is not enabled */
                port->flags |= ASYNC_NORMAL_ACTIVE;
                return 0;
index c0a2f5a1b1c2d08b0534df5138b12d813f420602..1f7d6d9437e64c601390f5fbfa6e2889ef3f5fab 100644 (file)
@@ -1032,7 +1032,7 @@ static int ioctl(struct tty_struct *tty,
 
        if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
            (cmd != TIOCMIWAIT)) {
-               if (tty->flags & (1 << TTY_IO_ERROR))
+               if (tty_io_error(tty))
                    return -EIO;
        }
 
@@ -3269,7 +3269,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 
        DBGINFO(("%s block_til_ready\n", tty->driver->name));
 
-       if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){
+       if (filp->f_flags & O_NONBLOCK || tty_io_error(tty)) {
                /* nonblock mode is set or port is not enabled */
                port->flags |= ASYNC_NORMAL_ACTIVE;
                return 0;
index 90da0c712262d81b92891aec8103c95a9df44634..e938799449053fdd7044c5177dd39bb2029b24e2 100644 (file)
@@ -1261,7 +1261,7 @@ static int ioctl(struct tty_struct *tty,
 
        if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
            (cmd != TIOCMIWAIT)) {
-               if (tty->flags & (1 << TTY_IO_ERROR))
+               if (tty_io_error(tty))
                    return -EIO;
        }
 
@@ -3285,7 +3285,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
                printk("%s(%d):%s block_til_ready()\n",
                         __FILE__,__LINE__, tty->driver->name );
 
-       if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){
+       if (filp->f_flags & O_NONBLOCK || tty_io_error(tty)) {
                /* nonblock mode is set or port is not enabled */
                /* just verify that callout device is not active */
                port->flags |= ASYNC_NORMAL_ACTIVE;
index 9b04d72e752e5e398aef0122eabf0d9ba2d2e1c1..320dc4da71620f8bf96becf2d095bc62344d8a52 100644 (file)
@@ -1070,7 +1070,7 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count,
 
        if (tty_paranoia_check(tty, inode, "tty_read"))
                return -EIO;
-       if (!tty || (test_bit(TTY_IO_ERROR, &tty->flags)))
+       if (!tty || tty_io_error(tty))
                return -EIO;
 
        /* We want to wait for the line discipline to sort out in this
@@ -1245,8 +1245,7 @@ static ssize_t tty_write(struct file *file, const char __user *buf,
 
        if (tty_paranoia_check(tty, file_inode(file), "tty_write"))
                return -EIO;
-       if (!tty || !tty->ops->write ||
-               (test_bit(TTY_IO_ERROR, &tty->flags)))
+       if (!tty || !tty->ops->write || tty_io_error(tty))
                        return -EIO;
        /* Short term debug to catch buggy drivers */
        if (tty->ops->write_room == NULL)
index dbcca30a54b1ad56db0b49f37a86d4d1a8f0710b..9127c54b803e36df216a40913ed016ed2851a13b 100644 (file)
@@ -364,7 +364,7 @@ int tty_port_block_til_ready(struct tty_port *port,
 
        /* if non-blocking mode is set we can pass directly to open unless
           the port has just hung up or is in another error state */
-       if (tty->flags & (1 << TTY_IO_ERROR)) {
+       if (tty_io_error(tty)) {
                port->flags |= ASYNC_NORMAL_ACTIVE;
                return 0;
        }
index 3b09f235db6668b932792f32890d0bbee942e8cb..68d829bf93b8883fc2fe56dab666b842bb1ef9ef 100644 (file)
@@ -360,6 +360,11 @@ static inline void tty_set_flow_change(struct tty_struct *tty, int val)
        smp_mb();
 }
 
+static inline bool tty_io_error(struct tty_struct *tty)
+{
+       return test_bit(TTY_IO_ERROR, &tty->flags);
+}
+
 #ifdef CONFIG_TTY
 extern void console_init(void);
 extern void tty_kref_put(struct tty_struct *tty);
index da126ee6d2183c7509afa0fa4d238845e9fa7f36..840b82f760ba873e7459fec694250307cb867872 100644 (file)
@@ -280,7 +280,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
         * If non-blocking mode is set, or the port is not enabled,
         * then make the check up front and then exit.
         */
-       if (test_bit(TTY_IO_ERROR, &tty->flags)) {
+       if (tty_io_error(tty)) {
                port->flags |= ASYNC_NORMAL_ACTIVE;
                return 0;
        }
index d3687aaa23de08a856021a6a7d92930197dda05e..9beb011441fa644e67e2a7a2aa0fcbc12a329977 100644 (file)
@@ -190,7 +190,7 @@ int ircomm_tty_tiocmget(struct tty_struct *tty)
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
        unsigned int result;
 
-       if (tty->flags & (1 << TTY_IO_ERROR))
+       if (tty_io_error(tty))
                return -EIO;
 
        result =  ((self->settings.dte & IRCOMM_RTS) ? TIOCM_RTS : 0)
@@ -213,7 +213,7 @@ int ircomm_tty_tiocmset(struct tty_struct *tty,
 {
        struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
 
-       if (tty->flags & (1 << TTY_IO_ERROR))
+       if (tty_io_error(tty))
                return -EIO;
 
        IRDA_ASSERT(self != NULL, return -1;);
@@ -362,7 +362,7 @@ int ircomm_tty_ioctl(struct tty_struct *tty,
        if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
            (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) &&
            (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
-               if (tty->flags & (1 << TTY_IO_ERROR))
+               if (tty_io_error(tty))
                    return -EIO;
        }