Merge branch 'timers/for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[cascardo/linux.git] / drivers / scsi / osst.c
index abef704..1c79f97 100644 (file)
@@ -50,6 +50,7 @@ static const char * osst_version = "0.99.4";
 #include <linux/moduleparam.h>
 #include <linux/delay.h>
 #include <linux/jiffies.h>
+#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/dma.h>
 #include <asm/system.h>
@@ -4359,7 +4360,7 @@ os_bypass:
 
 
 /* Open the device */
-static int os_scsi_tape_open(struct inode * inode, struct file * filp)
+static int __os_scsi_tape_open(struct inode * inode, struct file * filp)
 {
        unsigned short        flags;
        int                   i, b_size, new_session = 0, retval = 0;
@@ -4725,6 +4726,18 @@ err_out:
        return retval;
 }
 
+/* BKL pushdown: spaghetti avoidance wrapper */
+static int os_scsi_tape_open(struct inode * inode, struct file * filp)
+{
+       int ret;
+
+       lock_kernel();
+       ret = __os_scsi_tape_open(inode, filp);
+       unlock_kernel();
+       return ret;
+}
+
+
 
 /* Flush the tape buffer before close */
 static int os_scsi_tape_flush(struct file * filp, fl_owner_t id)
@@ -5591,9 +5604,10 @@ static void osst_remove_sysfs_files(struct device_driver *sysfs)
  * sysfs support for accessing ADR header information
  */
 
-static ssize_t osst_adr_rev_show(struct class_device *class_dev, char *buf)
+static ssize_t osst_adr_rev_show(struct device *dev,
+                                struct device_attribute *attr, char *buf)
 {
-       struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev);
+       struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
        ssize_t l = 0;
 
        if (STp && STp->header_ok && STp->linux_media)
@@ -5601,11 +5615,13 @@ static ssize_t osst_adr_rev_show(struct class_device *class_dev, char *buf)
        return l;
 }
 
-CLASS_DEVICE_ATTR(ADR_rev, S_IRUGO, osst_adr_rev_show, NULL);
+DEVICE_ATTR(ADR_rev, S_IRUGO, osst_adr_rev_show, NULL);
 
-static ssize_t osst_linux_media_version_show(struct class_device *class_dev, char *buf)
+static ssize_t osst_linux_media_version_show(struct device *dev,
+                                            struct device_attribute *attr,
+                                            char *buf)
 {
-       struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev);
+       struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
        ssize_t l = 0;
 
        if (STp && STp->header_ok && STp->linux_media)
@@ -5613,11 +5629,12 @@ static ssize_t osst_linux_media_version_show(struct class_device *class_dev, cha
        return l;
 }
 
-CLASS_DEVICE_ATTR(media_version, S_IRUGO, osst_linux_media_version_show, NULL);
+DEVICE_ATTR(media_version, S_IRUGO, osst_linux_media_version_show, NULL);
 
-static ssize_t osst_capacity_show(struct class_device *class_dev, char *buf)
+static ssize_t osst_capacity_show(struct device *dev,
+                                 struct device_attribute *attr, char *buf)
 {
-       struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev);
+       struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
        ssize_t l = 0;
 
        if (STp && STp->header_ok && STp->linux_media)
@@ -5625,11 +5642,13 @@ static ssize_t osst_capacity_show(struct class_device *class_dev, char *buf)
        return l;
 }
 
-CLASS_DEVICE_ATTR(capacity, S_IRUGO, osst_capacity_show, NULL);
+DEVICE_ATTR(capacity, S_IRUGO, osst_capacity_show, NULL);
 
-static ssize_t osst_first_data_ppos_show(struct class_device *class_dev, char *buf)
+static ssize_t osst_first_data_ppos_show(struct device *dev,
+                                        struct device_attribute *attr,
+                                        char *buf)
 {
-       struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev);
+       struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
        ssize_t l = 0;
 
        if (STp && STp->header_ok && STp->linux_media)
