include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / char / briq_panel.c
index 669965a..555cd93 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <linux/module.h>
 
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/tty.h>
@@ -13,7 +14,6 @@
 #include <linux/kernel.h>
 #include <linux/wait.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
 #include <linux/miscdevice.h>
@@ -67,11 +67,15 @@ static void set_led(char state)
 
 static int briq_panel_open(struct inode *ino, struct file *filep)
 {
-       /* enforce single access */
-       if (vfd_is_open)
+       lock_kernel();
+       /* enforce single access, vfd_is_open is protected by BKL */
+       if (vfd_is_open) {
+               unlock_kernel();
                return -EBUSY;
+       }
        vfd_is_open = 1;
 
+       unlock_kernel();
        return 0;
 }
 
@@ -91,11 +95,6 @@ static ssize_t briq_panel_read(struct file *file, char __user *buf, size_t count
        unsigned short c;
        unsigned char cp;
 
-#if 0  /*  Can't seek (pread) on this device  */
-       if (ppos != &file->f_pos)
-               return -ESPIPE;
-#endif
-
        if (!vfd_is_open)
                return -ENODEV;
 
@@ -139,11 +138,6 @@ static ssize_t briq_panel_write(struct file *file, const char __user *buf, size_
        size_t indx = len;
        int i, esc = 0;
 
-#if 0  /*  Can't seek (pwrite) on this device  */
-       if (ppos != &file->f_pos)
-               return -ESPIPE;
-#endif
-
        if (!vfd_is_open)
                return -EBUSY;
 
@@ -202,13 +196,16 @@ static struct miscdevice briq_panel_miscdev = {
 
 static int __init briq_panel_init(void)
 {
-       struct device_node *root = find_path_device("/");
+       struct device_node *root = of_find_node_by_path("/");
        const char *machine;
        int i;
 
        machine = of_get_property(root, "model", NULL);
-       if (!machine || strncmp(machine, "TotalImpact,BRIQ-1", 18) != 0)
+       if (!machine || strncmp(machine, "TotalImpact,BRIQ-1", 18) != 0) {
+               of_node_put(root);
                return -ENODEV;
+       }
+       of_node_put(root);
 
        printk(KERN_INFO
                "briq_panel: v%s Dr. Karsten Jeppesen (kj@totalimpact.com)\n",