include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / char / mbcs.c
index 035575c..83bef4e 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/moduleparam.h>
 #include <linux/types.h>
 #include <linux/ioport.h>
+#include <linux/kernel.h>
 #include <linux/notifier.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
@@ -24,6 +25,8 @@
 #include <linux/mm.h>
 #include <linux/uio.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -310,7 +313,7 @@ do_mbcs_sram_dmawrite(struct mbcs_soft *soft, uint64_t hostAddr,
 {
        int rv = 0;
 
-       if (down_interruptible(&soft->dmawritelock))
+       if (mutex_lock_interruptible(&soft->dmawritelock))
                return -ERESTARTSYS;
 
        atomic_set(&soft->dmawrite_done, 0);
@@ -336,7 +339,7 @@ do_mbcs_sram_dmawrite(struct mbcs_soft *soft, uint64_t hostAddr,
        *off += len;
 
 dmawrite_exit:
-       up(&soft->dmawritelock);
+       mutex_unlock(&soft->dmawritelock);
 
        return rv;
 }
@@ -347,7 +350,7 @@ do_mbcs_sram_dmaread(struct mbcs_soft *soft, uint64_t hostAddr,
 {
        int rv = 0;
 
-       if (down_interruptible(&soft->dmareadlock))
+       if (mutex_lock_interruptible(&soft->dmareadlock))
                return -ERESTARTSYS;
 
        atomic_set(&soft->dmawrite_done, 0);
@@ -372,7 +375,7 @@ do_mbcs_sram_dmaread(struct mbcs_soft *soft, uint64_t hostAddr,
        *off += len;
 
 dmaread_exit:
-       up(&soft->dmareadlock);
+       mutex_unlock(&soft->dmareadlock);
 
        return rv;
 }
@@ -382,15 +385,19 @@ static int mbcs_open(struct inode *ip, struct file *fp)
        struct mbcs_soft *soft;
        int minor;
 
+       lock_kernel();
        minor = iminor(ip);
 
+       /* Nothing protects access to this list... */
        list_for_each_entry(soft, &soft_list, list) {
                if (soft->nasid == minor) {
                        fp->private_data = soft->cxdev;
+                       unlock_kernel();
                        return 0;
                }
        }
 
+       unlock_kernel();
        return -ENODEV;
 }
 
@@ -710,8 +717,8 @@ static ssize_t show_algo(struct device *dev, struct device_attribute *attr, char
         */
        debug0 = *(uint64_t *) soft->debug_addr;
 
-       return sprintf(buf, "0x%lx 0x%lx\n",
-                      (debug0 >> 32), (debug0 & 0xffffffff));
+       return sprintf(buf, "0x%x 0x%x\n",
+                      upper_32_bits(debug0), lower_32_bits(debug0));
 }
 
 static ssize_t store_algo(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
@@ -763,8 +770,8 @@ static int mbcs_probe(struct cx_dev *dev, const struct cx_device_id *id)
        init_waitqueue_head(&soft->dmaread_queue);
        init_waitqueue_head(&soft->algo_queue);
 
-       init_MUTEX(&soft->dmawritelock);
-       init_MUTEX(&soft->dmareadlock);
+       mutex_init(&soft->dmawritelock);
+       mutex_init(&soft->dmareadlock);
        mutex_init(&soft->algolock);
 
        mbcs_getdma_init(&soft->getdma);