Merge branch 'bkl-removal' into next
[pandora-kernel.git] / drivers / char / misc.c
index 4d058da..6e1563c 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/device.h>
 #include <linux/tty.h>
 #include <linux/kmod.h>
+#include <linux/smp_lock.h>
 
 /*
  * Head entry for the doubly linked miscdevice list
@@ -118,6 +119,7 @@ static int misc_open(struct inode * inode, struct file * file)
        int err = -ENODEV;
        const struct file_operations *old_fops, *new_fops = NULL;
        
+       lock_kernel();
        mutex_lock(&misc_mtx);
        
        list_for_each_entry(c, &misc_list, list) {
@@ -155,6 +157,7 @@ static int misc_open(struct inode * inode, struct file * file)
        fops_put(old_fops);
 fail:
        mutex_unlock(&misc_mtx);
+       unlock_kernel();
        return err;
 }
 
@@ -263,23 +266,26 @@ EXPORT_SYMBOL(misc_deregister);
 
 static int __init misc_init(void)
 {
-#ifdef CONFIG_PROC_FS
-       struct proc_dir_entry *ent;
+       int err;
 
-       ent = create_proc_entry("misc", 0, NULL);
-       if (ent)
-               ent->proc_fops = &misc_proc_fops;
+#ifdef CONFIG_PROC_FS
+       proc_create("misc", 0, NULL, &misc_proc_fops);
 #endif
        misc_class = class_create(THIS_MODULE, "misc");
+       err = PTR_ERR(misc_class);
        if (IS_ERR(misc_class))
-               return PTR_ERR(misc_class);
+               goto fail_remove;
 
-       if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) {
-               printk("unable to get major %d for misc devices\n",
-                      MISC_MAJOR);
-               class_destroy(misc_class);
-               return -EIO;
-       }
+       err = -EIO;
+       if (register_chrdev(MISC_MAJOR,"misc",&misc_fops))
+               goto fail_printk;
        return 0;
+
+fail_printk:
+       printk("unable to get major %d for misc devices\n", MISC_MAJOR);
+       class_destroy(misc_class);
+fail_remove:
+       remove_proc_entry("misc", NULL);
+       return err;
 }
 subsys_initcall(misc_init);