]> err.no Git - linux-2.6/commitdiff
[SCSI] replace sizeof sense_buffer with SCSI_SENSE_BUFFERSIZE
authorFUJITA Tomonori <tomof@acm.org>
Sun, 13 Jan 2008 06:46:13 +0000 (15:46 +0900)
committerJames Bottomley <James.Bottomley@HansenPartnership.com>
Wed, 23 Jan 2008 17:29:27 +0000 (11:29 -0600)
This replaces sizeof sense_buffer with SCSI_SENSE_BUFFERSIZE in
several LLDs. It's a preparation for the future changes to remove
sense_buffer array in scsi_cmnd structure.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
28 files changed:
drivers/message/fusion/mptscsih.c
drivers/message/i2o/i2o_scsi.c
drivers/scsi/53c700.c
drivers/scsi/BusLogic.c
drivers/scsi/aacraid/aachba.c
drivers/scsi/advansys.c
drivers/scsi/aha1542.c
drivers/scsi/aha1740.c
drivers/scsi/aic7xxx/aic79xx_osm.c
drivers/scsi/aic7xxx/aic7xxx_osm.c
drivers/scsi/aic7xxx_old.c
drivers/scsi/arcmsr/arcmsr_hba.c
drivers/scsi/dc395x.c
drivers/scsi/dpt_i2o.c
drivers/scsi/eata.c
drivers/scsi/hptiop.c
drivers/scsi/ips.c
drivers/scsi/ncr53c8xx.c
drivers/scsi/qla1280.c
drivers/scsi/qla2xxx/qla_isr.c
drivers/scsi/qla4xxx/ql4_isr.c
drivers/scsi/qlogicpti.c
drivers/scsi/scsi_error.c
drivers/scsi/scsi_lib.c
drivers/scsi/sym53c8xx_2/sym_glue.c
drivers/scsi/tmscsim.c
drivers/scsi/u14-34f.c
drivers/scsi/ultrastor.c

index 626bb3c9af2b0d6614d2313753b4c9796e64bb5e..5c614ec38cc494da6671db10a964302cca993127 100644 (file)
@@ -111,7 +111,7 @@ int                 mptscsih_suspend(struct pci_dev *pdev, pm_message_t state);
 int            mptscsih_resume(struct pci_dev *pdev);
 #endif
 
-#define SNS_LEN(scp)   sizeof((scp)->sense_buffer)
+#define SNS_LEN(scp)   SCSI_SENSE_BUFFERSIZE
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
index aa6fb9429d58a06f84621324d682c7b25f9edf36..1bcdbbb9e7d39853015153cab1a4315a4f23c832 100644 (file)
@@ -370,7 +370,7 @@ static int i2o_scsi_reply(struct i2o_controller *c, u32 m,
         */
        if (cmd->result)
                memcpy(cmd->sense_buffer, &msg->body[3],
-                      min(sizeof(cmd->sense_buffer), (size_t) 40));
+                      min(SCSI_SENSE_BUFFERSIZE, 40));
 
        /* only output error code if AdapterStatus is not HBA_SUCCESS */
        if ((error >> 8) & 0xff)
index 71ff3fbfce12559d161fed31be5d6d1f90101677..f4c4fe90240abdbf995d4c2f8afe0ef9b87374b4 100644 (file)
@@ -608,7 +608,8 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata,
                        scsi_print_sense("53c700", SCp);
 
 #endif
-                       dma_unmap_single(hostdata->dev, slot->dma_handle, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);
+                       dma_unmap_single(hostdata->dev, slot->dma_handle,
+                                        SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
                        /* restore the old result if the request sense was
                         * successful */
                        if (result == 0)
@@ -1010,7 +1011,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
                                cmnd[1] = (SCp->device->lun & 0x7) << 5;
                                cmnd[2] = 0;
                                cmnd[3] = 0;
-                               cmnd[4] = sizeof(SCp->sense_buffer);
+                               cmnd[4] = SCSI_SENSE_BUFFERSIZE;
                                cmnd[5] = 0;
                                /* Here's a quiet hack: the
                                 * REQUEST_SENSE command is six bytes,
@@ -1024,14 +1025,14 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
                                SCp->cmd_len = 6; /* command length for
                                                   * REQUEST_SENSE */
                                slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE);
-                               slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);
-                               slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | sizeof(SCp->sense_buffer));
+                               slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
+                               slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | SCSI_SENSE_BUFFERSIZE);
                                slot->SG[0].pAddr = bS_to_host(slot->dma_handle);
                                slot->SG[1].ins = bS_to_host(SCRIPT_RETURN);
                                slot->SG[1].pAddr = 0;
                                slot->resume_offset = hostdata->pScript;
                                dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG[0])*2, DMA_TO_DEVICE);
