vserver 1.9.3
[linux-2.6.git] / drivers / scsi / sg.c
index 7b0665d..ed80392 100644 (file)
@@ -47,8 +47,9 @@ static int sg_version_num = 30531;    /* 2 digits for each component */
 #include <linux/devfs_fs_kernel.h>
 #include <linux/cdev.h>
 #include <linux/seq_file.h>
-
 #include <linux/blkdev.h>
+#include <linux/delay.h>
+
 #include "scsi.h"
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_driver.h>
@@ -205,8 +206,6 @@ static Sg_request *sg_get_rq_mark(Sg_fd * sfp, int pack_id);
 static Sg_request *sg_add_request(Sg_fd * sfp);
 static int sg_remove_request(Sg_fd * sfp, Sg_request * srp);
 static int sg_res_in_use(Sg_fd * sfp);
-static int sg_ms_to_jif(unsigned int msecs);
-static inline unsigned sg_jif_to_ms(int jifs);
 static int sg_allow_access(unsigned char opcode, char dev_type);
 static int sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len);
 static Sg_device *sg_get_dev(int dev);
@@ -611,7 +610,7 @@ sg_new_write(Sg_fd * sfp, const char __user *buf, size_t count,
                        return -EBUSY;  /* reserve buffer already being used */
                }
        }
-       timeout = sg_ms_to_jif(srp->header.timeout);
+       timeout = msecs_to_jiffies(srp->header.timeout);
        if ((!hp->cmdp) || (hp->cmd_len < 6) || (hp->cmd_len > sizeof (cmnd))) {
                sg_remove_request(sfp, srp);
                return -EMSGSIZE;
@@ -719,19 +718,6 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
        return 0;
 }
 
-static inline unsigned
-sg_jif_to_ms(int jifs)
-{
-       if (jifs <= 0)
-               return 0U;
-       else {
-               unsigned int j = (unsigned int) jifs;
-               return (j <
-                       (UINT_MAX / 1000)) ? ((j * 1000) / HZ) : ((j / HZ) *
-                                                                 1000);
-       }
-}
-
 static int
 sg_ioctl(struct inode *inode, struct file *filp,
         unsigned int cmd_in, unsigned long arg)
@@ -941,7 +927,7 @@ sg_ioctl(struct inode *inode, struct file *filp,
                                            srp->header.driver_status;
                                        rinfo[val].duration =
                                            srp->done ? srp->header.duration :
-                                           sg_jif_to_ms(
+                                           jiffies_to_msecs(
                                                jiffies - srp->header.duration);
                                        rinfo[val].orphan = srp->orphan;
                                        rinfo[val].sg_io_owned = srp->sg_io_owned;
@@ -1263,7 +1249,7 @@ sg_cmd_done(Scsi_Cmnd * SCpnt)
        srp->header.resid = SCpnt->resid;
        /* N.B. unit of duration changes here from jiffies to millisecs */
        srp->header.duration =
-           sg_jif_to_ms(jiffies - (int) srp->header.duration);
+           jiffies_to_msecs(jiffies - srp->header.duration);
        if (0 != SRpnt->sr_result) {
                memcpy(srp->sense_b, SRpnt->sr_sense_buffer,
                       sizeof (srp->sense_b));
@@ -1547,7 +1533,7 @@ sg_remove(struct class_device *cl_dev)
        }
 
        if (delay)
-               scsi_sleep(2);  /* dirty detach so delay device destruction */
+               msleep(10);     /* dirty detach so delay device destruction */
 }
 
 /* Set 'perm' (4th argument) to 0 to disable module_param's definition
@@ -2587,17 +2573,6 @@ sg_page_free(char *buff, int size)
        free_pages((unsigned long) buff, order);
 }
 
-static int
-sg_ms_to_jif(unsigned int msecs)
-{
-       if ((UINT_MAX / 2U) < msecs)
-               return INT_MAX; /* special case, set largest possible */
-       else
-               return ((int) msecs <
-                       (INT_MAX / 1000)) ? (((int) msecs * HZ) / 1000)
-                   : (((int) msecs / 1000) * HZ);
-}
-
 static unsigned char allow_ops[] = { TEST_UNIT_READY, REQUEST_SENSE,
        INQUIRY, READ_CAPACITY, READ_BUFFER, READ_6, READ_10, READ_12,
        MODE_SENSE, MODE_SENSE_10, LOG_SENSE
@@ -2960,7 +2935,7 @@ static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp)
        for (k = 0; (fp = sg_get_nth_sfp(sdp, k)); ++k) {
                seq_printf(s, "   FD(%d): timeout=%dms bufflen=%d "
                           "(res)sgat=%d low_dma=%d\n", k + 1,
-                          sg_jif_to_ms(fp->timeout),
+                          jiffies_to_msecs(fp->timeout),
                           fp->reserve.bufflen,
                           (int) fp->reserve.k_use_sg,
                           (int) fp->low_dma);
@@ -2996,8 +2971,8 @@ static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp)
                                seq_printf(s, " dur=%d", hp->duration);
                        else
                                seq_printf(s, " t_o/elap=%d/%d",
-                                 new_interface ? hp->timeout : sg_jif_to_ms(fp->timeout),
-                                 sg_jif_to_ms(hp->duration ? (jiffies - hp->duration) : 0));
+                                 new_interface ? hp->timeout : jiffies_to_msecs(fp->timeout),
+                                 jiffies_to_msecs(hp->duration ? (jiffies - hp->duration) : 0));
                        seq_printf(s, "ms sgat=%d op=0x%02x\n", usg,
                                   (int) srp->data.cmd_opcode);
                }