Merge master.kernel.org:/home/rmk/linux-2.6-serial
[pandora-kernel.git] / drivers / s390 / char / fs3270.c
index 735a7fc..ef004d0 100644 (file)
@@ -8,7 +8,6 @@
  *     -- Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
  */
 
-#include <linux/config.h>
 #include <linux/bootmem.h>
 #include <linux/console.h>
 #include <linux/init.h>
@@ -237,7 +236,7 @@ fs3270_irq(struct fs3270 *fp, struct raw3270_request *rq, struct irb *irb)
  * Process reads from fullscreen 3270.
  */
 static ssize_t
-fs3270_read(struct file *filp, char *data, size_t count, loff_t *off)
+fs3270_read(struct file *filp, char __user *data, size_t count, loff_t *off)
 {
        struct fs3270 *fp;
        struct raw3270_request *rq;
@@ -282,7 +281,7 @@ fs3270_read(struct file *filp, char *data, size_t count, loff_t *off)
  * Process writes to fullscreen 3270.
  */
 static ssize_t
-fs3270_write(struct file *filp, const char *data, size_t count, loff_t *off)
+fs3270_write(struct file *filp, const char __user *data, size_t count, loff_t *off)
 {
        struct fs3270 *fp;
        struct raw3270_request *rq;
@@ -319,9 +318,8 @@ fs3270_write(struct file *filp, const char *data, size_t count, loff_t *off)
 /*
  * process ioctl commands for the tube driver
  */
-static int
-fs3270_ioctl(struct inode *inode, struct file *filp,
-            unsigned int cmd, unsigned long arg)
+static long
+fs3270_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
        struct fs3270 *fp;
        struct raw3270_iocb iocb;
@@ -331,6 +329,7 @@ fs3270_ioctl(struct inode *inode, struct file *filp,
        if (!fp)
                return -ENODEV;
        rc = 0;
+       lock_kernel();
        switch (cmd) {
        case TUBICMD:
                fp->read_command = arg;
@@ -339,10 +338,10 @@ fs3270_ioctl(struct inode *inode, struct file *filp,
                fp->write_command = arg;
                break;
        case TUBGETI:
-               rc = put_user(fp->read_command, (char *) arg);
+               rc = put_user(fp->read_command, (char __user *) arg);
                break;
        case TUBGETO:
-               rc = put_user(fp->write_command,(char *) arg);
+               rc = put_user(fp->write_command,(char __user *) arg);
                break;
        case TUBGETMOD:
                iocb.model = fp->view.model;
@@ -351,11 +350,12 @@ fs3270_ioctl(struct inode *inode, struct file *filp,
                iocb.pf_cnt = 24;
                iocb.re_cnt = 20;
                iocb.map = 0;
-               if (copy_to_user((char *) arg, &iocb,
+               if (copy_to_user((char __user *) arg, &iocb,
                                 sizeof(struct raw3270_iocb)))
                        rc = -EFAULT;
                break;
        }
+       unlock_kernel();
        return rc;
 }
 
@@ -367,10 +367,9 @@ fs3270_alloc_view(void)
 {
        struct fs3270 *fp;
 
-       fp = (struct fs3270 *) kmalloc(sizeof(struct fs3270),GFP_KERNEL);
+       fp = kzalloc(sizeof(struct fs3270),GFP_KERNEL);
        if (!fp)
                return ERR_PTR(-ENOMEM);
-       memset(fp, 0, sizeof(struct fs3270));
        fp->init = raw3270_request_alloc(0);
        if (IS_ERR(fp->init)) {
                kfree(fp);
@@ -480,7 +479,7 @@ fs3270_close(struct inode *inode, struct file *filp)
        struct fs3270 *fp;
 
        fp = filp->private_data;
-       filp->private_data = 0;
+       filp->private_data = NULL;
        if (fp) {
                fp->fs_pid = 0;
                raw3270_reset(&fp->view);
@@ -491,12 +490,13 @@ fs3270_close(struct inode *inode, struct file *filp)
 }
 
 static struct file_operations fs3270_fops = {
-       .owner   = THIS_MODULE,         /* owner */
-       .read    = fs3270_read,         /* read */
-       .write   = fs3270_write,        /* write */
-       .ioctl   = fs3270_ioctl,        /* ioctl */
-       .open    = fs3270_open,         /* open */
-       .release = fs3270_close,        /* release */
+       .owner           = THIS_MODULE,         /* owner */
+       .read            = fs3270_read,         /* read */
+       .write           = fs3270_write,        /* write */
+       .unlocked_ioctl  = fs3270_ioctl,        /* ioctl */
+       .compat_ioctl    = fs3270_ioctl,        /* ioctl */
+       .open           = fs3270_open,          /* open */
+       .release        = fs3270_close,         /* release */
 };
 
 /*