]> 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 07fee811c09e0886267976e0861f231eaf8b5d18..72ec59456e6934bfd67c42b35970b5eb0b9c6a87 100644 (file)
@@ -68,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 */
 
@@ -476,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;
 }
 
@@ -1498,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;
 }
@@ -1567,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;
 
@@ -1707,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;
 }
 
@@ -1887,13 +1876,17 @@ st_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_pages,
        int i;
 
        for (i=0; i < nr_pages; i++) {
-               if (dirtied && !PageReserved(sgl[i].page))
-                       SetPageDirty(sgl[i].page);
-               /* unlock_page(sgl[i].page); */
+               struct page *page = sgl[i].page;
+
+               /* XXX: just for debug. Remove when PageReserved is removed */
+               BUG_ON(PageReserved(page));
+               if (dirtied)
+                       SetPageDirty(page);
+               /* unlock_page(page); */
                /* FIXME: cache flush missing for rw==READ
                 * FIXME: call the correct reference counting function
                 */
-               page_cache_release(sgl[i].page);
+               page_cache_release(page);
        }
 
        return 0;