Staging: agnx: Fixup sta.h checkpatch warnings
[safe/jmp/linux-2.6] / drivers / block / paride / pt.c
index ea12073..1e4006e 100644 (file)
@@ -141,12 +141,12 @@ static int (*drives[4])[6] = {&drive0, &drive1, &drive2, &drive3};
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/fs.h>
-#include <linux/devfs_fs_kernel.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/mtio.h>
 #include <linux/device.h>
 #include <linux/sched.h>       /* current, TASK_*, schedule_timeout() */
+#include <linux/smp_lock.h>
 
 #include <asm/uaccess.h>
 
@@ -190,8 +190,7 @@ module_param_array(drive3, int, NULL, 0);
 #define ATAPI_LOG_SENSE                0x4d
 
 static int pt_open(struct inode *inode, struct file *file);
-static int pt_ioctl(struct inode *inode, struct file *file,
-                   unsigned int cmd, unsigned long arg);
+static long pt_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 static int pt_release(struct inode *inode, struct file *file);
 static ssize_t pt_read(struct file *filp, char __user *buf,
                       size_t count, loff_t * ppos);
@@ -233,11 +232,11 @@ static char pt_scratch[512];      /* scratch block buffer */
 
 /* kernel glue structures */
 
-static struct file_operations pt_fops = {
+static const struct file_operations pt_fops = {
        .owner = THIS_MODULE,
        .read = pt_read,
        .write = pt_write,
-       .ioctl = pt_ioctl,
+       .unlocked_ioctl = pt_ioctl,
        .open = pt_open,
        .release = pt_release,
 };
@@ -651,8 +650,11 @@ static int pt_open(struct inode *inode, struct file *file)
        struct pt_unit *tape = pt + unit;
        int err;
 
-       if (unit >= PT_UNITS || (!tape->present))
+       lock_kernel();
+       if (unit >= PT_UNITS || (!tape->present)) {
+               unlock_kernel();
                return -ENODEV;
+       }
 
        err = -EBUSY;
        if (!atomic_dec_and_test(&tape->available))
@@ -661,11 +663,11 @@ static int pt_open(struct inode *inode, struct file *file)
        pt_identify(tape);
 
        err = -ENODEV;
-       if (!tape->flags & PT_MEDIA)
+       if (!(tape->flags & PT_MEDIA))
                goto out;
 
        err = -EROFS;
-       if ((!tape->flags & PT_WRITE_OK) && (file->f_mode & 2))
+       if ((!(tape->flags & PT_WRITE_OK)) && (file->f_mode & FMODE_WRITE))
                goto out;
 
        if (!(iminor(inode) & 128))
@@ -679,15 +681,16 @@ static int pt_open(struct inode *inode, struct file *file)
        }
 
        file->private_data = tape;
+       unlock_kernel();
        return 0;
 
 out:
        atomic_inc(&tape->available);
+       unlock_kernel();
        return err;
 }
 
-static int pt_ioctl(struct inode *inode, struct file *file,
-        unsigned int cmd, unsigned long arg)
+static long pt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
        struct pt_unit *tape = file->private_data;
        struct mtop __user *p = (void __user *)arg;
@@ -701,23 +704,26 @@ static int pt_ioctl(struct inode *inode, struct file *file,
                switch (mtop.mt_op) {
 
                case MTREW:
+                       lock_kernel();
                        pt_rewind(tape);
+                       unlock_kernel();
                        return 0;
 
                case MTWEOF:
+                       lock_kernel();
                        pt_write_fm(tape);
+                       unlock_kernel();
                        return 0;
 
                default:
-                       printk("%s: Unimplemented mt_op %d\n", tape->name,
+                       /* FIXME: rate limit ?? */
+                       printk(KERN_DEBUG "%s: Unimplemented mt_op %d\n", tape->name,
                               mtop.mt_op);
                        return -EINVAL;
                }
 
        default:
-               printk("%s: Unimplemented ioctl 0x%x\n", tape->name, cmd);
-               return -EINVAL;
-
+               return -ENOTTY;
        }
 }
 
@@ -947,12 +953,12 @@ static int __init pt_init(void)
        int err;
 
        if (disable) {
-               err = -1;
+               err = -EINVAL;
                goto out;
        }
 
        if (pt_detect()) {
-               err = -1;
+               err = -ENODEV;
                goto out;
        }
 
@@ -973,10 +979,10 @@ static int __init pt_init(void)
 
        for (unit = 0; unit < PT_UNITS; unit++)
                if (pt[unit].present) {
-                       class_device_create(pt_class, NULL, MKDEV(major, unit),
-                                       NULL, "pt%d", unit);
-                       class_device_create(pt_class, NULL, MKDEV(major, unit + 128),
-                                       NULL, "pt%dn", unit);
+                       device_create(pt_class, NULL, MKDEV(major, unit), NULL,
+                                     "pt%d", unit);
+                       device_create(pt_class, NULL, MKDEV(major, unit + 128),
+                                     NULL, "pt%dn", unit);
                }
        goto out;
 
@@ -991,8 +997,8 @@ static void __exit pt_exit(void)
        int unit;
        for (unit = 0; unit < PT_UNITS; unit++)
                if (pt[unit].present) {
-                       class_device_destroy(pt_class, MKDEV(major, unit));
-                       class_device_destroy(pt_class, MKDEV(major, unit + 128));
+                       device_destroy(pt_class, MKDEV(major, unit));
+                       device_destroy(pt_class, MKDEV(major, unit + 128));
                }
        class_destroy(pt_class);
        unregister_chrdev(major, name);