Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / drivers / char / ftape / zftape / zftape-init.c
index 1fc5fea..164a1aa 100644 (file)
  *      to the ftape floppy tape driver for Linux
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/errno.h>
-#include <linux/version.h>
 #include <linux/fs.h>
 #include <linux/kernel.h>
 #include <linux/signal.h>
@@ -34,7 +32,6 @@
 #endif
 #include <linux/fcntl.h>
 #include <linux/smp_lock.h>
-#include <linux/devfs_fs_kernel.h>
 
 #include <linux/zftape.h>
 #include <linux/init.h>
 #include "../zftape/zftape-ctl.h"
 #include "../zftape/zftape-buffers.h"
 
-char zft_src[] __initdata = "$Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-init.c,v $";
-char zft_rev[] __initdata = "$Revision: 1.8 $";
-char zft_dat[] __initdata = "$Date: 1997/11/06 00:48:56 $";
-
 MODULE_AUTHOR("(c) 1996, 1997 Claus-Justus Heine "
              "(claus@momo.math.rwth-aachen.de)");
 MODULE_DESCRIPTION(ZFTAPE_VERSION " - "
@@ -88,12 +81,12 @@ static int zft_close(struct inode *ino, struct file *filep);
 static int  zft_ioctl(struct inode *ino, struct file *filep,
                      unsigned int command, unsigned long arg);
 static int  zft_mmap(struct file *filep, struct vm_area_struct *vma);
-static ssize_t zft_read (struct file *fp, char *buff,
+static ssize_t zft_read (struct file *fp, char __user *buff,
                         size_t req_len, loff_t *ppos);
-static ssize_t zft_write(struct file *fp, const char *buff,
+static ssize_t zft_write(struct file *fp, const char __user *buff,
                         size_t req_len, loff_t *ppos);
 
-static struct file_operations zft_cdev =
+static const struct file_operations zft_cdev =
 {
        .owner          = THIS_MODULE,
        .read           = zft_read,
@@ -104,7 +97,7 @@ static struct file_operations zft_cdev =
        .release        = zft_close,
 };
 
-static struct class_simple *zft_class;
+static struct class *zft_class;
 
 /*      Open floppy tape device
  */
@@ -113,6 +106,7 @@ static int zft_open(struct inode *ino, struct file *filep)
        int result;
        TRACE_FUN(ft_t_flow);
 
+       nonseekable_open(ino, filep);
        TRACE(ft_t_flow, "called for minor %d", iminor(ino));
        if ( test_and_set_bit(0,&busy_flag) ) {
                TRACE_ABORT(-EBUSY, ft_t_warn, "failed: already busy");
@@ -177,7 +171,7 @@ static int zft_ioctl(struct inode *ino, struct file *filep,
        old_sigmask = current->blocked; /* save mask */
        sigfillset(&current->blocked);
        /* This will work as long as sizeof(void *) == sizeof(long) */
-       result = _zft_ioctl(command, (void *) arg);
+       result = _zft_ioctl(command, (void __user *) arg);
        current->blocked = old_sigmask; /* restore mask */
        TRACE_EXIT result;
 }
@@ -211,7 +205,7 @@ static int  zft_mmap(struct file *filep, struct vm_area_struct *vma)
 
 /*      Read from floppy tape device
  */
-static ssize_t zft_read(struct file *fp, char *buff,
+static ssize_t zft_read(struct file *fp, char __user *buff,
                        size_t req_len, loff_t *ppos)
 {
        int result = -EIO;
@@ -234,7 +228,7 @@ static ssize_t zft_read(struct file *fp, char *buff,
 
 /*      Write to tape device
  */
-static ssize_t zft_write(struct file *fp, const char *buff,
+static ssize_t zft_write(struct file *fp, const char __user *buff,
                         size_t req_len, loff_t *ppos)
 {
        int result = -EIO;
@@ -277,15 +271,6 @@ int zft_cmpr_register(struct zft_cmpr_ops *new_ops)
        }
 }
 
-struct zft_cmpr_ops *zft_cmpr_unregister(void)
-{
-       struct zft_cmpr_ops *old_ops = zft_cmpr_ops;
-       TRACE_FUN(ft_t_flow);
-
-       zft_cmpr_ops = NULL;
-       TRACE_EXIT old_ops;
-}
-
 /*  lock the zft-compressor() module.
  */
 int zft_cmpr_lock(int try_to_load)
@@ -331,45 +316,25 @@ KERN_INFO
 KERN_INFO
 "Support for QIC-113 compatible volume table, dynamic memory allocation\n"
 KERN_INFO
-"and builtin compression (lzrw3 algorithm).\n"
-KERN_INFO
-"Compiled for Linux version %s\n", UTS_RELEASE);
+"and builtin compression (lzrw3 algorithm).\n");
         }
 #else /* !MODULE */
        /* print a short no-nonsense boot message */
-       printk(KERN_INFO ZFTAPE_VERSION " for Linux " UTS_RELEASE "\n");
+       printk(KERN_INFO ZFTAPE_VERSION "\n");
 #endif /* MODULE */
        TRACE(ft_t_info, "zft_init @ 0x%p", zft_init);
        TRACE(ft_t_info,
              "installing zftape VFS interface for ftape driver ...");
        TRACE_CATCH(register_chrdev(QIC117_TAPE_MAJOR, "zft", &zft_cdev),);
 
-       zft_class = class_simple_create(THIS_MODULE, "zft");
+       zft_class = class_create(THIS_MODULE, "zft");
        for (i = 0; i < 4; i++) {
-               class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i), NULL, "qft%i", i);
-               devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i),
-                               S_IFCHR | S_IRUSR | S_IWUSR,
-                               "qft%i", i);
-               class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 4), NULL, "nqft%i", i);
-               devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 4),
-                               S_IFCHR | S_IRUSR | S_IWUSR,
-                               "nqft%i", i);
-               class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 16), NULL, "zqft%i", i);
-               devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 16),
-                               S_IFCHR | S_IRUSR | S_IWUSR,
-                               "zqft%i", i);
-               class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 20), NULL, "nzqft%i", i);
-               devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 20),
-                               S_IFCHR | S_IRUSR | S_IWUSR,
-                               "nzqft%i", i);
-               class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 32), NULL, "rawqft%i", i);
-               devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 32),
-                               S_IFCHR | S_IRUSR | S_IWUSR,
-                               "rawqft%i", i);
-               class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 36), NULL, "nrawrawqft%i", i);
-               devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 36),
-                               S_IFCHR | S_IRUSR | S_IWUSR,
-                               "nrawqft%i", i);
+               class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i), NULL, "qft%i", i);
+               class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 4), NULL, "nqft%i", i);
+               class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 16), NULL, "zqft%i", i);
+               class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 20), NULL, "nzqft%i", i);
+               class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 32), NULL, "rawqft%i", i);
+               class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 36), NULL, "nrawrawqft%i", i);
        }
 
 #ifdef CONFIG_ZFT_COMPRESSOR
@@ -395,20 +360,14 @@ static void zft_exit(void)
                TRACE(ft_t_info, "successful");
        }
         for (i = 0; i < 4; i++) {
-               devfs_remove("qft%i", i);
-               class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i));
-               devfs_remove("nqft%i", i);
-               class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 4));
-               devfs_remove("zqft%i", i);
-               class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 16));
-               devfs_remove("nzqft%i", i);
-               class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 20));
-               devfs_remove("rawqft%i", i);
-               class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 32));
-               devfs_remove("nrawqft%i", i);
-               class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 36));
+               class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i));
+               class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 4));
+               class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 16));
+               class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 20));
+               class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 32));
+               class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 36));
        }
-       class_simple_destroy(zft_class);
+       class_destroy(zft_class);
        zft_uninit_mem(); /* release remaining memory, if any */
         printk(KERN_INFO "zftape successfully unloaded.\n");
        TRACE_EXIT;