]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/st.c
[SCSI] qla2xxx: changes in multiq code
[linux-2.6-omap-h63xx.git] / drivers / scsi / st.c
index 11341b717bbafe9c586276baa20034ce582e4a55..7f3f317ee6ca7e2c69eedac77ca8c0d60a198c7c 100644 (file)
@@ -627,6 +627,7 @@ static int cross_eof(struct scsi_tape * STp, int forward)
 {
        struct st_request *SRpnt;
        unsigned char cmd[MAX_COMMAND_SIZE];
+       int ret;
 
        cmd[0] = SPACE;
        cmd[1] = 0x01;          /* Space FileMarks */
@@ -640,20 +641,26 @@ static int cross_eof(struct scsi_tape * STp, int forward)
         DEBC(printk(ST_DEB_MSG "%s: Stepping over filemark %s.\n",
                   tape_name(STp), forward ? "forward" : "backward"));
 
-       SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE,
-                          STp->device->request_queue->rq_timeout,
-                          MAX_RETRIES, 1);
+       SRpnt = st_allocate_request(STp);
        if (!SRpnt)
-               return (STp->buffer)->syscall_result;
+               return STp->buffer->syscall_result;
 
-       st_release_request(SRpnt);
-       SRpnt = NULL;
+       ret = st_scsi_kern_execute(SRpnt, cmd, DMA_NONE, NULL, 0,
+                                  STp->device->request_queue->rq_timeout,
+                                  MAX_RETRIES);
+       if (ret)
+               goto out;
+
+       ret = STp->buffer->syscall_result;
 
        if ((STp->buffer)->cmdstat.midlevel_result != 0)
                printk(KERN_ERR "%s: Stepping over filemark %s failed.\n",
                   tape_name(STp), forward ? "forward" : "backward");
 
-       return (STp->buffer)->syscall_result;
+out:
+       st_release_request(SRpnt);
+
+       return ret;
 }
 
 
@@ -874,21 +881,24 @@ static int test_ready(struct scsi_tape *STp, int do_wait)
        int attentions, waits, max_wait, scode;
        int retval = CHKRES_READY, new_session = 0;
        unsigned char cmd[MAX_COMMAND_SIZE];
-       struct st_request *SRpnt = NULL;
+       struct st_request *SRpnt;
        struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat;
 
+       SRpnt = st_allocate_request(STp);
+       if (!SRpnt)
+               return STp->buffer->syscall_result;
+
        max_wait = do_wait ? ST_BLOCK_SECONDS : 0;
 
        for (attentions=waits=0; ; ) {
                memset((void *) &cmd[0], 0, MAX_COMMAND_SIZE);
                cmd[0] = TEST_UNIT_READY;
-               SRpnt = st_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE,
-                                  STp->long_timeout, MAX_READY_RETRIES, 1);
 
-               if (!SRpnt) {
-                       retval = (STp->buffer)->syscall_result;
+               retval = st_scsi_kern_execute(SRpnt, cmd, DMA_NONE, NULL, 0,
+                                             STp->long_timeout,
+                                             MAX_READY_RETRIES);
+               if (retval)
                        break;
-               }
 
                if (cmdstatp->have_sense) {
 
@@ -932,8 +942,8 @@ static int test_ready(struct scsi_tape *STp, int do_wait)
                break;
        }
 
-       if (SRpnt != NULL)
-               st_release_request(SRpnt);
+       st_release_request(SRpnt);
+
        return retval;
 }
 
@@ -1010,17 +1020,24 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
                }
        }
 