-                               dma_cache_sync(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);
+                               dma_cache_sync(hostdata->dev, SCp->sense_buffer, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
 
                                /* queue the command for reissue */
                                slot->state = NCR_700_SLOT_QUEUED;
index 49e1ffa4b2ffbf700f2c1c22b43ebd7c59f8776a..ead47c143ce04fd9792da0d30c9a7b31f7d0db03 100644 (file)
@@ -2947,7 +2947,7 @@ static int BusLogic_QueueCommand(struct scsi_cmnd *Command, void (*CompletionRou
                }
        }
        memcpy(CCB->CDB, CDB, CDB_Length);
-       CCB->SenseDataLength = sizeof(Command->sense_buffer);
+       CCB->SenseDataLength = SCSI_SENSE_BUFFERSIZE;
        CCB->SenseDataPointer = pci_map_single(HostAdapter->PCI_Device, Command->sense_buffer, CCB->SenseDataLength, PCI_DMA_FROMDEVICE);
        CCB->Command = Command;
        Command->scsi_done = CompletionRoutine;
index 62d95165d2a6a96435b16ecaab102656d4d67f90..aadedbd630835ce824c6606e2ed0159ac34d2c30 100644 (file)
@@ -912,8 +912,8 @@ static int aac_bounds_32(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba)
                            ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
                            0, 0);
                memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
-                 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(cmd->sense_buffer))
-                   ? sizeof(cmd->sense_buffer)
+                 (sizeof(dev->fsa_dev[cid].sense_data) > SCSI_SENSE_BUFFERSIZE)
+                   ? SCSI_SENSE_BUFFERSIZE
                    : sizeof(dev->fsa_dev[cid].sense_data));
                cmd->scsi_done(cmd);
                return 1;
@@ -1525,8 +1525,8 @@ static void io_callback(void *context, struct fib * fibptr)
                                    ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
                                    0, 0);
                memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
-                 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
-                   ? sizeof(scsicmd->sense_buffer)
+                 (sizeof(dev->fsa_dev[cid].sense_data) > SCSI_SENSE_BUFFERSIZE)
+                   ? SCSI_SENSE_BUFFERSIZE
                    : sizeof(dev->fsa_dev[cid].sense_data));
        }
        aac_fib_complete(fibptr);
@@ -1739,8 +1739,8 @@ static void synchronize_callback(void *context, struct fib *fibptr)
                                    ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
                                    0, 0);
                memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
-                 min(sizeof(dev->fsa_dev[cid].sense_data),
-                         sizeof(cmd->sense_buffer)));
+                      min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data),
+                            SCSI_SENSE_BUFFERSIZE));
        }
 
        aac_fib_complete(fibptr);
@@ -1949,8 +1949,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
                            SENCODE_INVALID_COMMAND,
                            ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
                memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
-                 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
-                   ? sizeof(scsicmd->sense_buffer)
+                 (sizeof(dev->fsa_dev[cid].sense_data) > SCSI_SENSE_BUFFERSIZE)
+                   ? SCSI_SENSE_BUFFERSIZE
                    : sizeof(dev->fsa_dev[cid].sense_data));
                scsicmd->scsi_done(scsicmd);
                return 0;
@@ -2002,8 +2002,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
                                memcpy(scsicmd->sense_buffer,
                                  &dev->fsa_dev[cid].sense_data,
                                  (sizeof(dev->fsa_dev[cid].sense_data) >
-                                   sizeof(scsicmd->sense_buffer))
-                                      ? sizeof(scsicmd->sense_buffer)
+                                   SCSI_SENSE_BUFFERSIZE)
+                                      ? SCSI_SENSE_BUFFERSIZE
                                       : sizeof(dev->fsa_dev[cid].sense_data));
                        }
                        scsicmd->scsi_done(scsicmd);
@@ -2259,8 +2259,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
                                ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND,
                                ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
                        memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
-                         (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
-                           ? sizeof(scsicmd->sense_buffer)
+                         (sizeof(dev->fsa_dev[cid].sense_data) > SCSI_SENSE_BUFFERSIZE)
+                           ? SCSI_SENSE_BUFFERSIZE
                            : sizeof(dev->fsa_dev[cid].sense_data));
                        scsicmd->scsi_done(scsicmd);
                        return 0;
@@ -2422,8 +2422,8 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
                int len;
                printk(KERN_WARNING "aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply->status));
                len = (le32_to_cpu(srbreply->sense_data_size) > 
-                               sizeof(scsicmd->sense_buffer)) ?
-                               sizeof(scsicmd->sense_buffer) : 
+                               SCSI_SENSE_BUFFERSIZE) ?
+                               SCSI_SENSE_BUFFERSIZE :
                                le32_to_cpu(srbreply->sense_data_size);
                scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
                memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);
