]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/s390/char/fs3270.c
fs3270: remove extra locks
[mirror_ubuntu-bionic-kernel.git] / drivers / s390 / char / fs3270.c
index e136d10a0de6da541f788937d32fd0a513091e0f..1227f4591f8d76078631a73d1cd61f1a4045cd06 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/interrupt.h>
 #include <linux/list.h>
 #include <linux/types.h>
+#include <linux/smp_lock.h>
 
 #include <asm/ccwdev.h>
 #include <asm/cio.h>
@@ -421,36 +422,39 @@ fs3270_open(struct inode *inode, struct file *filp)
 
        if (imajor(filp->f_path.dentry->d_inode) != IBM_FS3270_MAJOR)
                return -ENODEV;
+       lock_kernel();
        minor = iminor(filp->f_path.dentry->d_inode);
        /* Check for minor 0 multiplexer. */
        if (minor == 0) {
-               struct tty_struct *tty;
-               mutex_lock(&tty_mutex);
-               tty = get_current_tty();
+               struct tty_struct *tty = get_current_tty();
                if (!tty || tty->driver->major != IBM_TTY3270_MAJOR) {
-                       mutex_unlock(&tty_mutex);
-                       return -ENODEV;
+                       tty_kref_put(tty);
+                       rc = -ENODEV;
+                       goto out;
                }
                minor = tty->index + RAW3270_FIRSTMINOR;
-               mutex_unlock(&tty_mutex);
+               tty_kref_put(tty);
        }
        /* Check if some other program is already using fullscreen mode. */
        fp = (struct fs3270 *) raw3270_find_view(&fs3270_fn, minor);
        if (!IS_ERR(fp)) {
                raw3270_put_view(&fp->view);
-               return -EBUSY;
+               rc = -EBUSY;
+               goto out;
        }
        /* Allocate fullscreen view structure. */
        fp = fs3270_alloc_view();
-       if (IS_ERR(fp))
-               return PTR_ERR(fp);
+       if (IS_ERR(fp)) {
+               rc = PTR_ERR(fp);
+               goto out;
+       }
 
        init_waitqueue_head(&fp->wait);
        fp->fs_pid = get_pid(task_pid(current));
        rc = raw3270_add_view(&fp->view, &fs3270_fn, minor);
        if (rc) {
                fs3270_free_view(&fp->view);
-               return rc;
+               goto out;
        }
 
        /* Allocate idal-buffer. */
@@ -458,7 +462,8 @@ fs3270_open(struct inode *inode, struct file *filp)
        if (IS_ERR(ib)) {
                raw3270_put_view(&fp->view);
                raw3270_del_view(&fp->view);
-               return PTR_ERR(fp);
+               rc = PTR_ERR(fp);
+               goto out;
        }
        fp->rdbuf = ib;
 
@@ -466,9 +471,11 @@ fs3270_open(struct inode *inode, struct file *filp)
        if (rc) {
                raw3270_put_view(&fp->view);
                raw3270_del_view(&fp->view);
-               return rc;
+               goto out;
        }
        filp->private_data = fp;
+out:
+       unlock_kernel();
        return 0;
 }