+       SRpnt = st_allocate_request(STp);
+       if (!SRpnt) {
+               retval = STp->buffer->syscall_result;
+               goto err_out;
+       }
+
        if (STp->omit_blklims)
                STp->min_block = STp->max_block = (-1);
        else {
                memset((void *) &cmd[0], 0, MAX_COMMAND_SIZE);
                cmd[0] = READ_BLOCK_LIMITS;
 
-               SRpnt = st_do_scsi(SRpnt, STp, cmd, 6, DMA_FROM_DEVICE,
-                                  STp->device->request_queue->rq_timeout,
-                                  MAX_READY_RETRIES, 1);
-               if (!SRpnt) {
-                       retval = (STp->buffer)->syscall_result;
+               retval = st_scsi_kern_execute(SRpnt, cmd, DMA_FROM_DEVICE,
+                                             STp->buffer->b_data, 6,
+                                             STp->device->request_queue->rq_timeout,
+                                             MAX_READY_RETRIES);
+               if (retval) {
+                       st_release_request(SRpnt);
                        goto err_out;
                }
 
@@ -1044,11 +1061,12 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
        cmd[0] = MODE_SENSE;
        cmd[4] = 12;
 
-       SRpnt = st_do_scsi(SRpnt, STp, cmd, 12, DMA_FROM_DEVICE,
-                          STp->device->request_queue->rq_timeout,
-                          MAX_READY_RETRIES, 1);
-       if (!SRpnt) {
-               retval = (STp->buffer)->syscall_result;
+       retval = st_scsi_kern_execute(SRpnt, cmd, DMA_FROM_DEVICE,
+                                     STp->buffer->b_data, 12,
+                                     STp->device->request_queue->rq_timeout,
+                                     MAX_READY_RETRIES);
+       if (retval) {
+               st_release_request(SRpnt);
                goto err_out;
        }
 
@@ -1278,11 +1296,17 @@ static int st_flush(struct file *filp, fl_owner_t id)
                cmd[0] = WRITE_FILEMARKS;
                cmd[4] = 1 + STp->two_fm;
 
-               SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE,
-                                  STp->device->request_queue->rq_timeout,
-                                  MAX_WRITE_RETRIES, 1);
+               SRpnt = st_allocate_request(STp);
                if (!SRpnt) {
-                       result = (STp->buffer)->syscall_result;
+                       result = STp->buffer->syscall_result;
+                       goto out;
+               }
+
+               result = st_scsi_kern_execute(SRpnt, cmd, DMA_NONE, NULL, 0,
+                                             STp->device->request_queue->rq_timeout,
+                                             MAX_WRITE_RETRIES);
+               if (result) {
+                       st_release_request(SRpnt);
                        goto out;
                }
 
@@ -2347,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;
@@ -2356,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;
 }
 
 
@@ -2371,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;
@@ -2387,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;
 }
 
 
@@ -2512,13 +2547,16 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_cod
                printk(ST_DEB_MSG "%s: Loading tape.\n", name);
                );
 
-       SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE,
-                          timeout, MAX_RETRIES, 1);
+       SRpnt = st_allocate_request(STp);
        if (!SRpnt)
-               return (STp->buffer)->syscall_result;
+               return STp->buffer->syscall_result;
+
+       retval = st_scsi_kern_execute(SRpnt, cmd, DMA_NONE, NULL, 0, timeout,
+                                     MAX_RETRIES);
+       if (retval)
+               goto out;
 
        retval = (STp->buffer)->syscall_result;
-       st_release_request(SRpnt);
 
        if (!retval) {  /* SCSI command successful */
 
@@ -2537,6 +2575,8 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_cod
                STps = &(STp->ps[STp->partition]);
                STps->drv_file = STps->drv_block = (-1);
        }
+out:
+       st_release_request(SRpnt);
 
        return retval;
 }
@@ -2812,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);
@@ -2979,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 &&
@@ -3011,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;
 
@@ -3085,10 +3135,14 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition
                timeout = STp->device->request_queue->rq_timeout;
        }
 
-       SRpnt = st_do_scsi(NULL, STp, scmd, 0, DMA_NONE,
-                          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_NONE, NULL, 0,
+                                     timeout, MAX_READY_RETRIES);
+       if (result)
+               goto out;
 
        STps->drv_block = STps->drv_file = (-1);
        STps->eof = ST_NOEOF;
@@ -3113,7 +3167,7 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition
                        STps->drv_block = STps->drv_file = 0;
                result = 0;
        }
-
+out:
        st_release_request(SRpnt);
        SRpnt = NULL;