@@ -2528,8 +2528,8 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
                int len;
                scsicmd->result |= SAM_STAT_CHECK_CONDITION;
                len = (le32_to_cpu(srbreply->sense_data_size) > 
-                               sizeof(scsicmd->sense_buffer)) ?
-                               sizeof(scsicmd->sense_buffer) :
+                               SCSI_SENSE_BUFFERSIZE) ?
+                               SCSI_SENSE_BUFFERSIZE :
                                le32_to_cpu(srbreply->sense_data_size);
 #ifdef AAC_DETAILED_STATUS_INFO
                printk(KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n",
index 9dd3952516c548c84b61b0754ab406b14ae36dd0..492702ba64630617fb1f6925dc6e772348872d1d 100644 (file)
@@ -8233,7 +8233,7 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
                        if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
                                ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
                                ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
-                                                 sizeof(scp->sense_buffer));
+                                                 SCSI_SENSE_BUFFERSIZE);
                                /*
                                 * Note: The 'status_byte()' macro used by
                                 * target drivers defined in scsi.h shifts the
@@ -9136,7 +9136,7 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
        BUG_ON(asc_dvc_varp != &boardp->dvc_var.asc_dvc_var);
 
        dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
-                       sizeof(scp->sense_buffer), DMA_FROM_DEVICE);
+                        SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
        /*
         * 'qdonep' contains the command's ending status.
         */
@@ -9166,7 +9166,7 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
                        if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
                                ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
                                ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
-                                                 sizeof(scp->sense_buffer));
+                                                 SCSI_SENSE_BUFFERSIZE);
                                /*
                                 * Note: The 'status_byte()' macro used by
                                 * target drivers defined in scsi.h shifts the
@@ -9881,9 +9881,9 @@ static __le32 advansys_get_sense_buffer_dma(struct scsi_cmnd *scp)
 {
        struct asc_board *board = shost_priv(scp->device->host);
        scp->SCp.dma_handle = dma_map_single(board->dev, scp->sense_buffer,
-                               sizeof(scp->sense_buffer), DMA_FROM_DEVICE);
+                                            SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
        dma_cache_sync(board->dev, scp->sense_buffer,
-                               sizeof(scp->sense_buffer), DMA_FROM_DEVICE);
+                      SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
        return cpu_to_le32(scp->SCp.dma_handle);
 }
 
@@ -9914,7 +9914,7 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
        asc_scsi_q->q2.target_ix =
            ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
        asc_scsi_q->q1.sense_addr = advansys_get_sense_buffer_dma(scp);
-       asc_scsi_q->q1.sense_len = sizeof(scp->sense_buffer);
+       asc_scsi_q->q1.sense_len = SCSI_SENSE_BUFFERSIZE;
 
        /*
         * If there are any outstanding requests for the current target,
@@ -10173,7 +10173,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
        scsiqp->target_lun = scp->device->lun;
 
        scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
-       scsiqp->sense_len = sizeof(scp->sense_buffer);
+       scsiqp->sense_len = SCSI_SENSE_BUFFERSIZE;
 
        /* Build ADV_SCSI_REQ_Q */
 
index 5b69a88d0e4c560e0a58f7c682675dd02c12937d..190568ebea3c12e15131bfb6868c212c9463caa0 100644 (file)
@@ -536,7 +536,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost, void *dev_id)
                   we will still have it in the cdb when we come back */
                if (ccb[mbo].tarstat == 2)
                        memcpy(SCtmp->sense_buffer, &ccb[mbo].cdb[ccb[mbo].cdblen],
-                              sizeof(SCtmp->sense_buffer));
+                              SCSI_SENSE_BUFFERSIZE);
 
 
                /* is there mail :-) */
@@ -609,7 +609,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
 #if 0
                /* scsi_request_sense() provides a buffer of size 256,
                   so there is no reason to expect equality */
-               if (bufflen != sizeof(SCpnt->sense_buffer))
+               if (bufflen != SCSI_SENSE_BUFFERSIZE)
                        printk(KERN_CRIT "aha1542: Wrong buffer length supplied "
                               "for request sense (%d)\n", bufflen);
 #endif
index f6722fd46008a2f451ceb645411e93f6b4115fae..be58a0b097c76752d0827ee097c4c198db09fe17 100644 (file)
@@ -286,7 +286,7 @@ static irqreturn_t aha1740_intr_handle(int irq, void *dev_id)
                           cdb when we come back */
                        if ( (adapstat & G2INTST_MASK) == G2INTST_CCBERROR ) {
                                memcpy(SCtmp->sense_buffer, ecbptr->sense, 
-                                      sizeof(SCtmp->sense_buffer));
+                                      SCSI_SENSE_BUFFERSIZE);
                                errstatus = aha1740_makecode(ecbptr->sense,ecbptr->status);
                        } else
                                errstatus = 0;
