Merge branch 'linus' into x86/urgent
[pandora-kernel.git] / drivers / scsi / ch.c
index 92d1cb1..aa2011b 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/chio.h>                        /* here are all the ioctls */
 #include <linux/mutex.h>
 #include <linux/idr.h>
+#include <linux/smp_lock.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
@@ -571,16 +572,19 @@ ch_open(struct inode *inode, struct file *file)
        scsi_changer *ch;
        int minor = iminor(inode);
 
+       lock_kernel();
        spin_lock(&ch_index_lock);
        ch = idr_find(&ch_index_idr, minor);
 
        if (NULL == ch || scsi_device_get(ch->device)) {
                spin_unlock(&ch_index_lock);
+               unlock_kernel();
                return -ENXIO;
        }
        spin_unlock(&ch_index_lock);
 
        file->private_data = ch;
+       unlock_kernel();
        return 0;
 }
 
@@ -881,7 +885,7 @@ static long ch_ioctl_compat(struct file * file,
 static int ch_probe(struct device *dev)
 {
        struct scsi_device *sd = to_scsi_device(dev);
-       struct class_device *class_dev;
+       struct device *class_dev;
        int minor, ret = -ENOMEM;
        scsi_changer *ch;
 
@@ -910,11 +914,11 @@ static int ch_probe(struct device *dev)
        ch->minor = minor;
        sprintf(ch->name,"ch%d",ch->minor);
 
-       class_dev = class_device_create(ch_sysfs_class, NULL,
-                                       MKDEV(SCSI_CHANGER_MAJOR, ch->minor),
-                                       dev, "s%s", ch->name);
+       class_dev = device_create_drvdata(ch_sysfs_class, dev,
+                                         MKDEV(SCSI_CHANGER_MAJOR, ch->minor),
+                                         ch, "s%s", ch->name);
        if (IS_ERR(class_dev)) {
-               printk(KERN_WARNING "ch%d: class_device_create failed\n",
+               printk(KERN_WARNING "ch%d: device_create failed\n",
                       ch->minor);
                ret = PTR_ERR(class_dev);
                goto remove_idr;
@@ -926,7 +930,6 @@ static int ch_probe(struct device *dev)
        if (init)
                ch_init_elem(ch);
 
-       dev_set_drvdata(dev, ch);
        sdev_printk(KERN_INFO, sd, "Attached scsi changer %s\n", ch->name);
 
        return 0;
@@ -945,8 +948,7 @@ static int ch_remove(struct device *dev)
        idr_remove(&ch_index_idr, ch->minor);
        spin_unlock(&ch_index_lock);
 
-       class_device_destroy(ch_sysfs_class,
-                            MKDEV(SCSI_CHANGER_MAJOR,ch->minor));
+       device_destroy(ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR,ch->minor));
        kfree(ch->dt);
        kfree(ch);
        return 0;