Merge branch 'core/locking' of git://git.kernel.org/pub/scm/linux/kernel/git/tip...
[pandora-kernel.git] / drivers / char / dsp56k.c
index 9b8278e..7bf7485 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/device.h>
+#include <linux/smp_lock.h>
 
 #include <asm/atarihw.h>
 #include <asm/traps.h>
@@ -136,7 +137,7 @@ static int sizeof_bootstrap = 375;
 
 
 static struct dsp56k_device {
-       long in_use;
+       unsigned long in_use;
        long maxio, timeout;
        int tx_wsize, rx_wsize;
 } dsp56k;
@@ -436,13 +437,17 @@ static unsigned int dsp56k_poll(struct file *file, poll_table *wait)
 static int dsp56k_open(struct inode *inode, struct file *file)
 {
        int dev = iminor(inode) & 0x0f;
+       int ret = 0;
 
+       lock_kernel();
        switch(dev)
        {
        case DSP56K_DEV_56001:
 
-               if (test_and_set_bit(0, &dsp56k.in_use))
-                       return -EBUSY;
+               if (test_and_set_bit(0, &dsp56k.in_use)) {
+                       ret = -EBUSY;
+                       goto out;
+               }
 
                dsp56k.timeout = TIMEOUT;
                dsp56k.maxio = MAXIO;
@@ -458,10 +463,11 @@ static int dsp56k_open(struct inode *inode, struct file *file)
                break;
 
        default:
-               return -ENODEV;
+               ret = -ENODEV;
        }
-
-       return 0;
+out:
+       unlock_kernel();
+       return ret;
 }
 
 static int dsp56k_release(struct inode *inode, struct file *file)
@@ -513,7 +519,7 @@ static int __init dsp56k_init_driver(void)
                err = PTR_ERR(dsp56k_class);
                goto out_chrdev;
        }
-       class_device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k");
+       device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), "dsp56k");
 
        printk(banner);
        goto out;
@@ -527,7 +533,7 @@ module_init(dsp56k_init_driver);
 
 static void __exit dsp56k_cleanup_driver(void)
 {
-       class_device_destroy(dsp56k_class, MKDEV(DSP56K_MAJOR, 0));
+       device_destroy(dsp56k_class, MKDEV(DSP56K_MAJOR, 0));
        class_destroy(dsp56k_class);
        unregister_chrdev(DSP56K_MAJOR, "dsp56k");
 }