index 2d020405480c7755cae40a67dda23713971bbc40..0e4708fd43c8e00d861b80392c976683d43145fa 100644 (file)
@@ -1784,7 +1784,7 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd,
                        if (scb->flags & SCB_SENSE) {
                                sense_size = min(sizeof(struct scsi_sense_data)
                                               - ahd_get_sense_residual(scb),
-                                                (u_long)sizeof(cmd->sense_buffer));
+                                                (u_long)SCSI_SENSE_BUFFERSIZE);
                                sense_offset = 0;
                        } else {
                                /*
@@ -1795,11 +1795,11 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd,
                                    scb->sense_data;
                                sense_size = min_t(size_t,
                                                scsi_4btoul(siu->sense_length),
-                                               sizeof(cmd->sense_buffer));
+                                               SCSI_SENSE_BUFFERSIZE);
                                sense_offset = SIU_SENSE_OFFSET(siu);
                        }
 
-                       memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
+                       memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
                        memcpy(cmd->sense_buffer,
                               ahd_get_sense_buf(ahd, scb)
                               + sense_offset, sense_size);
index 390b0fc991c5930dcb8e42057f5aa1ba9ec6644a..e310e414067fc767ef0e8ede1a6864d90650ca6a 100644 (file)
@@ -1801,12 +1801,12 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
 
                        sense_size = min(sizeof(struct scsi_sense_data)
                                       - ahc_get_sense_residual(scb),
-                                        (u_long)sizeof(cmd->sense_buffer));
+                                        (u_long)SCSI_SENSE_BUFFERSIZE);
                        memcpy(cmd->sense_buffer,
                               ahc_get_sense_buf(ahc, scb), sense_size);
-                       if (sense_size < sizeof(cmd->sense_buffer))
+                       if (sense_size < SCSI_SENSE_BUFFERSIZE)
                                memset(&cmd->sense_buffer[sense_size], 0,
-                                      sizeof(cmd->sense_buffer) - sense_size);
+                                      SCSI_SENSE_BUFFERSIZE - sense_size);
                        cmd->result |= (DRIVER_SENSE << 24);
 #ifdef AHC_DEBUG
                        if (ahc_debug & AHC_SHOW_SENSE) {
index 2b402fafd009b1a6771c62b14aa50adaab66229e..bcb0b870320c166b56f2c08c6ee07113d6fa915d 100644 (file)
@@ -2696,7 +2696,7 @@ aic7xxx_done(struct aic7xxx_host *p, struct aic7xxx_scb *scb)
   {
     pci_unmap_single(p->pdev,
                      le32_to_cpu(scb->sg_list[0].address),
-                     sizeof(cmd->sense_buffer),
+                     SCSI_SENSE_BUFFERSIZE,
                      PCI_DMA_FROMDEVICE);
   }
   if (scb->flags & SCB_RECOVERY_SCB)
@@ -4267,13 +4267,13 @@ aic7xxx_handle_seqint(struct aic7xxx_host *p, unsigned char intstat)
                        sizeof(generic_sense));
 
                 scb->sense_cmd[1] = (cmd->device->lun << 5);
-                scb->sense_cmd[4] = sizeof(cmd->sense_buffer);
+                scb->sense_cmd[4] = SCSI_SENSE_BUFFERSIZE;
 
                 scb->sg_list[0].length = 
-                  cpu_to_le32(sizeof(cmd->sense_buffer));
+                  cpu_to_le32(SCSI_SENSE_BUFFERSIZE);
                scb->sg_list[0].address =
                         cpu_to_le32(pci_map_single(p->pdev, cmd->sense_buffer,
-                                                   sizeof(cmd->sense_buffer),
+                                                   SCSI_SENSE_BUFFERSIZE,
                                                    PCI_DMA_FROMDEVICE));
 
                 /*
@@ -4296,7 +4296,7 @@ aic7xxx_handle_seqint(struct aic7xxx_host *p, unsigned char intstat)
                 hscb->residual_data_count[2] = 0;
 
                 scb->sg_count = hscb->SG_segment_count = 1;
-                scb->sg_length = sizeof(cmd->sense_buffer);
+                scb->sg_length = SCSI_SENSE_BUFFERSIZE;
                 scb->tag_action = 0;
                 scb->flags |= SCB_SENSE;
                 /*
index d466a2dac1dbcba2d5e28d44260408bfa6979792..d80dba913a750c8e051b16ec28215348cb55ef41 100644 (file)
@@ -634,9 +634,9 @@ static void arcmsr_report_sense_info(struct CommandControlBlock *ccb)
        pcmd->result = DID_OK << 16;
        if (sensebuffer) {
                int sense_data_length =
-                       sizeof(struct SENSE_DATA) < sizeof(pcmd->sense_buffer)
-                       ? sizeof(struct SENSE_DATA) : sizeof(pcmd->sense_buffer);
-               memset(sensebuffer, 0, sizeof(pcmd->sense_buffer));
+                       sizeof(struct SENSE_DATA) < SCSI_SENSE_BUFFERSIZE
+                       ? sizeof(struct SENSE_DATA) : SCSI_SENSE_BUFFERSIZE;
+               memset(sensebuffer, 0, SCSI_SENSE_BUFFERSIZE);
                memcpy(sensebuffer, ccb->arcmsr_cdb.SenseData, sense_data_length);
                sensebuffer->ErrorCode = SCSI_SENSE_CURRENT_ERRORS;
                sensebuffer->Valid = 1;
index a9def6e1d30e6a5bd761a481b1fe522f924bd107..f93c73c0ba53d7081a187f17e5c17bf7224da77d 100644 (file)
@@ -1629,8 +1629,7 @@ static u8 start_scsi(struct AdapterCtlBlk* acb, struct DeviceCtlBlk* dcb,
                DC395x_write8(acb, TRM_S1040_SCSI_FIFO, (dcb->target_lun << 5));
                DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
                DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
-               DC395x_write8(acb, TRM_S1040_SCSI_FIFO,
-                             sizeof(srb->cmd->sense_buffer));
+               DC395x_write8(acb, TRM_S1040_SCSI_FIFO, SCSI_SENSE_BUFFERSIZE);
                DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
        } else {
                ptr = (u8 *)srb->cmd->cmnd;
@@ -1915,8 +1914,7 @@ static void command_phase1(struct AdapterCtlBlk *acb, struct ScsiReqBlk *srb,
                DC395x_write8(acb, TRM_S1040_SCSI_FIFO, (dcb->target_lun << 5));
                DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
                DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
-               DC395x_write8(acb, TRM_S1040_SCSI_FIFO,
-                             sizeof(srb->cmd->sense_buffer));
+               DC395x_write8(acb, TRM_S1040_SCSI_FIFO, SCSI_SENSE_BUFFERSIZE);
                DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
        }
        srb->state |= SRB_COMMAND;
@@ -3685,7 +3683,7 @@ static void request_sense(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
        srb->target_status = 0;
 
        /* KG: Can this prevent crap sense data ? */
-       memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
+       memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
 
        /* Save some data */
        srb->segment_x[DC395x_MAX_SG_LISTENTRY - 1].address =
@@ -3694,15 +3692,15 @@ static void request_sense(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
            srb->segment_x[0].length;
        srb->xferred = srb->total_xfer_length;
        /* srb->segment_x : a one entry of S/G list table */
-       srb->total_xfer_length = sizeof(cmd->sense_buffer);
-       srb->segment_x[0].length = sizeof(cmd->sense_buffer);
+       srb->total_xfer_length = SCSI_SENSE_BUFFERSIZE;
+       srb->segment_x[0].length = SCSI_SENSE_BUFFERSIZE;
        /* Map sense buffer */
        srb->segment_x[0].address =
            pci_map_single(acb->dev, cmd->sense_buffer,
-                          sizeof(cmd->sense_buffer), PCI_DMA_FROMDEVICE);
+                          SCSI_SENSE_BUFFERSIZE, PCI_DMA_FROMDEVICE);
        dprintkdbg(DBG_SG, "request_sense: map buffer %p->%08x(%05x)\n",
               cmd->sense_buffer, srb->segment_x[0].address,
-              sizeof(cmd->sense_buffer));
+              SCSI_SENSE_BUFFERSIZE);
        srb->sg_count = 1;
        srb->sg_index = 0;
 
