[S390] pm: netiucv power management callbacks.
[safe/jmp/linux-2.6] / drivers / s390 / char / fs3270.c
index f0d67af..40759c3 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>
@@ -417,40 +418,42 @@ fs3270_open(struct inode *inode, struct file *filp)
 {
        struct fs3270 *fp;
        struct idal_buffer *ib;
-       int minor, rc;
+       int minor, rc = 0;
 
        if (imajor(filp->f_path.dentry->d_inode) != IBM_FS3270_MAJOR)
                return -ENODEV;
        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);
+                       tty_kref_put(tty);
                        return -ENODEV;
                }
                minor = tty->index + RAW3270_FIRSTMINOR;
-               mutex_unlock(&tty_mutex);
+               tty_kref_put(tty);
        }
+       lock_kernel();
        /* 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 +461,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,10 +470,12 @@ 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;
-       return 0;
+out:
+       unlock_kernel();
+       return rc;
 }
 
 /*
@@ -512,11 +518,8 @@ fs3270_init(void)
        int rc;
 
        rc = register_chrdev(IBM_FS3270_MAJOR, "fs3270", &fs3270_fops);
-       if (rc) {
-               printk(KERN_ERR "fs3270 can't get major number %d: errno %d\n",
-                      IBM_FS3270_MAJOR, rc);
+       if (rc)
                return rc;
-       }
        return 0;
 }