aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/53c700.c11
-rw-r--r--drivers/scsi/BusLogic.c2
-rw-r--r--drivers/scsi/aacraid/aachba.c32
-rw-r--r--drivers/scsi/advansys.c14
-rw-r--r--drivers/scsi/aha1542.c4
-rw-r--r--drivers/scsi/aha1740.c2
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c6
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c6
-rw-r--r--drivers/scsi/aic7xxx_old.c10
-rw-r--r--drivers/scsi/arcmsr/arcmsr_hba.c6
-rw-r--r--drivers/scsi/dc395x.c16
-rw-r--r--drivers/scsi/dpt_i2o.c5
-rw-r--r--drivers/scsi/eata.c4
-rw-r--r--drivers/scsi/hptiop.c2
-rw-r--r--drivers/scsi/ips.c6
-rw-r--r--drivers/scsi/ncr53c8xx.c3
-rw-r--r--drivers/scsi/qla1280.c4
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c12
-rw-r--r--drivers/scsi/qla4xxx/ql4_isr.c11
-rw-r--r--drivers/scsi/qlogicpti.c2
-rw-r--r--drivers/scsi/scsi_error.c6
-rw-r--r--drivers/scsi/scsi_lib.c2
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c5
-rw-r--r--drivers/scsi/tmscsim.c6
-rw-r--r--drivers/scsi/u14-34f.c4
-rw-r--r--drivers/scsi/ultrastor.c2
26 files changed, 88 insertions, 95 deletions
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index 71ff3fbfce12..f4c4fe90240a 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -608,7 +608,8 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata,
608 scsi_print_sense("53c700", SCp); 608 scsi_print_sense("53c700", SCp);
609 609
610#endif 610#endif
611 dma_unmap_single(hostdata->dev, slot->dma_handle, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); 611 dma_unmap_single(hostdata->dev, slot->dma_handle,
612 SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
612 /* restore the old result if the request sense was 613 /* restore the old result if the request sense was
613 * successful */ 614 * successful */
614 if (result == 0) 615 if (result == 0)
@@ -1010,7 +1011,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
1010 cmnd[1] = (SCp->device->lun & 0x7) << 5; 1011 cmnd[1] = (SCp->device->lun & 0x7) << 5;
1011 cmnd[2] = 0; 1012 cmnd[2] = 0;
1012 cmnd[3] = 0; 1013 cmnd[3] = 0;
1013 cmnd[4] = sizeof(SCp->sense_buffer); 1014 cmnd[4] = SCSI_SENSE_BUFFERSIZE;
1014 cmnd[5] = 0; 1015 cmnd[5] = 0;
1015 /* Here's a quiet hack: the 1016 /* Here's a quiet hack: the
1016 * REQUEST_SENSE command is six bytes, 1017 * REQUEST_SENSE command is six bytes,
@@ -1024,14 +1025,14 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
1024 SCp->cmd_len = 6; /* command length for 1025 SCp->cmd_len = 6; /* command length for
1025 * REQUEST_SENSE */ 1026 * REQUEST_SENSE */
1026 slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE); 1027 slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE);
1027 slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); 1028 slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
1028 slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | sizeof(SCp->sense_buffer)); 1029 slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | SCSI_SENSE_BUFFERSIZE);
1029 slot->SG[0].pAddr = bS_to_host(slot->dma_handle); 1030 slot->SG[0].pAddr = bS_to_host(slot->dma_handle);
1030 slot->SG[1].ins = bS_to_host(SCRIPT_RETURN); 1031 slot->SG[1].ins = bS_to_host(SCRIPT_RETURN);
1031 slot->SG[1].pAddr = 0; 1032 slot->SG[1].pAddr = 0;
1032 slot->resume_offset = hostdata->pScript; 1033 slot->resume_offset = hostdata->pScript;
1033 dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG[0])*2, DMA_TO_DEVICE); 1034 dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG[0])*2, DMA_TO_DEVICE);
1034 dma_cache_sync(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); 1035 dma_cache_sync(hostdata->dev, SCp->sense_buffer, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
1035 1036
1036 /* queue the command for reissue */ 1037 /* queue the command for reissue */
1037 slot->state = NCR_700_SLOT_QUEUED; 1038 slot->state = NCR_700_SLOT_QUEUED;
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index 49e1ffa4b2ff..ead47c143ce0 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -2947,7 +2947,7 @@ static int BusLogic_QueueCommand(struct scsi_cmnd *Command, void (*CompletionRou
2947 } 2947 }
2948 } 2948 }
2949 memcpy(CCB->CDB, CDB, CDB_Length); 2949 memcpy(CCB->CDB, CDB, CDB_Length);
2950 CCB->SenseDataLength = sizeof(Command->sense_buffer); 2950 CCB->SenseDataLength = SCSI_SENSE_BUFFERSIZE;
2951 CCB->SenseDataPointer = pci_map_single(HostAdapter->PCI_Device, Command->sense_buffer, CCB->SenseDataLength, PCI_DMA_FROMDEVICE); 2951 CCB->SenseDataPointer = pci_map_single(HostAdapter->PCI_Device, Command->sense_buffer, CCB->SenseDataLength, PCI_DMA_FROMDEVICE);
2952 CCB->Command = Command; 2952 CCB->Command = Command;
2953 Command->scsi_done = CompletionRoutine; 2953 Command->scsi_done = CompletionRoutine;
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 62d95165d2a6..aadedbd63083 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -912,8 +912,8 @@ static int aac_bounds_32(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba)
912 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, 912 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
913 0, 0); 913 0, 0);
914 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data, 914 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
915 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(cmd->sense_buffer)) 915 (sizeof(dev->fsa_dev[cid].sense_data) > SCSI_SENSE_BUFFERSIZE)
916 ? sizeof(cmd->sense_buffer) 916 ? SCSI_SENSE_BUFFERSIZE
917 : sizeof(dev->fsa_dev[cid].sense_data)); 917 : sizeof(dev->fsa_dev[cid].sense_data));
918 cmd->scsi_done(cmd); 918 cmd->scsi_done(cmd);
919 return 1; 919 return 1;
@@ -1525,8 +1525,8 @@ static void io_callback(void *context, struct fib * fibptr)
1525 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, 1525 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
1526 0, 0); 1526 0, 0);
1527 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, 1527 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1528 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer)) 1528 (sizeof(dev->fsa_dev[cid].sense_data) > SCSI_SENSE_BUFFERSIZE)
1529 ? sizeof(scsicmd->sense_buffer) 1529 ? SCSI_SENSE_BUFFERSIZE
1530 : sizeof(dev->fsa_dev[cid].sense_data)); 1530 : sizeof(dev->fsa_dev[cid].sense_data));
1531 } 1531 }
1532 aac_fib_complete(fibptr); 1532 aac_fib_complete(fibptr);
@@ -1739,8 +1739,8 @@ static void synchronize_callback(void *context, struct fib *fibptr)
1739 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, 1739 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
1740 0, 0); 1740 0, 0);
1741 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data, 1741 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1742 min(sizeof(dev->fsa_dev[cid].sense_data), 1742 min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data),
1743 sizeof(cmd->sense_buffer))); 1743 SCSI_SENSE_BUFFERSIZE));
1744 } 1744 }
1745 1745
1746 aac_fib_complete(fibptr); 1746 aac_fib_complete(fibptr);
@@ -1949,8 +1949,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1949 SENCODE_INVALID_COMMAND, 1949 SENCODE_INVALID_COMMAND,
1950 ASENCODE_INVALID_COMMAND, 0, 0, 0, 0); 1950 ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
1951 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, 1951 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1952 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer)) 1952 (sizeof(dev->fsa_dev[cid].sense_data) > SCSI_SENSE_BUFFERSIZE)
1953 ? sizeof(scsicmd->sense_buffer) 1953 ? SCSI_SENSE_BUFFERSIZE
1954 : sizeof(dev->fsa_dev[cid].sense_data)); 1954 : sizeof(dev->fsa_dev[cid].sense_data));
1955 scsicmd->scsi_done(scsicmd); 1955 scsicmd->scsi_done(scsicmd);
1956 return 0; 1956 return 0;
@@ -2002,8 +2002,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
2002 memcpy(scsicmd->sense_buffer, 2002 memcpy(scsicmd->sense_buffer,
2003 &dev->fsa_dev[cid].sense_data, 2003 &dev->fsa_dev[cid].sense_data,
2004 (sizeof(dev->fsa_dev[cid].sense_data) > 2004 (sizeof(dev->fsa_dev[cid].sense_data) >
2005 sizeof(scsicmd->sense_buffer)) 2005 SCSI_SENSE_BUFFERSIZE)
2006 ? sizeof(scsicmd->sense_buffer) 2006 ? SCSI_SENSE_BUFFERSIZE
2007 : sizeof(dev->fsa_dev[cid].sense_data)); 2007 : sizeof(dev->fsa_dev[cid].sense_data));
2008 } 2008 }
2009 scsicmd->scsi_done(scsicmd); 2009 scsicmd->scsi_done(scsicmd);
@@ -2259,8 +2259,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
2259 ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND, 2259 ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND,
2260 ASENCODE_INVALID_COMMAND, 0, 0, 0, 0); 2260 ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
2261 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, 2261 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
2262 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer)) 2262 (sizeof(dev->fsa_dev[cid].sense_data) > SCSI_SENSE_BUFFERSIZE)
2263 ? sizeof(scsicmd->sense_buffer) 2263 ? SCSI_SENSE_BUFFERSIZE
2264 : sizeof(dev->fsa_dev[cid].sense_data)); 2264 : sizeof(dev->fsa_dev[cid].sense_data));
2265 scsicmd->scsi_done(scsicmd); 2265 scsicmd->scsi_done(scsicmd);
2266 return 0; 2266 return 0;
@@ -2422,8 +2422,8 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
2422 int len; 2422 int len;
2423 printk(KERN_WARNING "aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply->status)); 2423 printk(KERN_WARNING "aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply->status));
2424 len = (le32_to_cpu(srbreply->sense_data_size) > 2424 len = (le32_to_cpu(srbreply->sense_data_size) >
2425 sizeof(scsicmd->sense_buffer)) ? 2425 SCSI_SENSE_BUFFERSIZE) ?
2426 sizeof(scsicmd->sense_buffer) : 2426 SCSI_SENSE_BUFFERSIZE :
2427 le32_to_cpu(srbreply->sense_data_size); 2427 le32_to_cpu(srbreply->sense_data_size);
2428 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; 2428 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
2429 memcpy(scsicmd->sense_buffer, srbreply->sense_data, len); 2429 memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);
@@ -2528,8 +2528,8 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
2528 int len; 2528 int len;
2529 scsicmd->result |= SAM_STAT_CHECK_CONDITION; 2529 scsicmd->result |= SAM_STAT_CHECK_CONDITION;
2530 len = (le32_to_cpu(srbreply->sense_data_size) > 2530 len = (le32_to_cpu(srbreply->sense_data_size) >
2531 sizeof(scsicmd->sense_buffer)) ? 2531 SCSI_SENSE_BUFFERSIZE) ?
2532 sizeof(scsicmd->sense_buffer) : 2532 SCSI_SENSE_BUFFERSIZE :
2533 le32_to_cpu(srbreply->sense_data_size); 2533 le32_to_cpu(srbreply->sense_data_size);
2534#ifdef AAC_DETAILED_STATUS_INFO 2534#ifdef AAC_DETAILED_STATUS_INFO
2535 printk(KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n", 2535 printk(KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n",
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 9dd3952516c5..492702ba6463 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -8233,7 +8233,7 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
8233 if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) { 8233 if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
8234 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n"); 8234 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
8235 ASC_DBG_PRT_SENSE(2, scp->sense_buffer, 8235 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
8236 sizeof(scp->sense_buffer)); 8236 SCSI_SENSE_BUFFERSIZE);
8237 /* 8237 /*
8238 * Note: The 'status_byte()' macro used by 8238 * Note: The 'status_byte()' macro used by
8239 * target drivers defined in scsi.h shifts the 8239 * 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)
9136 BUG_ON(asc_dvc_varp != &boardp->dvc_var.asc_dvc_var); 9136 BUG_ON(asc_dvc_varp != &boardp->dvc_var.asc_dvc_var);
9137 9137
9138 dma_unmap_single(boardp->dev, scp->SCp.dma_handle, 9138 dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
9139 sizeof(scp->sense_buffer), DMA_FROM_DEVICE); 9139 SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
9140 /* 9140 /*
9141 * 'qdonep' contains the command's ending status. 9141 * 'qdonep' contains the command's ending status.
9142 */ 9142 */
@@ -9166,7 +9166,7 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
9166 if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) { 9166 if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
9167 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n"); 9167 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
9168 ASC_DBG_PRT_SENSE(2, scp->sense_buffer, 9168 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
9169 sizeof(scp->sense_buffer)); 9169 SCSI_SENSE_BUFFERSIZE);
9170 /* 9170 /*
9171 * Note: The 'status_byte()' macro used by 9171 * Note: The 'status_byte()' macro used by
9172 * target drivers defined in scsi.h shifts the 9172 * target drivers defined in scsi.h shifts the
@@ -9881,9 +9881,9 @@ static __le32 advansys_get_sense_buffer_dma(struct scsi_cmnd *scp)
9881{ 9881{
9882 struct asc_board *board = shost_priv(scp->device->host); 9882 struct asc_board *board = shost_priv(scp->device->host);
9883 scp->SCp.dma_handle = dma_map_single(board->dev, scp->sense_buffer, 9883 scp->SCp.dma_handle = dma_map_single(board->dev, scp->sense_buffer,
9884 sizeof(scp->sense_buffer), DMA_FROM_DEVICE); 9884 SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
9885 dma_cache_sync(board->dev, scp->sense_buffer, 9885 dma_cache_sync(board->dev, scp->sense_buffer,
9886 sizeof(scp->sense_buffer), DMA_FROM_DEVICE); 9886 SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
9887 return cpu_to_le32(scp->SCp.dma_handle); 9887 return cpu_to_le32(scp->SCp.dma_handle);
9888} 9888}
9889 9889
@@ -9914,7 +9914,7 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
9914 asc_scsi_q->q2.target_ix = 9914 asc_scsi_q->q2.target_ix =
9915 ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun); 9915 ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
9916 asc_scsi_q->q1.sense_addr = advansys_get_sense_buffer_dma(scp); 9916 asc_scsi_q->q1.sense_addr = advansys_get_sense_buffer_dma(scp);
9917 asc_scsi_q->q1.sense_len = sizeof(scp->sense_buffer); 9917 asc_scsi_q->q1.sense_len = SCSI_SENSE_BUFFERSIZE;
9918 9918
9919 /* 9919 /*
9920 * If there are any outstanding requests for the current target, 9920 * 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,
10173 scsiqp->target_lun = scp->device->lun; 10173 scsiqp->target_lun = scp->device->lun;
10174 10174
10175 scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0])); 10175 scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
10176 scsiqp->sense_len = sizeof(scp->sense_buffer); 10176 scsiqp->sense_len = SCSI_SENSE_BUFFERSIZE;
10177 10177
10178 /* Build ADV_SCSI_REQ_Q */ 10178 /* Build ADV_SCSI_REQ_Q */
10179 10179
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index 5b69a88d0e4c..190568ebea3c 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -536,7 +536,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost, void *dev_id)
536 we will still have it in the cdb when we come back */ 536 we will still have it in the cdb when we come back */
537 if (ccb[mbo].tarstat == 2) 537 if (ccb[mbo].tarstat == 2)
538 memcpy(SCtmp->sense_buffer, &ccb[mbo].cdb[ccb[mbo].cdblen], 538 memcpy(SCtmp->sense_buffer, &ccb[mbo].cdb[ccb[mbo].cdblen],
539 sizeof(SCtmp->sense_buffer)); 539 SCSI_SENSE_BUFFERSIZE);
540 540
541 541
542 /* is there mail :-) */ 542 /* is there mail :-) */
@@ -609,7 +609,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
609#if 0 609#if 0
610 /* scsi_request_sense() provides a buffer of size 256, 610 /* scsi_request_sense() provides a buffer of size 256,
611 so there is no reason to expect equality */ 611 so there is no reason to expect equality */
612 if (bufflen != sizeof(SCpnt->sense_buffer)) 612 if (bufflen != SCSI_SENSE_BUFFERSIZE)
613 printk(KERN_CRIT "aha1542: Wrong buffer length supplied " 613 printk(KERN_CRIT "aha1542: Wrong buffer length supplied "
614 "for request sense (%d)\n", bufflen); 614 "for request sense (%d)\n", bufflen);
615#endif 615#endif
diff --git a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c
index f6722fd46008..be58a0b097c7 100644
--- a/drivers/scsi/aha1740.c
+++ b/drivers/scsi/aha1740.c
@@ -286,7 +286,7 @@ static irqreturn_t aha1740_intr_handle(int irq, void *dev_id)
286 cdb when we come back */ 286 cdb when we come back */
287 if ( (adapstat & G2INTST_MASK) == G2INTST_CCBERROR ) { 287 if ( (adapstat & G2INTST_MASK) == G2INTST_CCBERROR ) {
288 memcpy(SCtmp->sense_buffer, ecbptr->sense, 288 memcpy(SCtmp->sense_buffer, ecbptr->sense,
289 sizeof(SCtmp->sense_buffer)); 289 SCSI_SENSE_BUFFERSIZE);
290 errstatus = aha1740_makecode(ecbptr->sense,ecbptr->status); 290 errstatus = aha1740_makecode(ecbptr->sense,ecbptr->status);
291 } else 291 } else
292 errstatus = 0; 292 errstatus = 0;
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 2d020405480c..0e4708fd43c8 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -1784,7 +1784,7 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd,
1784 if (scb->flags & SCB_SENSE) { 1784 if (scb->flags & SCB_SENSE) {
1785 sense_size = min(sizeof(struct scsi_sense_data) 1785 sense_size = min(sizeof(struct scsi_sense_data)
1786 - ahd_get_sense_residual(scb), 1786 - ahd_get_sense_residual(scb),
1787 (u_long)sizeof(cmd->sense_buffer)); 1787 (u_long)SCSI_SENSE_BUFFERSIZE);
1788 sense_offset = 0; 1788 sense_offset = 0;
1789 } else { 1789 } else {
1790 /* 1790 /*
@@ -1795,11 +1795,11 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd,
1795 scb->sense_data; 1795 scb->sense_data;
1796 sense_size = min_t(size_t, 1796 sense_size = min_t(size_t,
1797 scsi_4btoul(siu->sense_length), 1797 scsi_4btoul(siu->sense_length),
1798 sizeof(cmd->sense_buffer)); 1798 SCSI_SENSE_BUFFERSIZE);
1799 sense_offset = SIU_SENSE_OFFSET(siu); 1799 sense_offset = SIU_SENSE_OFFSET(siu);
1800 } 1800 }
1801 1801
1802 memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer)); 1802 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
1803 memcpy(cmd->sense_buffer, 1803 memcpy(cmd->sense_buffer,
1804 ahd_get_sense_buf(ahd, scb) 1804 ahd_get_sense_buf(ahd, scb)
1805 + sense_offset, sense_size); 1805 + sense_offset, sense_size);
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index 390b0fc991c5..e310e414067f 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -1801,12 +1801,12 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
1801 1801
1802 sense_size = min(sizeof(struct scsi_sense_data) 1802 sense_size = min(sizeof(struct scsi_sense_data)
1803 - ahc_get_sense_residual(scb), 1803 - ahc_get_sense_residual(scb),
1804 (u_long)sizeof(cmd->sense_buffer)); 1804 (u_long)SCSI_SENSE_BUFFERSIZE);
1805 memcpy(cmd->sense_buffer, 1805 memcpy(cmd->sense_buffer,
1806 ahc_get_sense_buf(ahc, scb), sense_size); 1806 ahc_get_sense_buf(ahc, scb), sense_size);
1807 if (sense_size < sizeof(cmd->sense_buffer)) 1807 if (sense_size < SCSI_SENSE_BUFFERSIZE)
1808 memset(&cmd->sense_buffer[sense_size], 0, 1808 memset(&cmd->sense_buffer[sense_size], 0,
1809 sizeof(cmd->sense_buffer) - sense_size); 1809 SCSI_SENSE_BUFFERSIZE - sense_size);
1810 cmd->result |= (DRIVER_SENSE << 24); 1810 cmd->result |= (DRIVER_SENSE << 24);
1811#ifdef AHC_DEBUG 1811#ifdef AHC_DEBUG
1812 if (ahc_debug & AHC_SHOW_SENSE) { 1812 if (ahc_debug & AHC_SHOW_SENSE) {
diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
index 2b402fafd009..bcb0b870320c 100644
--- a/drivers/scsi/aic7xxx_old.c
+++ b/drivers/scsi/aic7xxx_old.c
@@ -2696,7 +2696,7 @@ aic7xxx_done(struct aic7xxx_host *p, struct aic7xxx_scb *scb)
2696 { 2696 {
2697 pci_unmap_single(p->pdev, 2697 pci_unmap_single(p->pdev,
2698 le32_to_cpu(scb->sg_list[0].address), 2698 le32_to_cpu(scb->sg_list[0].address),
2699 sizeof(cmd->sense_buffer), 2699 SCSI_SENSE_BUFFERSIZE,
2700 PCI_DMA_FROMDEVICE); 2700 PCI_DMA_FROMDEVICE);
2701 } 2701 }
2702 if (scb->flags & SCB_RECOVERY_SCB) 2702 if (scb->flags & SCB_RECOVERY_SCB)
@@ -4267,13 +4267,13 @@ aic7xxx_handle_seqint(struct aic7xxx_host *p, unsigned char intstat)
4267 sizeof(generic_sense)); 4267 sizeof(generic_sense));
4268 4268
4269 scb->sense_cmd[1] = (cmd->device->lun << 5); 4269 scb->sense_cmd[1] = (cmd->device->lun << 5);
4270 scb->sense_cmd[4] = sizeof(cmd->sense_buffer); 4270 scb->sense_cmd[4] = SCSI_SENSE_BUFFERSIZE;
4271 4271
4272 scb->sg_list[0].length = 4272 scb->sg_list[0].length =
4273 cpu_to_le32(sizeof(cmd->sense_buffer)); 4273 cpu_to_le32(SCSI_SENSE_BUFFERSIZE);
4274 scb->sg_list[0].address = 4274 scb->sg_list[0].address =
4275 cpu_to_le32(pci_map_single(p->pdev, cmd->sense_buffer, 4275 cpu_to_le32(pci_map_single(p->pdev, cmd->sense_buffer,
4276 sizeof(cmd->sense_buffer), 4276 SCSI_SENSE_BUFFERSIZE,
4277 PCI_DMA_FROMDEVICE)); 4277 PCI_DMA_FROMDEVICE));
4278 4278
4279 /* 4279 /*
@@ -4296,7 +4296,7 @@ aic7xxx_handle_seqint(struct aic7xxx_host *p, unsigned char intstat)
4296 hscb->residual_data_count[2] = 0; 4296 hscb->residual_data_count[2] = 0;
4297 4297
4298 scb->sg_count = hscb->SG_segment_count = 1; 4298 scb->sg_count = hscb->SG_segment_count = 1;
4299 scb->sg_length = sizeof(cmd->sense_buffer); 4299 scb->sg_length = SCSI_SENSE_BUFFERSIZE;
4300 scb->tag_action = 0; 4300 scb->tag_action = 0;
4301 scb->flags |= SCB_SENSE; 4301 scb->flags |= SCB_SENSE;
4302 /* 4302 /*
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index d466a2dac1db..d80dba913a75 100644
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -634,9 +634,9 @@ static void arcmsr_report_sense_info(struct CommandControlBlock *ccb)
634 pcmd->result = DID_OK << 16; 634 pcmd->result = DID_OK << 16;
635 if (sensebuffer) { 635 if (sensebuffer) {
636 int sense_data_length = 636 int sense_data_length =
637 sizeof(struct SENSE_DATA) < sizeof(pcmd->sense_buffer) 637 sizeof(struct SENSE_DATA) < SCSI_SENSE_BUFFERSIZE
638 ? sizeof(struct SENSE_DATA) : sizeof(pcmd->sense_buffer); 638 ? sizeof(struct SENSE_DATA) : SCSI_SENSE_BUFFERSIZE;
639 memset(sensebuffer, 0, sizeof(pcmd->sense_buffer)); 639 memset(sensebuffer, 0, SCSI_SENSE_BUFFERSIZE);
640 memcpy(sensebuffer, ccb->arcmsr_cdb.SenseData, sense_data_length); 640 memcpy(sensebuffer, ccb->arcmsr_cdb.SenseData, sense_data_length);
641 sensebuffer->ErrorCode = SCSI_SENSE_CURRENT_ERRORS; 641 sensebuffer->ErrorCode = SCSI_SENSE_CURRENT_ERRORS;
642 sensebuffer->Valid = 1; 642 sensebuffer->Valid = 1;
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index a9def6e1d30e..f93c73c0ba53 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -1629,8 +1629,7 @@ static u8 start_scsi(struct AdapterCtlBlk* acb, struct DeviceCtlBlk* dcb,
1629 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, (dcb->target_lun << 5)); 1629 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, (dcb->target_lun << 5));
1630 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0); 1630 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
1631 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0); 1631 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
1632 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 1632 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, SCSI_SENSE_BUFFERSIZE);
1633 sizeof(srb->cmd->sense_buffer));
1634 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0); 1633 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
1635 } else { 1634 } else {
1636 ptr = (u8 *)srb->cmd->cmnd; 1635 ptr = (u8 *)srb->cmd->cmnd;
@@ -1915,8 +1914,7 @@ static void command_phase1(struct AdapterCtlBlk *acb, struct ScsiReqBlk *srb,
1915 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, (dcb->target_lun << 5)); 1914 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, (dcb->target_lun << 5));
1916 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0); 1915 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
1917 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0); 1916 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
1918 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 1917 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, SCSI_SENSE_BUFFERSIZE);
1919 sizeof(srb->cmd->sense_buffer));
1920 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0); 1918 DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 0);
1921 } 1919 }
1922 srb->state |= SRB_COMMAND; 1920 srb->state |= SRB_COMMAND;
@@ -3685,7 +3683,7 @@ static void request_sense(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
3685 srb->target_status = 0; 3683 srb->target_status = 0;
3686 3684
3687 /* KG: Can this prevent crap sense data ? */ 3685 /* KG: Can this prevent crap sense data ? */
3688 memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer)); 3686 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
3689 3687
3690 /* Save some data */ 3688 /* Save some data */
3691 srb->segment_x[DC395x_MAX_SG_LISTENTRY - 1].address = 3689 srb->segment_x[DC395x_MAX_SG_LISTENTRY - 1].address =
@@ -3694,15 +3692,15 @@ static void request_sense(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
3694 srb->segment_x[0].length; 3692 srb->segment_x[0].length;
3695 srb->xferred = srb->total_xfer_length; 3693 srb->xferred = srb->total_xfer_length;
3696 /* srb->segment_x : a one entry of S/G list table */ 3694 /* srb->segment_x : a one entry of S/G list table */
3697 srb->total_xfer_length = sizeof(cmd->sense_buffer); 3695 srb->total_xfer_length = SCSI_SENSE_BUFFERSIZE;
3698 srb->segment_x[0].length = sizeof(cmd->sense_buffer); 3696 srb->segment_x[0].length = SCSI_SENSE_BUFFERSIZE;
3699 /* Map sense buffer */ 3697 /* Map sense buffer */
3700 srb->segment_x[0].address = 3698 srb->segment_x[0].address =
3701 pci_map_single(acb->dev, cmd->sense_buffer, 3699 pci_map_single(acb->dev, cmd->sense_buffer,
3702 sizeof(cmd->sense_buffer), PCI_DMA_FROMDEVICE); 3700 SCSI_SENSE_BUFFERSIZE, PCI_DMA_FROMDEVICE);
3703 dprintkdbg(DBG_SG, "request_sense: map buffer %p->%08x(%05x)\n", 3701 dprintkdbg(DBG_SG, "request_sense: map buffer %p->%08x(%05x)\n",
3704 cmd->sense_buffer, srb->segment_x[0].address, 3702 cmd->sense_buffer, srb->segment_x[0].address,
3705 sizeof(cmd->sense_buffer)); 3703 SCSI_SENSE_BUFFERSIZE);
3706 srb->sg_count = 1; 3704 srb->sg_count = 1;
3707 srb->sg_index = 0; 3705 srb->sg_index = 0;
3708 3706
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index b31d1c95c9fb..577b34c93a07 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -2296,9 +2296,8 @@ static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd)
2296 2296
2297 // copy over the request sense data if it was a check 2297 // copy over the request sense data if it was a check
2298 // condition status 2298 // condition status
2299 if(dev_status == 0x02 /*CHECK_CONDITION*/) { 2299 if (dev_status == 0x02 /*CHECK_CONDITION*/) {
2300 u32 len = sizeof(cmd->sense_buffer); 2300 u32 len = min(SCSI_SENSE_BUFFERSIZE, 40);
2301 len = (len > 40) ? 40 : len;
2302 // Copy over the sense data 2301 // Copy over the sense data
2303 memcpy_fromio(cmd->sense_buffer, (reply+28) , len); 2302 memcpy_fromio(cmd->sense_buffer, (reply+28) , len);
2304 if(cmd->sense_buffer[0] == 0x70 /* class 7 */ && 2303 if(cmd->sense_buffer[0] == 0x70 /* class 7 */ &&
diff --git a/drivers/scsi/eata.c b/drivers/scsi/eata.c
index 7ead5210de96..05163cefec12 100644
--- a/drivers/scsi/eata.c
+++ b/drivers/scsi/eata.c
@@ -1623,9 +1623,9 @@ static void map_dma(unsigned int i, struct hostdata *ha)
1623 if (SCpnt->sense_buffer) 1623 if (SCpnt->sense_buffer)
1624 cpp->sense_addr = 1624 cpp->sense_addr =
1625 H2DEV(pci_map_single(ha->pdev, SCpnt->sense_buffer, 1625 H2DEV(pci_map_single(ha->pdev, SCpnt->sense_buffer,
1626 sizeof SCpnt->sense_buffer, PCI_DMA_FROMDEVICE)); 1626 SCSI_SENSE_BUFFERSIZE, PCI_DMA_FROMDEVICE));
1627 1627
1628 cpp->sense_len = sizeof SCpnt->sense_buffer; 1628 cpp->sense_len = SCSI_SENSE_BUFFERSIZE;
1629 1629
1630 count = scsi_dma_map(SCpnt); 1630 count = scsi_dma_map(SCpnt);
1631 BUG_ON(count < 0); 1631 BUG_ON(count < 0);
diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index df1a76438e29..e7b2f3575ce9 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -574,7 +574,7 @@ static void hptiop_finish_scsi_req(struct hptiop_hba *hba, u32 tag,
574 scsi_bufflen(scp) - le32_to_cpu(req->dataxfer_length)); 574 scsi_bufflen(scp) - le32_to_cpu(req->dataxfer_length));
575 scp->result = SAM_STAT_CHECK_CONDITION; 575 scp->result = SAM_STAT_CHECK_CONDITION;
576 memcpy(&scp->sense_buffer, &req->sg_list, 576 memcpy(&scp->sense_buffer, &req->sg_list,
577 min_t(size_t, sizeof(scp->sense_buffer), 577 min_t(size_t, SCSI_SENSE_BUFFERSIZE,
578 le32_to_cpu(req->dataxfer_length))); 578 le32_to_cpu(req->dataxfer_length)));
579 break; 579 break;
580 580
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index b1b229506113..7505cca8e68e 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -3433,13 +3433,11 @@ ips_map_status(ips_ha_t * ha, ips_scb_t * scb, ips_stat_t * sp)
3433 (IPS_DCDB_TABLE_TAPE *) & scb->dcdb; 3433 (IPS_DCDB_TABLE_TAPE *) & scb->dcdb;
3434 memcpy(scb->scsi_cmd->sense_buffer, 3434 memcpy(scb->scsi_cmd->sense_buffer,
3435 tapeDCDB->sense_info, 3435 tapeDCDB->sense_info,
3436 sizeof (scb->scsi_cmd-> 3436 SCSI_SENSE_BUFFERSIZE);
3437 sense_buffer));
3438 } else { 3437 } else {
3439 memcpy(scb->scsi_cmd->sense_buffer, 3438 memcpy(scb->scsi_cmd->sense_buffer,
3440 scb->dcdb.sense_info, 3439 scb->dcdb.sense_info,
3441 sizeof (scb->scsi_cmd-> 3440 SCSI_SENSE_BUFFERSIZE);
3442 sense_buffer));
3443 } 3441 }
3444 device_error = 2; /* check condition */ 3442 device_error = 2; /* check condition */
3445 } 3443 }
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
index 016c462bc771..c02771aa6c9b 100644
--- a/drivers/scsi/ncr53c8xx.c
+++ b/drivers/scsi/ncr53c8xx.c
@@ -4963,7 +4963,8 @@ void ncr_complete (struct ncb *np, struct ccb *cp)
4963 ** Copy back sense data to caller's buffer. 4963 ** Copy back sense data to caller's buffer.
4964 */ 4964 */
4965 memcpy(cmd->sense_buffer, cp->sense_buf, 4965 memcpy(cmd->sense_buffer, cp->sense_buf,
4966 min(sizeof(cmd->sense_buffer), sizeof(cp->sense_buf))); 4966 min_t(size_t, SCSI_SENSE_BUFFERSIZE,
4967 sizeof(cp->sense_buf)));
4967 4968
4968 if (DEBUG_FLAGS & (DEBUG_RESULT|DEBUG_TINY)) { 4969 if (DEBUG_FLAGS & (DEBUG_RESULT|DEBUG_TINY)) {
4969 u_char * p = (u_char*) & cmd->sense_buffer; 4970 u_char * p = (u_char*) & cmd->sense_buffer;
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 288640756099..c94906abfee3 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -528,7 +528,7 @@ __setup("qla1280=", qla1280_setup);
528#define CMD_CDBLEN(Cmnd) Cmnd->cmd_len 528#define CMD_CDBLEN(Cmnd) Cmnd->cmd_len
529#define CMD_CDBP(Cmnd) Cmnd->cmnd 529#define CMD_CDBP(Cmnd) Cmnd->cmnd
530#define CMD_SNSP(Cmnd) Cmnd->sense_buffer 530#define CMD_SNSP(Cmnd) Cmnd->sense_buffer
531#define CMD_SNSLEN(Cmnd) sizeof(Cmnd->sense_buffer) 531#define CMD_SNSLEN(Cmnd) SCSI_SENSE_BUFFERSIZE
532#define CMD_RESULT(Cmnd) Cmnd->result 532#define CMD_RESULT(Cmnd) Cmnd->result
533#define CMD_HANDLE(Cmnd) Cmnd->host_scribble 533#define CMD_HANDLE(Cmnd) Cmnd->host_scribble
534#define CMD_REQUEST(Cmnd) Cmnd->request->cmd 534#define CMD_REQUEST(Cmnd) Cmnd->request->cmd
@@ -3715,7 +3715,7 @@ qla1280_status_entry(struct scsi_qla_host *ha, struct response *pkt,
3715 } else 3715 } else
3716 sense_sz = 0; 3716 sense_sz = 0;
3717 memset(cmd->sense_buffer + sense_sz, 0, 3717 memset(cmd->sense_buffer + sense_sz, 0,
3718 sizeof(cmd->sense_buffer) - sense_sz); 3718 SCSI_SENSE_BUFFERSIZE - sense_sz);
3719 3719
3720 dprintk(2, "qla1280_status_entry: Check " 3720 dprintk(2, "qla1280_status_entry: Check "
3721 "condition Sense data, b %i, t %i, " 3721 "condition Sense data, b %i, t %i, "
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 798b7e87e2e1..53cbaffbb78c 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -977,13 +977,13 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
977 break; 977 break;
978 978
979 /* Copy Sense Data into sense buffer. */ 979 /* Copy Sense Data into sense buffer. */
980 memset(cp->sense_buffer, 0, sizeof(cp->sense_buffer)); 980 memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
981 981
982 if (!(scsi_status & SS_SENSE_LEN_VALID)) 982 if (!(scsi_status & SS_SENSE_LEN_VALID))
983 break; 983 break;
984 984
985 if (sense_len >= sizeof(cp->sense_buffer)) 985 if (sense_len >= SCSI_SENSE_BUFFERSIZE)
986 sense_len = sizeof(cp->sense_buffer); 986 sense_len = SCSI_SENSE_BUFFERSIZE;
987 987
988 CMD_ACTUAL_SNSLEN(cp) = sense_len; 988 CMD_ACTUAL_SNSLEN(cp) = sense_len;
989 sp->request_sense_length = sense_len; 989 sp->request_sense_length = sense_len;
@@ -1061,13 +1061,13 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
1061 break; 1061 break;
1062 1062
1063 /* Copy Sense Data into sense buffer */ 1063 /* Copy Sense Data into sense buffer */
1064 memset(cp->sense_buffer, 0, sizeof(cp->sense_buffer)); 1064 memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
1065 1065
1066 if (!(scsi_status & SS_SENSE_LEN_VALID)) 1066 if (!(scsi_status & SS_SENSE_LEN_VALID))
1067 break; 1067 break;
1068 1068
1069 if (sense_len >= sizeof(cp->sense_buffer)) 1069 if (sense_len >= SCSI_SENSE_BUFFERSIZE)
1070 sense_len = sizeof(cp->sense_buffer); 1070 sense_len = SCSI_SENSE_BUFFERSIZE;
1071 1071
1072 CMD_ACTUAL_SNSLEN(cp) = sense_len; 1072 CMD_ACTUAL_SNSLEN(cp) = sense_len;
1073 sp->request_sense_length = sense_len; 1073 sp->request_sense_length = sense_len;
diff --git a/drivers/scsi/qla4xxx/ql4_isr.c b/drivers/scsi/qla4xxx/ql4_isr.c
index 4a154beb0d39..0f029d0d7315 100644
--- a/drivers/scsi/qla4xxx/ql4_isr.c
+++ b/drivers/scsi/qla4xxx/ql4_isr.c
@@ -123,15 +123,14 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha,
123 break; 123 break;
124 124
125 /* Copy Sense Data into sense buffer. */ 125 /* Copy Sense Data into sense buffer. */
126 memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer)); 126 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
127 127
128 sensebytecnt = le16_to_cpu(sts_entry->senseDataByteCnt); 128 sensebytecnt = le16_to_cpu(sts_entry->senseDataByteCnt);
129 if (sensebytecnt == 0) 129 if (sensebytecnt == 0)
130 break; 130 break;
131 131
132 memcpy(cmd->sense_buffer, sts_entry->senseData, 132 memcpy(cmd->sense_buffer, sts_entry->senseData,
133 min(sensebytecnt, 133 min_t(uint16_t, sensebytecnt, SCSI_SENSE_BUFFERSIZE));
134 (uint16_t) sizeof(cmd->sense_buffer)));
135 134
136 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: sense key = %x, " 135 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: sense key = %x, "
137 "ASC/ASCQ = %02x/%02x\n", ha->host_no, 136 "ASC/ASCQ = %02x/%02x\n", ha->host_no,
@@ -208,8 +207,7 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha,
208 break; 207 break;
209 208
210 /* Copy Sense Data into sense buffer. */ 209 /* Copy Sense Data into sense buffer. */
211 memset(cmd->sense_buffer, 0, 210 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
212 sizeof(cmd->sense_buffer));
213 211
214 sensebytecnt = 212 sensebytecnt =
215 le16_to_cpu(sts_entry->senseDataByteCnt); 213 le16_to_cpu(sts_entry->senseDataByteCnt);
@@ -217,8 +215,7 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha,
217 break; 215 break;
218 216
219 memcpy(cmd->sense_buffer, sts_entry->senseData, 217 memcpy(cmd->sense_buffer, sts_entry->senseData,
220 min(sensebytecnt, 218 min_t(uint16_t, sensebytecnt, SCSI_SENSE_BUFFERSIZE));
221 (uint16_t) sizeof(cmd->sense_buffer)));
222 219
223 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: sense key = %x, " 220 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: sense key = %x, "
224 "ASC/ASCQ = %02x/%02x\n", ha->host_no, 221 "ASC/ASCQ = %02x/%02x\n", ha->host_no,
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index 5bc883182b97..65455ab1f3b9 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -1142,7 +1142,7 @@ static struct scsi_cmnd *qlogicpti_intr_handler(struct qlogicpti *qpti)
1142 1142
1143 if (sts->state_flags & SF_GOT_SENSE) 1143 if (sts->state_flags & SF_GOT_SENSE)
1144 memcpy(Cmnd->sense_buffer, sts->req_sense_data, 1144 memcpy(Cmnd->sense_buffer, sts->req_sense_data,
1145 sizeof(Cmnd->sense_buffer)); 1145 SCSI_SENSE_BUFFERSIZE);
1146 1146
1147 if (sts->hdr.entry_type == ENTRY_STATUS) 1147 if (sts->hdr.entry_type == ENTRY_STATUS)
1148 Cmnd->result = 1148 Cmnd->result =
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 169bc595648a..547e85aa414f 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -625,7 +625,7 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses,
625 625
626 if (sense_bytes) { 626 if (sense_bytes) {
627 scmd->request_bufflen = min_t(unsigned, 627 scmd->request_bufflen = min_t(unsigned,
628 sizeof(scmd->sense_buffer), sense_bytes); 628 SCSI_SENSE_BUFFERSIZE, sense_bytes);
629 sg_init_one(&ses->sense_sgl, scmd->sense_buffer, 629 sg_init_one(&ses->sense_sgl, scmd->sense_buffer,
630 scmd->request_bufflen); 630 scmd->request_bufflen);
631 scmd->request_buffer = &ses->sense_sgl; 631 scmd->request_buffer = &ses->sense_sgl;
@@ -657,7 +657,7 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses,
657 * Zero the sense buffer. The scsi spec mandates that any 657 * Zero the sense buffer. The scsi spec mandates that any
658 * untransferred sense data should be interpreted as being zero. 658 * untransferred sense data should be interpreted as being zero.
659 */ 659 */
660 memset(scmd->sense_buffer, 0, sizeof(scmd->sense_buffer)); 660 memset(scmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
661} 661}
662EXPORT_SYMBOL(scsi_eh_prep_cmnd); 662EXPORT_SYMBOL(scsi_eh_prep_cmnd);
663 663
@@ -1820,7 +1820,7 @@ int scsi_command_normalize_sense(struct scsi_cmnd *cmd,
1820 struct scsi_sense_hdr *sshdr) 1820 struct scsi_sense_hdr *sshdr)
1821{ 1821{
1822 return scsi_normalize_sense(cmd->sense_buffer, 1822 return scsi_normalize_sense(cmd->sense_buffer,
1823 sizeof(cmd->sense_buffer), sshdr); 1823 SCSI_SENSE_BUFFERSIZE, sshdr);
1824} 1824}
1825EXPORT_SYMBOL(scsi_command_normalize_sense); 1825EXPORT_SYMBOL(scsi_command_normalize_sense);
1826 1826
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index de601370c05b..4cf902efbdbf 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -441,7 +441,7 @@ static void scsi_init_cmd_errh(struct scsi_cmnd *cmd)
441{ 441{
442 cmd->serial_number = 0; 442 cmd->serial_number = 0;
443 cmd->resid = 0; 443 cmd->resid = 0;
444 memset(cmd->sense_buffer, 0, sizeof cmd->sense_buffer); 444 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
445 if (cmd->cmd_len == 0) 445 if (cmd->cmd_len == 0)
446 cmd->cmd_len = COMMAND_SIZE(cmd->cmnd[0]); 446 cmd->cmd_len = COMMAND_SIZE(cmd->cmnd[0]);
447} 447}
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index dc9af8f8f260..21e926dcdab0 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -207,10 +207,9 @@ void sym_set_cam_result_error(struct sym_hcb *np, struct sym_ccb *cp, int resid)
207 /* 207 /*
208 * Bounce back the sense data to user. 208 * Bounce back the sense data to user.
209 */ 209 */
210 memset(&cmd->sense_buffer, 0, sizeof(cmd->sense_buffer)); 210 memset(&cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
211 memcpy(cmd->sense_buffer, cp->sns_bbuf, 211 memcpy(cmd->sense_buffer, cp->sns_bbuf,
212 min(sizeof(cmd->sense_buffer), 212 min(SCSI_SENSE_BUFFERSIZE, SYM_SNS_BBUF_LEN));
213 (size_t)SYM_SNS_BBUF_LEN));
214#if 0 213#if 0
215 /* 214 /*
216 * If the device reports a UNIT ATTENTION condition 215 * If the device reports a UNIT ATTENTION condition
diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
index 44193049c4ae..5b04ddfed26c 100644
--- a/drivers/scsi/tmscsim.c
+++ b/drivers/scsi/tmscsim.c
@@ -444,7 +444,7 @@ static int dc390_pci_map (struct dc390_srb* pSRB)
444 444
445 /* Map sense buffer */ 445 /* Map sense buffer */
446 if (pSRB->SRBFlag & AUTO_REQSENSE) { 446 if (pSRB->SRBFlag & AUTO_REQSENSE) {
447 pSRB->pSegmentList = dc390_sg_build_single(&pSRB->Segmentx, pcmd->sense_buffer, sizeof(pcmd->sense_buffer)); 447 pSRB->pSegmentList = dc390_sg_build_single(&pSRB->Segmentx, pcmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
448 pSRB->SGcount = pci_map_sg(pdev, pSRB->pSegmentList, 1, 448 pSRB->SGcount = pci_map_sg(pdev, pSRB->pSegmentList, 1,
449 DMA_FROM_DEVICE); 449 DMA_FROM_DEVICE);
450 cmdp->saved_dma_handle = sg_dma_address(pSRB->pSegmentList); 450 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
599 DC390_write8 (ScsiFifo, pDCB->TargetLUN << 5); 599 DC390_write8 (ScsiFifo, pDCB->TargetLUN << 5);
600 DC390_write8 (ScsiFifo, 0); 600 DC390_write8 (ScsiFifo, 0);
601 DC390_write8 (ScsiFifo, 0); 601 DC390_write8 (ScsiFifo, 0);
602 DC390_write8 (ScsiFifo, sizeof(scmd->sense_buffer)); 602 DC390_write8 (ScsiFifo, SCSI_SENSE_BUFFERSIZE);
603 DC390_write8 (ScsiFifo, 0); 603 DC390_write8 (ScsiFifo, 0);
604 DEBUG1(printk (KERN_DEBUG "DC390: AutoReqSense !\n")); 604 DEBUG1(printk (KERN_DEBUG "DC390: AutoReqSense !\n"));
605 } 605 }
@@ -1389,7 +1389,7 @@ dc390_CommandPhase( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus
1389 DC390_write8 (ScsiFifo, pDCB->TargetLUN << 5); 1389 DC390_write8 (ScsiFifo, pDCB->TargetLUN << 5);
1390 DC390_write8 (ScsiFifo, 0); 1390 DC390_write8 (ScsiFifo, 0);
1391 DC390_write8 (ScsiFifo, 0); 1391 DC390_write8 (ScsiFifo, 0);
1392 DC390_write8 (ScsiFifo, sizeof(pSRB->pcmd->sense_buffer)); 1392 DC390_write8 (ScsiFifo, SCSI_SENSE_BUFFERSIZE);
1393 DC390_write8 (ScsiFifo, 0); 1393 DC390_write8 (ScsiFifo, 0);
1394 DEBUG0(printk(KERN_DEBUG "DC390: AutoReqSense (CmndPhase)!\n")); 1394 DEBUG0(printk(KERN_DEBUG "DC390: AutoReqSense (CmndPhase)!\n"));
1395 } 1395 }
diff --git a/drivers/scsi/u14-34f.c b/drivers/scsi/u14-34f.c
index 7edd6ceb13b2..4bc5407f9695 100644
--- a/drivers/scsi/u14-34f.c
+++ b/drivers/scsi/u14-34f.c
@@ -1121,9 +1121,9 @@ static void map_dma(unsigned int i, unsigned int j) {
1121 1121
1122 if (SCpnt->sense_buffer) 1122 if (SCpnt->sense_buffer)
1123 cpp->sense_addr = H2DEV(pci_map_single(HD(j)->pdev, SCpnt->sense_buffer, 1123 cpp->sense_addr = H2DEV(pci_map_single(HD(j)->pdev, SCpnt->sense_buffer,
1124 sizeof SCpnt->sense_buffer, PCI_DMA_FROMDEVICE)); 1124 SCSI_SENSE_BUFFERSIZE, PCI_DMA_FROMDEVICE));
1125 1125
1126 cpp->sense_len = sizeof SCpnt->sense_buffer; 1126 cpp->sense_len = SCSI_SENSE_BUFFERSIZE;
1127 1127
1128 if (scsi_bufflen(SCpnt)) { 1128 if (scsi_bufflen(SCpnt)) {
1129 count = scsi_dma_map(SCpnt); 1129 count = scsi_dma_map(SCpnt);
diff --git a/drivers/scsi/ultrastor.c b/drivers/scsi/ultrastor.c
index 6d1f0edd7985..1d3b02976d74 100644
--- a/drivers/scsi/ultrastor.c
+++ b/drivers/scsi/ultrastor.c
@@ -741,7 +741,7 @@ static int ultrastor_queuecommand(struct scsi_cmnd *SCpnt,
741 } 741 }
742 my_mscp->command_link = 0; /*???*/ 742 my_mscp->command_link = 0; /*???*/
743 my_mscp->scsi_command_link_id = 0; /*???*/ 743 my_mscp->scsi_command_link_id = 0; /*???*/
744 my_mscp->length_of_sense_byte = sizeof SCpnt->sense_buffer; 744 my_mscp->length_of_sense_byte = SCSI_SENSE_BUFFERSIZE;
745 my_mscp->length_of_scsi_cdbs = SCpnt->cmd_len; 745 my_mscp->length_of_scsi_cdbs = SCpnt->cmd_len;
746 memcpy(my_mscp->scsi_cdbs, SCpnt->cmnd, my_mscp->length_of_scsi_cdbs); 746 memcpy(my_mscp->scsi_cdbs, SCpnt->cmnd, my_mscp->length_of_scsi_cdbs);
747 my_mscp->adapter_status = 0; 747 my_mscp->adapter_status = 0;