index b31d1c95c9fbd4d1a16c04856e088a54411801d5..577b34c93a075ac3c0dc81733122817d2e4b0014 100644 (file)
@@ -2296,9 +2296,8 @@ static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd)
 
                // copy over the request sense data if it was a check
                // condition status
-               if(dev_status == 0x02 /*CHECK_CONDITION*/) {
-                       u32 len = sizeof(cmd->sense_buffer);
-                       len = (len > 40) ?  40 : len;
+               if (dev_status == 0x02 /*CHECK_CONDITION*/) {
+                       u32 len = min(SCSI_SENSE_BUFFERSIZE, 40);
                        // Copy over the sense data
                        memcpy_fromio(cmd->sense_buffer, (reply+28) , len);
                        if(cmd->sense_buffer[0] == 0x70 /* class 7 */ && 
index 7ead5210de968dfb0ece36e1d81058a018875d14..05163cefec12f7f2f806009de76da5d77767a0ed 100644 (file)
@@ -1623,9 +1623,9 @@ static void map_dma(unsigned int i, struct hostdata *ha)
        if (SCpnt->sense_buffer)
                cpp->sense_addr =
                    H2DEV(pci_map_single(ha->pdev, SCpnt->sense_buffer,
-                          sizeof SCpnt->sense_buffer, PCI_DMA_FROMDEVICE));
+                          SCSI_SENSE_BUFFERSIZE, PCI_DMA_FROMDEVICE));
 
-       cpp->sense_len = sizeof SCpnt->sense_buffer;
+       cpp->sense_len = SCSI_SENSE_BUFFERSIZE;
 
        count = scsi_dma_map(SCpnt);
        BUG_ON(count < 0);
index df1a76438e29855245efedc2c9dffba673af3f13..e7b2f3575ce99466c1ddf50991744205b4d0c0fa 100644 (file)
@@ -574,7 +574,7 @@ static void hptiop_finish_scsi_req(struct hptiop_hba *hba, u32 tag,
                        scsi_bufflen(scp) - le32_to_cpu(req->dataxfer_length));
                scp->result = SAM_STAT_CHECK_CONDITION;
                memcpy(&scp->sense_buffer, &req->sg_list,
-                               min_t(size_t, sizeof(scp->sense_buffer),
+                               min_t(size_t, SCSI_SENSE_BUFFERSIZE,
                                        le32_to_cpu(req->dataxfer_length)));
                break;
 
index b1b2295061139795219e4ee0f5442e608da3a09c..7505cca8e68e3d1825e06c9a977e948c3a0dacf2 100644 (file)
@@ -3433,13 +3433,11 @@ ips_map_status(ips_ha_t * ha, ips_scb_t * scb, ips_stat_t * sp)
                                            (IPS_DCDB_TABLE_TAPE *) & scb->dcdb;
                                        memcpy(scb->scsi_cmd->sense_buffer,
                                               tapeDCDB->sense_info,
-                                              sizeof (scb->scsi_cmd->
-                                                      sense_buffer));
+                                              SCSI_SENSE_BUFFERSIZE);
                                } else {
                                        memcpy(scb->scsi_cmd->sense_buffer,
                                               scb->dcdb.sense_info,
-                                              sizeof (scb->scsi_cmd->
-                                                      sense_buffer));
+                                              SCSI_SENSE_BUFFERSIZE);
                                }
                                device_error = 2;       /* check condition */
                        }
