include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / arch / mips / sibyte / common / sb_tbprof.c
index 4fcdaa8..d4ed7a9 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/fs.h>
 #include <linux/errno.h>
@@ -276,8 +275,8 @@ static int sbprof_zbprof_start(struct file *filp)
        sbp.next_tb_sample = 0;
        filp->f_pos = 0;
 
-       err = request_irq (K_INT_TRACE_FREEZE, sbprof_tb_intr, 0,
-                          DEVNAME " trace freeze", &sbp);
+       err = request_irq(K_INT_TRACE_FREEZE, sbprof_tb_intr, 0,
+                         DEVNAME " trace freeze", &sbp);
        if (err)
                return -EBUSY;
 
@@ -412,14 +411,19 @@ static int sbprof_tb_open(struct inode *inode, struct file *filp)
 
        memset(&sbp, 0, sizeof(struct sbprof_tb));
        sbp.sbprof_tbbuf = vmalloc(MAX_TBSAMPLE_BYTES);
-       if (!sbp.sbprof_tbbuf)
+       if (!sbp.sbprof_tbbuf) {
+               sbp.open = SB_CLOSED;
+               wmb();
                return -ENOMEM;
+       }
+
        memset(sbp.sbprof_tbbuf, 0, MAX_TBSAMPLE_BYTES);
        init_waitqueue_head(&sbp.tb_sync);
        init_waitqueue_head(&sbp.tb_read);
        mutex_init(&sbp.lock);
 
        sbp.open = SB_OPEN;
+       wmb();
 
        return 0;
 }
@@ -429,7 +433,7 @@ static int sbprof_tb_release(struct inode *inode, struct file *filp)
        int minor;
 
        minor = iminor(inode);
-       if (minor != 0 || !sbp.open)
+       if (minor != 0 || sbp.open != SB_CLOSED)
                return -ENODEV;
 
        mutex_lock(&sbp.lock);
@@ -438,7 +442,8 @@ static int sbprof_tb_release(struct inode *inode, struct file *filp)
                sbprof_zbprof_stop();
 
        vfree(sbp.sbprof_tbbuf);
-       sbp.open = 0;
+       sbp.open = SB_CLOSED;
+       wmb();
 
        mutex_unlock(&sbp.lock);
 
@@ -565,14 +570,15 @@ static int __init sbprof_tb_init(void)
 
        tb_class = tbc;
 
-       dev = device_create(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0), "tb");
+       dev = device_create(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0), NULL, "tb");
        if (IS_ERR(dev)) {
                err = PTR_ERR(dev);
                goto out_class;
        }
        tb_dev = dev;
 
-       sbp.open = 0;
+       sbp.open = SB_CLOSED;
+       wmb();
        tb_period = zbbus_mhz * 10000LL;
        pr_info(DEVNAME ": initialized - tb_period = %lld\n",
                (long long) tb_period);