Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / fs / coda / psdev.c
index 6793b37..803aacf 100644 (file)
 #include <linux/kernel.h>
 #include <linux/major.h>
 #include <linux/time.h>
-#include <linux/lp.h>
 #include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/fcntl.h>
 #include <linux/delay.h>
 #include <linux/skbuff.h>
 #include <linux/proc_fs.h>
-#include <linux/devfs_fs_kernel.h>
 #include <linux/vmalloc.h>
 #include <linux/fs.h>
 #include <linux/file.h>
 #include <linux/coda_psdev.h>
 #include <linux/coda_proc.h>
 
-#define upc_free(r) kfree(r)
+#include "coda_int.h"
 
-/* 
- * Coda stuff
- */
-extern struct file_system_type coda_fs_type;
+#define upc_free(r) kfree(r)
 
 /* statistics */
 int           coda_hard;         /* allows signals during upcalls */
@@ -62,7 +57,7 @@ unsigned long coda_timeout = 30; /* .. secs, then signals will dequeue */
 
 
 struct venus_comm coda_comms[MAX_CODADEVS];
-static struct class_simple *coda_psdev_class;
+static struct class *coda_psdev_class;
 
 /*
  * Device operations
@@ -263,7 +258,7 @@ static ssize_t coda_psdev_read(struct file * file, char __user * buf,
        /* If request was not a signal, enqueue and don't free */
        if (!(req->uc_flags & REQ_ASYNC)) {
                req->uc_flags |= REQ_READ;
-               list_add(&(req->uc_chain), vcp->vc_processing.prev);
+               list_add_tail(&(req->uc_chain), &vcp->vc_processing);
                goto out;
        }
 
@@ -310,8 +305,7 @@ static int coda_psdev_open(struct inode * inode, struct file * file)
 static int coda_psdev_release(struct inode * inode, struct file * file)
 {
         struct venus_comm *vcp = (struct venus_comm *) file->private_data;
-        struct upc_req *req;
-       struct list_head *lh, *next;
+        struct upc_req *req, *tmp;
 
        lock_kernel();
        if ( !vcp->vc_inuse ) {
@@ -326,8 +320,7 @@ static int coda_psdev_release(struct inode * inode, struct file * file)
        }
         
         /* Wakeup clients so they can return. */
-       list_for_each_safe(lh, next, &vcp->vc_pending) {
-               req = list_entry(lh, struct upc_req, uc_chain);
+       list_for_each_entry_safe(req, tmp, &vcp->vc_pending, uc_chain) {
                /* Async requests need to be freed here */
                if (req->uc_flags & REQ_ASYNC) {
                        CODA_FREE(req->uc_data, sizeof(struct coda_in_hdr));
@@ -348,7 +341,7 @@ static int coda_psdev_release(struct inode * inode, struct file * file)
 }
 
 
-static struct file_operations coda_psdev_fops = {
+static const struct file_operations coda_psdev_fops = {
        .owner          = THIS_MODULE,
        .read           = coda_psdev_read,
        .write          = coda_psdev_write,
@@ -361,35 +354,24 @@ static struct file_operations coda_psdev_fops = {
 static int init_coda_psdev(void)
 {
        int i, err = 0;
-       if (register_chrdev(CODA_PSDEV_MAJOR,"coda_psdev",
-                                &coda_psdev_fops)) {
+       if (register_chrdev(CODA_PSDEV_MAJOR, "coda", &coda_psdev_fops)) {
               printk(KERN_ERR "coda_psdev: unable to get major %d\n", 
                     CODA_PSDEV_MAJOR);
               return -EIO;
        }
-       coda_psdev_class = class_simple_create(THIS_MODULE, "coda_psdev");
+       coda_psdev_class = class_create(THIS_MODULE, "coda");
        if (IS_ERR(coda_psdev_class)) {
                err = PTR_ERR(coda_psdev_class);
                goto out_chrdev;
        }               
-       devfs_mk_dir ("coda");
-       for (i = 0; i < MAX_CODADEVS; i++) {
-               class_simple_device_add(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR,i), 
-                               NULL, "cfs%d", i);
-               err = devfs_mk_cdev(MKDEV(CODA_PSDEV_MAJOR, i),
-                               S_IFCHR|S_IRUSR|S_IWUSR, "coda/%d", i);
-               if (err)
-                       goto out_class;
-       }
+       for (i = 0; i < MAX_CODADEVS; i++)
+               class_device_create(coda_psdev_class, NULL,
+                               MKDEV(CODA_PSDEV_MAJOR,i), NULL, "cfs%d", i);
        coda_sysctl_init();
        goto out;
 
-out_class:
-       for (i = 0; i < MAX_CODADEVS; i++) 
-               class_simple_device_remove(MKDEV(CODA_PSDEV_MAJOR, i));
-       class_simple_destroy(coda_psdev_class);
 out_chrdev:
-       unregister_chrdev(CODA_PSDEV_MAJOR, "coda_psdev");
+       unregister_chrdev(CODA_PSDEV_MAJOR, "coda");
 out:
        return err;
 }
@@ -398,14 +380,12 @@ out:
 MODULE_AUTHOR("Peter J. Braam <braam@cs.cmu.edu>");
 MODULE_LICENSE("GPL");
 
-extern int coda_init_inodecache(void);
-extern void coda_destroy_inodecache(void);
 static int __init init_coda(void)
 {
        int status;
        int i;
        printk(KERN_INFO "Coda Kernel/Venus communications, "
-#ifdef CODA_FS_OLD_API
+#ifdef CONFIG_CODA_FS_OLD_API
               "v5.3.20"
 #else
               "v6.0.0"
@@ -428,13 +408,10 @@ static int __init init_coda(void)
        }
        return 0;
 out:
-       for (i = 0; i < MAX_CODADEVS; i++) {
-               class_simple_device_remove(MKDEV(CODA_PSDEV_MAJOR, i));
-               devfs_remove("coda/%d", i);
-       }
-       class_simple_destroy(coda_psdev_class);
-       devfs_remove("coda");
-       unregister_chrdev(CODA_PSDEV_MAJOR,"coda_psdev");
+       for (i = 0; i < MAX_CODADEVS; i++)
+               class_device_destroy(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR, i));
+       class_destroy(coda_psdev_class);
+       unregister_chrdev(CODA_PSDEV_MAJOR, "coda");
        coda_sysctl_clean();
 out1:
        coda_destroy_inodecache();
@@ -450,13 +427,10 @@ static void __exit exit_coda(void)
         if ( err != 0 ) {
                 printk("coda: failed to unregister filesystem\n");
         }
-       for (i = 0; i < MAX_CODADEVS; i++) {
-               class_simple_device_remove(MKDEV(CODA_PSDEV_MAJOR, i));
-               devfs_remove("coda/%d", i);
-       }
-       class_simple_destroy(coda_psdev_class);
-       devfs_remove("coda");
-       unregister_chrdev(CODA_PSDEV_MAJOR, "coda_psdev");
+       for (i = 0; i < MAX_CODADEVS; i++)
+               class_device_destroy(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR, i));
+       class_destroy(coda_psdev_class);
+       unregister_chrdev(CODA_PSDEV_MAJOR, "coda");
        coda_sysctl_clean();
        coda_destroy_inodecache();
 }