]> git.ipfire.org Git - people/ms/linux.git/blobdiff - drivers/tty/synclinkmp.c
Importing "grsecurity-3.1-3.19.2-201503201903.patch"
[people/ms/linux.git] / drivers / tty / synclinkmp.c
index c3f90910fed93cfa28112eb2796924a64d1d2029..abe46017b0b33c9a13f548e970e481b5323c4a30 100644 (file)
@@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
 
        if (debug_level >= DEBUG_LEVEL_INFO)
                printk("%s(%d):%s open(), old ref count = %d\n",
-                        __FILE__,__LINE__,tty->driver->name, info->port.count);
+                        __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
 
        /* If port is closing, signal caller to try again */
        if (info->port.flags & ASYNC_CLOSING){
@@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
                spin_unlock_irqrestore(&info->netlock, flags);
                goto cleanup;
        }
-       info->port.count++;
+       atomic_inc(&info->port.count);
        spin_unlock_irqrestore(&info->netlock, flags);
 
-       if (info->port.count == 1) {
+       if (atomic_read(&info->port.count) == 1) {
                /* 1st open on this device, init hardware */
                retval = startup(info);
                if (retval < 0)
@@ -796,8 +796,8 @@ cleanup:
        if (retval) {
                if (tty->count == 1)
                        info->port.tty = NULL; /* tty layer will release tty struct */
-               if(info->port.count)
-                       info->port.count--;
+               if(atomic_read(&info->port.count))
+                       atomic_dec(&info->port.count);
        }
 
        return retval;
@@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
 
        if (debug_level >= DEBUG_LEVEL_INFO)
                printk("%s(%d):%s close() entry, count=%d\n",
-                        __FILE__,__LINE__, info->device_name, info->port.count);
+                        __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
 
        if (tty_port_close_start(&info->port, tty, filp) == 0)
                goto cleanup;
@@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
 cleanup:
        if (debug_level >= DEBUG_LEVEL_INFO)
                printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
-                       tty->driver->name, info->port.count);
+                       tty->driver->name, atomic_read(&info->port.count));
 }
 
 /* Called by tty_hangup() when a hangup is signaled.
@@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
        shutdown(info);
 
        spin_lock_irqsave(&info->port.lock, flags);
-       info->port.count = 0;
+       atomic_set(&info->port.count, 0);
        info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
        info->port.tty = NULL;
        spin_unlock_irqrestore(&info->port.lock, flags);
@@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
        unsigned short new_crctype;
 
        /* return error if TTY interface open */
-       if (info->port.count)
+       if (atomic_read(&info->port.count))
                return -EBUSY;
 
        switch (encoding)
@@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
 
        /* arbitrate between network and tty opens */
        spin_lock_irqsave(&info->netlock, flags);
-       if (info->port.count != 0 || info->netcount != 0) {
+       if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
                printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
                spin_unlock_irqrestore(&info->netlock, flags);
                return -EBUSY;
@@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
                printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
 
        /* return error if TTY interface open */
-       if (info->port.count)
+       if (atomic_read(&info->port.count))
                return -EBUSY;
 
        if (cmd != SIOCWANDEV)
@@ -2621,7 +2621,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
                 * do not request bottom half processing if the
                 * device is not open in a normal mode.
                 */
-               if ( port && (port->port.count || port->netcount) &&
+               if ( port && (atomic_read(&port->port.count) || port->netcount) &&
                     port->pending_bh && !port->bh_running &&
                     !port->bh_requested ) {
                        if ( debug_level >= DEBUG_LEVEL_ISR )
@@ -3318,10 +3318,10 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 
        if (debug_level >= DEBUG_LEVEL_INFO)
                printk("%s(%d):%s block_til_ready() before block, count=%d\n",
-                        __FILE__,__LINE__, tty->driver->name, port->count );
+                        __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
 
        spin_lock_irqsave(&info->lock, flags);
-       port->count--;
+       atomic_dec(&port->count);
        spin_unlock_irqrestore(&info->lock, flags);
        port->blocked_open++;
 
@@ -3349,7 +3349,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 
                if (debug_level >= DEBUG_LEVEL_INFO)
                        printk("%s(%d):%s block_til_ready() count=%d\n",
-                                __FILE__,__LINE__, tty->driver->name, port->count );
+                                __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
 
                tty_unlock(tty);
                schedule();
@@ -3359,12 +3359,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
        set_current_state(TASK_RUNNING);
        remove_wait_queue(&port->open_wait, &wait);
        if (!tty_hung_up_p(filp))
-               port->count++;
+               atomic_inc(&port->count);
        port->blocked_open--;
 
        if (debug_level >= DEBUG_LEVEL_INFO)
                printk("%s(%d):%s block_til_ready() after, count=%d\n",
-                        __FILE__,__LINE__, tty->driver->name, port->count );
+                        __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
 
        if (!retval)
                port->flags |= ASYNC_NORMAL_ACTIVE;