]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/sg.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6-omap-h63xx.git] / drivers / scsi / sg.c
index 2d30b46806bf30a3d65f9ba1b05672b8143e5c20..72ec59456e6934bfd67c42b35970b5eb0b9c6a87 100644 (file)
@@ -49,6 +49,7 @@ static int sg_version_num = 30533;    /* 2 digits for each component */
 #include <linux/seq_file.h>
 #include <linux/blkdev.h>
 #include <linux/delay.h>
+#include <linux/scatterlist.h>
 
 #include "scsi.h"
 #include <scsi/scsi_dbg.h>
@@ -67,10 +68,6 @@ static int sg_proc_init(void);
 static void sg_proc_cleanup(void);
 #endif
 
-#ifndef LINUX_VERSION_CODE
-#include <linux/version.h>
-#endif                         /* LINUX_VERSION_CODE */
-
 #define SG_ALLOW_DIO_DEF 0
 #define SG_ALLOW_DIO_CODE /* compile out by commenting this define */
 
@@ -475,8 +472,7 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
        sg_finish_rem_req(srp);
        retval = count;
 free_old_hdr:
-       if (old_hdr)
-               kfree(old_hdr);
+       kfree(old_hdr);
        return retval;
 }
 
@@ -1497,10 +1493,9 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
 
  overflow:
        write_unlock_irqrestore(&sg_dev_arr_lock, iflags);
-       printk(KERN_WARNING
-              "Unable to attach sg device <%d, %d, %d, %d> type=%d, minor "
-              "number exceeds %d\n", scsidp->host->host_no, scsidp->channel,
-              scsidp->id, scsidp->lun, scsidp->type, SG_MAX_DEVS - 1);
+       sdev_printk(KERN_WARNING, scsidp,
+                   "Unable to attach sg device type=%d, minor "
+                   "number exceeds %d\n", scsidp->type, SG_MAX_DEVS - 1);
        error = -ENODEV;
        goto out;
 }
@@ -1566,11 +1561,8 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
        } else
                printk(KERN_WARNING "sg_add: sg_sys INvalid\n");
 
-       printk(KERN_NOTICE
-              "Attached scsi generic sg%d at scsi%d, channel"
-              " %d, id %d, lun %d,  type %d\n", k,
-              scsidp->host->host_no, scsidp->channel, scsidp->id,
-              scsidp->lun, scsidp->type);
+       sdev_printk(KERN_NOTICE, scsidp,
+                   "Attached scsi generic sg%d type %d\n", k,scsidp->type);
 
        return 0;
 
@@ -1706,10 +1698,8 @@ exit_sg(void)
        sg_sysfs_valid = 0;
        unregister_chrdev_region(MKDEV(SCSI_GENERIC_MAJOR, 0),
                                 SG_MAX_DEVS);
-       if (sg_dev_arr != NULL) {
-               kfree((char *) sg_dev_arr);
-               sg_dev_arr = NULL;
-       }
+       kfree((char *)sg_dev_arr);
+       sg_dev_arr = NULL;
        sg_dev_max = 0;
 }
 
@@ -1996,9 +1986,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size)
                                if (!p)
                                        break;
                        }
-                       sclp->page = virt_to_page(p);
-                       sclp->offset = offset_in_page(p);
-                       sclp->length = ret_sz;
+                       sg_set_buf(sclp, p, ret_sz);
 
                        SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n",
                                          k, sg_scatg2virt(sclp), ret_sz));