ixp4xx_eth: fix dma_mapping_error() compile errors
[pandora-kernel.git] / block / bsg.c
index 93e757d..5a68b09 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/uio.h>
 #include <linux/idr.h>
 #include <linux/bsg.h>
+#include <linux/smp_lock.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_ioctl.h>
@@ -739,8 +740,13 @@ static int bsg_put_device(struct bsg_device *bd)
        mutex_lock(&bsg_mutex);
 
        do_free = atomic_dec_and_test(&bd->ref_count);
-       if (!do_free)
+       if (!do_free) {
+               mutex_unlock(&bsg_mutex);
                goto out;
+       }
+
+       hlist_del(&bd->dev_list);
+       mutex_unlock(&bsg_mutex);
 
        dprintk("%s: tearing down\n", bd->name);
 
@@ -756,10 +762,8 @@ static int bsg_put_device(struct bsg_device *bd)
         */
        ret = bsg_complete_all_commands(bd);
 
-       hlist_del(&bd->dev_list);
        kfree(bd);
 out:
-       mutex_unlock(&bsg_mutex);
        kref_put(&q->bsg_dev.ref, bsg_kref_release_function);
        if (do_free)
                blk_put_queue(q);
@@ -851,7 +855,11 @@ static struct bsg_device *bsg_get_device(struct inode *inode, struct file *file)
 
 static int bsg_open(struct inode *inode, struct file *file)
 {
-       struct bsg_device *bd = bsg_get_device(inode, file);
+       struct bsg_device *bd;
+
+       lock_kernel();
+       bd = bsg_get_device(inode, file);
+       unlock_kernel();
 
        if (IS_ERR(bd))
                return PTR_ERR(bd);
@@ -1036,7 +1044,8 @@ int bsg_register_queue(struct request_queue *q, struct device *parent,
        bcd->release = release;
        kref_init(&bcd->ref);
        dev = MKDEV(bsg_major, bcd->minor);
-       class_dev = device_create(bsg_class, parent, dev, "%s", devname);
+       class_dev = device_create_drvdata(bsg_class, parent, dev, NULL,
+                                         "%s", devname);
        if (IS_ERR(class_dev)) {
                ret = PTR_ERR(class_dev);
                goto put_dev;