@@ -5637,11 +5656,13 @@ static ssize_t osst_first_data_ppos_show(struct class_device *class_dev, char *b
        return l;
 }
 
-CLASS_DEVICE_ATTR(BOT_frame, S_IRUGO, osst_first_data_ppos_show, NULL);
+DEVICE_ATTR(BOT_frame, S_IRUGO, osst_first_data_ppos_show, NULL);
 
-static ssize_t osst_eod_frame_ppos_show(struct class_device *class_dev, char *buf)
+static ssize_t osst_eod_frame_ppos_show(struct device *dev,
+                                       struct device_attribute *attr,
+                                       char *buf)
 {
-       struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev);
+       struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
        ssize_t l = 0;
 
        if (STp && STp->header_ok && STp->linux_media)
@@ -5649,11 +5670,12 @@ static ssize_t osst_eod_frame_ppos_show(struct class_device *class_dev, char *bu
        return l;
 }
 
-CLASS_DEVICE_ATTR(EOD_frame, S_IRUGO, osst_eod_frame_ppos_show, NULL);
+DEVICE_ATTR(EOD_frame, S_IRUGO, osst_eod_frame_ppos_show, NULL);
 
-static ssize_t osst_filemark_cnt_show(struct class_device *class_dev, char *buf)
+static ssize_t osst_filemark_cnt_show(struct device *dev,
+                                     struct device_attribute *attr, char *buf)
 {
-       struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev);
+       struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
        ssize_t l = 0;
 
        if (STp && STp->header_ok && STp->linux_media)
@@ -5661,7 +5683,7 @@ static ssize_t osst_filemark_cnt_show(struct class_device *class_dev, char *buf)
        return l;
 }
 
-CLASS_DEVICE_ATTR(file_count, S_IRUGO, osst_filemark_cnt_show, NULL);
+DEVICE_ATTR(file_count, S_IRUGO, osst_filemark_cnt_show, NULL);
 
 static struct class *osst_sysfs_class;
 
@@ -5678,44 +5700,36 @@ static int osst_sysfs_init(void)
 
 static void osst_sysfs_destroy(dev_t dev)
 {
-       class_device_destroy(osst_sysfs_class, dev);
+       device_destroy(osst_sysfs_class, dev);
 }
 
 static int osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape * STp, char * name)
 {
-       struct class_device *osst_class_member;
+       struct device *osst_member;
        int err;
 
-       osst_class_member = class_device_create(osst_sysfs_class, NULL, dev,
-                                               device, "%s", name);
-       if (IS_ERR(osst_class_member)) {
+       osst_member = device_create_drvdata(osst_sysfs_class, device, dev, STp, "%s", name);
+       if (IS_ERR(osst_member)) {
                printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name);
-               return PTR_ERR(osst_class_member);
+               return PTR_ERR(osst_member);
        }
 
-       class_set_devdata(osst_class_member, STp);
-       err = class_device_create_file(osst_class_member,
-                                      &class_device_attr_ADR_rev);
+       err = device_create_file(osst_member, &dev_attr_ADR_rev);
        if (err)
                goto err_out;
-       err = class_device_create_file(osst_class_member,
-                                      &class_device_attr_media_version);
+       err = device_create_file(osst_member, &dev_attr_media_version);
        if (err)
                goto err_out;
-       err = class_device_create_file(osst_class_member,
-                                      &class_device_attr_capacity);
+       err = device_create_file(osst_member, &dev_attr_capacity);
        if (err)
                goto err_out;
-       err = class_device_create_file(osst_class_member,
-                                      &class_device_attr_BOT_frame);
+       err = device_create_file(osst_member, &dev_attr_BOT_frame);
        if (err)
                goto err_out;
-       err = class_device_create_file(osst_class_member,
-                                      &class_device_attr_EOD_frame);
+       err = device_create_file(osst_member, &dev_attr_EOD_frame);
        if (err)
                goto err_out;
-       err = class_device_create_file(osst_class_member,
-                                      &class_device_attr_file_count);
+       err = device_create_file(osst_member, &dev_attr_file_count);
        if (err)
                goto err_out;