]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/st.c
Merge branch 'cpus4096-for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-omap-h63xx.git] / drivers / scsi / st.c
index 322ca87d252e5dd7843199928baa1e0d38865eca..7f3f317ee6ca7e2c69eedac77ca8c0d60a198c7c 100644 (file)
@@ -2371,7 +2371,8 @@ static int st_set_options(struct scsi_tape *STp, long options)
 static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs)
 {
        unsigned char cmd[MAX_COMMAND_SIZE];
-       struct st_request *SRpnt = NULL;
+       struct st_request *SRpnt;
+       int ret;
 
        memset(cmd, 0, MAX_COMMAND_SIZE);
        cmd[0] = MODE_SENSE;
@@ -2380,14 +2381,17 @@ static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs)
        cmd[2] = page;
        cmd[4] = 255;
 
-       SRpnt = st_do_scsi(SRpnt, STp, cmd, cmd[4], DMA_FROM_DEVICE,
-                          STp->device->request_queue->rq_timeout, 0, 1);
-       if (SRpnt == NULL)
-               return (STp->buffer)->syscall_result;
+       SRpnt = st_allocate_request(STp);
+       if (!SRpnt)
+               return STp->buffer->syscall_result;
 
+       ret = st_scsi_kern_execute(SRpnt, cmd, DMA_FROM_DEVICE,
+                                  STp->buffer->b_data, cmd[4],
+                                  STp->device->request_queue->rq_timeout,
+                                  MAX_RETRIES);
        st_release_request(SRpnt);
 
-       return (STp->buffer)->syscall_result;
+       return ret ? : STp->buffer->syscall_result;
 }
 
 
@@ -2395,9 +2399,9 @@ static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs)
    in the buffer is correctly formatted. The long timeout is used if slow is non-zero. */
 static int write_mode_page(struct scsi_tape *STp, int page, int slow)
 {
-       int pgo;
+       int pgo, timeout, ret = 0;
        unsigned char cmd[MAX_COMMAND_SIZE];
-       struct st_request *SRpnt = NULL;
+       struct st_request *SRpnt;
 
        memset(cmd, 0, MAX_COMMAND_SIZE);
        cmd[0] = MODE_SELECT;
@@ -2411,14 +2415,21 @@ static int write_mode_page(struct scsi_tape *STp, int page, int slow)
        (STp->buffer)->b_data[MH_OFF_DEV_SPECIFIC] &= ~MH_BIT_WP;
        (STp->buffer)->b_data[pgo + MP_OFF_PAGE_NBR] &= MP_MSK_PAGE_NBR;
 
-       SRpnt = st_do_scsi(SRpnt, STp, cmd, cmd[4], DMA_TO_DEVICE,
-                          (slow ? STp->long_timeout : STp->device->request_queue->rq_timeout), 0, 1);
-       if (SRpnt == NULL)
-               return (STp->buffer)->syscall_result;
+       SRpnt = st_allocate_request(STp);
+       if (!SRpnt)
+               return ret;
+
+       timeout = slow ? STp->long_timeout :
+               STp->device->request_queue->rq_timeout;
+
+       ret = st_scsi_kern_execute(SRpnt, cmd, DMA_TO_DEVICE,
+                                  STp->buffer->b_data, cmd[4], timeout, 0);
+       if (!ret)
+               ret = STp->buffer->syscall_result;
 
        st_release_request(SRpnt);
 
-       return (STp->buffer)->syscall_result;
+       return ret;
 }
 
 
@@ -2841,12 +2852,15 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
                return (-ENOSYS);
        }
 
-       SRpnt = st_do_scsi(NULL, STp, cmd, datalen, direction,
-                          timeout, MAX_RETRIES, 1);
+       SRpnt = st_allocate_request(STp);
        if (!SRpnt)
                return (STp->buffer)->syscall_result;
 
-       ioctl_result = (STp->buffer)->syscall_result;
+       ioctl_result = st_scsi_kern_execute(SRpnt, cmd, direction,
+                                           STp->buffer->b_data, datalen,
+                                           timeout, MAX_RETRIES);
+       if (!ioctl_result)
+               ioctl_result = (STp->buffer)->syscall_result;
 
        if (!ioctl_result) {    /* SCSI command successful */
                st_release_request(SRpnt);
@@ -3008,11 +3022,17 @@ static int get_location(struct scsi_tape *STp, unsigned int *block, int *partiti
                if (!logical && !STp->scsi2_logical)
                        scmd[1] = 1;
        }
-       SRpnt = st_do_scsi(NULL, STp, scmd, 20, DMA_FROM_DEVICE,
-                          STp->device->request_queue->rq_timeout,
-                          MAX_READY_RETRIES, 1);
+
+       SRpnt = st_allocate_request(STp);
        if (!SRpnt)
-               return (STp->buffer)->syscall_result;
+               return STp->buffer->syscall_result;
+
+       result = st_scsi_kern_execute(SRpnt, scmd, DMA_FROM_DEVICE,
+                                     STp->buffer->b_data, 20,
+                                     STp->device->request_queue->rq_timeout,
+                                     MAX_READY_RETRIES);
+       if (result)
+               goto out;
 
        if ((STp->buffer)->syscall_result != 0 ||
            (STp->device->scsi_level >= SCSI_2 &&
@@ -3040,6 +3060,7 @@ static int get_location(struct scsi_tape *STp, unsigned int *block, int *partiti
                 DEBC(printk(ST_DEB_MSG "%s: Got tape pos. blk %d part %d.\n", name,
                             *block, *partition));
        }
+out:
        st_release_request(SRpnt);
        SRpnt = NULL;