kbuild: move tags from ARCH and include/ ahead of drivers
[sfrench/cifs-2.6.git] / block / scsi_ioctl.c
index b3e210723a71f637605852b7d8136ef594af95d2..65c6a3cba6d6e85d31d345dd75b322f7196889a5 100644 (file)
@@ -223,11 +223,12 @@ static int verify_command(struct file *file, unsigned char *cmd)
 static int sg_io(struct file *file, request_queue_t *q,
                struct gendisk *bd_disk, struct sg_io_hdr *hdr)
 {
-       unsigned long start_time;
+       unsigned long start_time, timeout;
        int writing = 0, ret = 0;
        struct request *rq;
        char sense[SCSI_SENSE_BUFFERSIZE];
        unsigned char cmd[BLK_MAX_CDB];
+       struct bio *bio;
 
        if (hdr->interface_id != 'S')
                return -EINVAL;
@@ -270,14 +271,8 @@ static int sg_io(struct file *file, request_queue_t *q,
 
        rq->cmd_type = REQ_TYPE_BLOCK_PC;
 
-       /*
-        * bounce this after holding a reference to the original bio, it's
-        * needed for proper unmapping
-        */
-       if (rq->bio)
-               blk_queue_bounce(q, &rq->bio);
-
-       rq->timeout = jiffies_to_msecs(hdr->timeout);
+       timeout = msecs_to_jiffies(hdr->timeout);
+       rq->timeout = (timeout < INT_MAX) ? timeout : INT_MAX;
        if (!rq->timeout)
                rq->timeout = q->sg_timeout;
        if (!rq->timeout)
@@ -308,6 +303,7 @@ static int sg_io(struct file *file, request_queue_t *q,
        if (ret)
                goto out;
 
+       bio = rq->bio;
        rq->retries = 0;
 
        start_time = jiffies;
@@ -338,7 +334,7 @@ static int sg_io(struct file *file, request_queue_t *q,
                        hdr->sb_len_wr = len;
        }
 
-       if (blk_rq_unmap_user(rq))
+       if (blk_rq_unmap_user(bio))
                ret = -EFAULT;
 
        /* may not have succeeded, but output values written to control