index 016c462bc771a80fddce05894445fc1cdb7dd384..c02771aa6c9b4d76d6abc52c509ec9c0327b83f3 100644 (file)
@@ -4963,7 +4963,8 @@ void ncr_complete (struct ncb *np, struct ccb *cp)
                **      Copy back sense data to caller's buffer.
                */
                memcpy(cmd->sense_buffer, cp->sense_buf,
-                      min(sizeof(cmd->sense_buffer), sizeof(cp->sense_buf)));
+                      min_t(size_t, SCSI_SENSE_BUFFERSIZE,
+                            sizeof(cp->sense_buf)));
 
                if (DEBUG_FLAGS & (DEBUG_RESULT|DEBUG_TINY)) {
                        u_char * p = (u_char*) & cmd->sense_buffer;
index 28864075609930af90875d2d17522be20899e239..c94906abfee353137b4483dbcfcc2346cc4aeab9 100644 (file)
@@ -528,7 +528,7 @@ __setup("qla1280=", qla1280_setup);
 #define        CMD_CDBLEN(Cmnd)        Cmnd->cmd_len
 #define        CMD_CDBP(Cmnd)          Cmnd->cmnd
 #define        CMD_SNSP(Cmnd)          Cmnd->sense_buffer
-#define        CMD_SNSLEN(Cmnd)        sizeof(Cmnd->sense_buffer)
+#define        CMD_SNSLEN(Cmnd)        SCSI_SENSE_BUFFERSIZE
 #define        CMD_RESULT(Cmnd)        Cmnd->result
 #define        CMD_HANDLE(Cmnd)        Cmnd->host_scribble
 #define CMD_REQUEST(Cmnd)      Cmnd->request->cmd
@@ -3715,7 +3715,7 @@ qla1280_status_entry(struct scsi_qla_host *ha, struct response *pkt,
                        } else
                                sense_sz = 0;
                        memset(cmd->sense_buffer + sense_sz, 0,
-                              sizeof(cmd->sense_buffer) - sense_sz);
+                              SCSI_SENSE_BUFFERSIZE - sense_sz);
 
                        dprintk(2, "qla1280_status_entry: Check "
                                "condition Sense data, b %i, t %i, "
index 798b7e87e2e14e6105afc921eead81d9c419a386..53cbaffbb78cd101a1965d5c6618eeb85995a277 100644 (file)
@@ -977,13 +977,13 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
                        break;
 
                /* Copy Sense Data into sense buffer. */
-               memset(cp->sense_buffer, 0, sizeof(cp->sense_buffer));
+               memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
 
                if (!(scsi_status & SS_SENSE_LEN_VALID))
                        break;
 
-               if (sense_len >= sizeof(cp->sense_buffer))
-                       sense_len = sizeof(cp->sense_buffer);
+               if (sense_len >= SCSI_SENSE_BUFFERSIZE)
+                       sense_len = SCSI_SENSE_BUFFERSIZE;
 
                CMD_ACTUAL_SNSLEN(cp) = sense_len;
                sp->request_sense_length = sense_len;
@@ -1061,13 +1061,13 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
                                break;
 
                        /* Copy Sense Data into sense buffer */
-                       memset(cp->sense_buffer, 0, sizeof(cp->sense_buffer));
+                       memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
 
                        if (!(scsi_status & SS_SENSE_LEN_VALID))
                                break;
 
-                       if (sense_len >= sizeof(cp->sense_buffer))
-                               sense_len = sizeof(cp->sense_buffer);
+                       if (sense_len >= SCSI_SENSE_BUFFERSIZE)
+                               sense_len = SCSI_SENSE_BUFFERSIZE;
 
                        CMD_ACTUAL_SNSLEN(cp) = sense_len;
                        sp->request_sense_length = sense_len;
index 4a154beb0d39ba90bf15e1b05b261fafe1bbec09..0f029d0d73150e17881cec0f98575134d22438e8 100644 (file)
@@ -123,15 +123,14 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha,
                        break;
 
                /* Copy Sense Data into sense buffer. */
-               memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
+               memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
 
                sensebytecnt = le16_to_cpu(sts_entry->senseDataByteCnt);
                if (sensebytecnt == 0)
                        break;
 
                memcpy(cmd->sense_buffer, sts_entry->senseData,
-                      min(sensebytecnt,
-                          (uint16_t) sizeof(cmd->sense_buffer)));
+                      min_t(uint16_t, sensebytecnt, SCSI_SENSE_BUFFERSIZE));
 
                DEBUG2(printk("scsi%ld:%d:%d:%d: %s: sense key = %x, "
                              "ASC/ASCQ = %02x/%02x\n", ha->host_no,
@@ -208,8 +207,7 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha,
                                break;
 
                        /* Copy Sense Data into sense buffer. */
-                       memset(cmd->sense_buffer, 0,
-                              sizeof(cmd->sense_buffer));
+                       memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
 
                        sensebytecnt =
                                le16_to_cpu(sts_entry->senseDataByteCnt);
@@ -217,8 +215,7 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha,
                                break;
 
                        memcpy(cmd->sense_buffer, sts_entry->senseData,
-                              min(sensebytecnt,
-                                  (uint16_t) sizeof(cmd->sense_buffer)));
+                              min_t(uint16_t, sensebytecnt, SCSI_SENSE_BUFFERSIZE));
 
                        DEBUG2(printk("scsi%ld:%d:%d:%d: %s: sense key = %x, "
                                      "ASC/ASCQ = %02x/%02x\n", ha->host_no,
index 5bc883182b979b50b9695943513e01dde76a741a..65455ab1f3b94ffb8aaa2ed5c59b7dafcddc628e 100644 (file)
@@ -1142,7 +1142,7 @@ static struct scsi_cmnd *qlogicpti_intr_handler(struct qlogicpti *qpti)
 
                if (sts->state_flags & SF_GOT_SENSE)
                        memcpy(Cmnd->sense_buffer, sts->req_sense_data,
-                              sizeof(Cmnd->sense_buffer));
+                              SCSI_SENSE_BUFFERSIZE);
 
                if (sts->hdr.entry_type == ENTRY_STATUS)
                        Cmnd->result =
index 169bc595648aa54c7b4d2862f67b8059e6fbdc74..547e85aa414f2b06a27a5b298e917c456e472f60 100644 (file)
@@ -625,7 +625,7 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses,
 
        if (sense_bytes) {
                scmd->request_bufflen = min_t(unsigned,
-                                      sizeof(scmd->sense_buffer), sense_bytes);
+                                      SCSI_SENSE_BUFFERSIZE, sense_bytes);
                sg_init_one(&ses->sense_sgl, scmd->sense_buffer,
                                                       scmd->request_bufflen);
                scmd->request_buffer = &ses->sense_sgl;
@@ -657,7 +657,7 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses,
         * Zero the sense buffer.  The scsi spec mandates that any
         * untransferred sense data should be interpreted as being zero.
         */
-       memset(scmd->sense_buffer, 0, sizeof(scmd->sense_buffer));
+       memset(scmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
 }
 EXPORT_SYMBOL(scsi_eh_prep_cmnd);
 
@@ -1820,7 +1820,7 @@ int scsi_command_normalize_sense(struct scsi_cmnd *cmd,
                                 struct scsi_sense_hdr *sshdr)
 {
        return scsi_normalize_sense(cmd->sense_buffer,
-                       sizeof(cmd->sense_buffer), sshdr);
+                       SCSI_SENSE_BUFFERSIZE, sshdr);
 }
 EXPORT_SYMBOL(scsi_command_normalize_sense);
 
index de601370c05b0a76ad5e8ddfedf4839259efb20c..4cf902efbdbf14aa26422226491463aa05a2f7cc 100644 (file)
@@ -441,7 +441,7 @@ static void scsi_init_cmd_errh(struct scsi_cmnd *cmd)
 {
        cmd->serial_number = 0;
        cmd->resid = 0;
-       memset(cmd->sense_buffer, 0, sizeof cmd->sense_buffer);
+       memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
        if (cmd->cmd_len == 0)
                cmd->cmd_len = COMMAND_SIZE(cmd->cmnd[0]);
 }
index dc9af8f8f2605ecaa8e312594de86855669d6af5..21e926dcdab0bfc73d6bc89d85f7c4d177d5c0ea 100644 (file)
@@ -207,10 +207,9 @@ void sym_set_cam_result_error(struct sym_hcb *np, struct sym_ccb *cp, int resid)
                        /*
                         *  Bounce back the sense data to user.
                         */
-                       memset(&cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
+                       memset(&cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
                        memcpy(cmd->sense_buffer, cp->sns_bbuf,
-                             min(sizeof(cmd->sense_buffer),
-                                 (size_t)SYM_SNS_BBUF_LEN));
+                              min(SCSI_SENSE_BUFFERSIZE, SYM_SNS_BBUF_LEN));
 #if 0
                        /*
                         *  If the device reports a UNIT ATTENTION condition 
index 44193049c4aed96de169fcea061f52536bf7e92f..5b04ddfed26c6162c0234963963598998d79a4b3 100644 (file)
@@ -444,7 +444,7 @@ static int dc390_pci_map (struct dc390_srb* pSRB)
 
        /* Map sense buffer */
        if (pSRB->SRBFlag & AUTO_REQSENSE) {
-               pSRB->pSegmentList      = dc390_sg_build_single(&pSRB->Segmentx, pcmd->sense_buffer, sizeof(pcmd->sense_buffer));
+               pSRB->pSegmentList      = dc390_sg_build_single(&pSRB->Segmentx, pcmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
                pSRB->SGcount           = pci_map_sg(pdev, pSRB->pSegmentList, 1,
                                                     DMA_FROM_DEVICE);
                cmdp->saved_dma_handle  = sg_dma_address(pSRB->pSegmentList);
@@ -599,7 +599,7 @@ dc390_StartSCSI( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_sr
            DC390_write8 (ScsiFifo, pDCB->TargetLUN << 5);
            DC390_write8 (ScsiFifo, 0);
            DC390_write8 (ScsiFifo, 0);
-           DC390_write8 (ScsiFifo, sizeof(scmd->sense_buffer));
+           DC390_write8 (ScsiFifo, SCSI_SENSE_BUFFERSIZE);
            DC390_write8 (ScsiFifo, 0);
            DEBUG1(printk (KERN_DEBUG "DC390: AutoReqSense !\n"));
          }
@@ -1389,7 +1389,7 @@ dc390_CommandPhase( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus
        DC390_write8 (ScsiFifo, pDCB->TargetLUN << 5);
        DC390_write8 (ScsiFifo, 0);
        DC390_write8 (ScsiFifo, 0);
-       DC390_write8 (ScsiFifo, sizeof(pSRB->pcmd->sense_buffer));
+       DC390_write8 (ScsiFifo, SCSI_SENSE_BUFFERSIZE);
        DC390_write8 (ScsiFifo, 0);
        DEBUG0(printk(KERN_DEBUG "DC390: AutoReqSense (CmndPhase)!\n"));
     }
index 7edd6ceb13b26ba8447f8d4b9096fdfde94ee07a..4bc5407f96958598f3a44ca56c8d387a6a86100e 100644 (file)
@@ -1121,9 +1121,9 @@ static void map_dma(unsigned int i, unsigned int j) {
 
    if (SCpnt->sense_buffer)
       cpp->sense_addr = H2DEV(pci_map_single(HD(j)->pdev, SCpnt->sense_buffer,
-                           sizeof SCpnt->sense_buffer, PCI_DMA_FROMDEVICE));
+                           SCSI_SENSE_BUFFERSIZE, PCI_DMA_FROMDEVICE));
 
-   cpp->sense_len = sizeof SCpnt->sense_buffer;
+   cpp->sense_len = SCSI_SENSE_BUFFERSIZE;
 
    if (scsi_bufflen(SCpnt)) {
           count = scsi_dma_map(SCpnt);
index 6d1f0edd7985632384c83d47793946f88c262875..1d3b02976d74328e78a99e9bfe7eed60d464d486 100644 (file)
@@ -741,7 +741,7 @@ static int ultrastor_queuecommand(struct scsi_cmnd *SCpnt,
     }
     my_mscp->command_link = 0;         /*???*/
     my_mscp->scsi_command_link_id = 0; /*???*/
-    my_mscp->length_of_sense_byte = sizeof SCpnt->sense_buffer;
+    my_mscp->length_of_sense_byte = SCSI_SENSE_BUFFERSIZE;
     my_mscp->length_of_scsi_cdbs = SCpnt->cmd_len;
     memcpy(my_mscp->scsi_cdbs, SCpnt->cmnd, my_mscp->length_of_scsi_cdbs);
     my_mscp->adapter_status = 0;