]> err.no Git - linux-2.6/blobdiff - drivers/scsi/st.c
Merge git://git.skbuff.net/gitroot/yoshfuji/linux-2.6-git-rfc3542
[linux-2.6] / drivers / scsi / st.c
index 47a5698a712a7461459dadbf91ac5e06d2c2780f..a93308ae97362b3fa2d0b2a76979ffca3c5da630 100644 (file)
@@ -17,7 +17,7 @@
    Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support
  */
 
-static char *verstr = "20050802";
+static char *verstr = "20050830";
 
 #include <linux/module.h>
 
@@ -4241,12 +4241,10 @@ static int __init init_st(void)
                        do_create_driverfs_files();
                        return 0;
                }
-               if (st_sysfs_class)
-                       class_destroy(st_sysfs_class);
                unregister_chrdev_region(MKDEV(SCSI_TAPE_MAJOR, 0),
-
                                         ST_MAX_TAPE_ENTRIES);
        }
+       class_destroy(st_sysfs_class);
 
        printk(KERN_ERR "Unable to get major %d for SCSI tapes\n", SCSI_TAPE_MAJOR);
        return 1;
@@ -4254,13 +4252,11 @@ static int __init init_st(void)
 
 static void __exit exit_st(void)
 {
-       if (st_sysfs_class)
-               class_destroy(st_sysfs_class);
-       st_sysfs_class = NULL;
        do_remove_driverfs_files();
        scsi_unregister_driver(&st_template.gendrv);
        unregister_chrdev_region(MKDEV(SCSI_TAPE_MAJOR, 0),
                                 ST_MAX_TAPE_ENTRIES);
+       class_destroy(st_sysfs_class);
        kfree(scsi_tapes);
        printk(KERN_INFO "st: Unloaded.\n");
 }
@@ -4444,12 +4440,12 @@ static int st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pag
 static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, 
                              unsigned long uaddr, size_t count, int rw)
 {
+       unsigned long end = (uaddr + count + PAGE_SIZE - 1) >> PAGE_SHIFT;
+       unsigned long start = uaddr >> PAGE_SHIFT;
+       const int nr_pages = end - start;
        int res, i, j;
-       unsigned int nr_pages;
        struct page **pages;
 
-       nr_pages = ((uaddr & ~PAGE_MASK) + count + ~PAGE_MASK) >> PAGE_SHIFT;
-
        /* User attempted Overflow! */
        if ((uaddr + count) < uaddr)
                return -EINVAL;