aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/BusLogic.c
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2007-05-14 02:43:56 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2007-05-26 20:21:37 -0400
commitddc914c741c1374dbb5fa288b5e283060c2a8488 (patch)
tree36123d8cbd49c350c4b618ed5faac696f97fc587 /drivers/scsi/BusLogic.c
parentbc1ebfba1a3a27122462fd342d11216e3faea53f (diff)
[SCSI] BusLogic: convert to use the data buffer accessors
- remove the unnecessary map_single path. - convert to use the new accessors for the sg lists and the parameters. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/BusLogic.c')
-rw-r--r--drivers/scsi/BusLogic.c51
1 files changed, 21 insertions, 30 deletions
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index 96f4cab07614..9b206176f717 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -304,18 +304,10 @@ static struct BusLogic_CCB *BusLogic_AllocateCCB(struct BusLogic_HostAdapter
304static void BusLogic_DeallocateCCB(struct BusLogic_CCB *CCB) 304static void BusLogic_DeallocateCCB(struct BusLogic_CCB *CCB)
305{ 305{
306 struct BusLogic_HostAdapter *HostAdapter = CCB->HostAdapter; 306 struct BusLogic_HostAdapter *HostAdapter = CCB->HostAdapter;
307 struct scsi_cmnd *cmd = CCB->Command;
308 307
309 if (cmd->use_sg != 0) { 308 scsi_dma_unmap(CCB->Command);
310 pci_unmap_sg(HostAdapter->PCI_Device,
311 (struct scatterlist *)cmd->request_buffer,
312 cmd->use_sg, cmd->sc_data_direction);
313 } else if (cmd->request_bufflen != 0) {
314 pci_unmap_single(HostAdapter->PCI_Device, CCB->DataPointer,
315 CCB->DataLength, cmd->sc_data_direction);
316 }
317 pci_unmap_single(HostAdapter->PCI_Device, CCB->SenseDataPointer, 309 pci_unmap_single(HostAdapter->PCI_Device, CCB->SenseDataPointer,
318 CCB->SenseDataLength, PCI_DMA_FROMDEVICE); 310 CCB->SenseDataLength, PCI_DMA_FROMDEVICE);
319 311
320 CCB->Command = NULL; 312 CCB->Command = NULL;
321 CCB->Status = BusLogic_CCB_Free; 313 CCB->Status = BusLogic_CCB_Free;
@@ -2648,7 +2640,8 @@ static void BusLogic_ProcessCompletedCCBs(struct BusLogic_HostAdapter *HostAdapt
2648 */ 2640 */
2649 if (CCB->CDB[0] == INQUIRY && CCB->CDB[1] == 0 && CCB->HostAdapterStatus == BusLogic_CommandCompletedNormally) { 2641 if (CCB->CDB[0] == INQUIRY && CCB->CDB[1] == 0 && CCB->HostAdapterStatus == BusLogic_CommandCompletedNormally) {
2650 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[CCB->TargetID]; 2642 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[CCB->TargetID];
2651 struct SCSI_Inquiry *InquiryResult = (struct SCSI_Inquiry *) Command->request_buffer; 2643 struct SCSI_Inquiry *InquiryResult =
2644 (struct SCSI_Inquiry *) scsi_sglist(Command);
2652 TargetFlags->TargetExists = true; 2645 TargetFlags->TargetExists = true;
2653 TargetFlags->TaggedQueuingSupported = InquiryResult->CmdQue; 2646 TargetFlags->TaggedQueuingSupported = InquiryResult->CmdQue;
2654 TargetFlags->WideTransfersSupported = InquiryResult->WBus16; 2647 TargetFlags->WideTransfersSupported = InquiryResult->WBus16;
@@ -2819,9 +2812,8 @@ static int BusLogic_QueueCommand(struct scsi_cmnd *Command, void (*CompletionRou
2819 int CDB_Length = Command->cmd_len; 2812 int CDB_Length = Command->cmd_len;
2820 int TargetID = Command->device->id; 2813 int TargetID = Command->device->id;
2821 int LogicalUnit = Command->device->lun; 2814 int LogicalUnit = Command->device->lun;
2822 void *BufferPointer = Command->request_buffer; 2815 int BufferLength = scsi_bufflen(Command);
2823 int BufferLength = Command->request_bufflen; 2816 int Count;
2824 int SegmentCount = Command->use_sg;
2825 struct BusLogic_CCB *CCB; 2817 struct BusLogic_CCB *CCB;
2826 /* 2818 /*
2827 SCSI REQUEST_SENSE commands will be executed automatically by the Host 2819 SCSI REQUEST_SENSE commands will be executed automatically by the Host
@@ -2851,36 +2843,35 @@ static int BusLogic_QueueCommand(struct scsi_cmnd *Command, void (*CompletionRou
2851 return 0; 2843 return 0;
2852 } 2844 }
2853 } 2845 }
2846
2854 /* 2847 /*
2855 Initialize the fields in the BusLogic Command Control Block (CCB). 2848 Initialize the fields in the BusLogic Command Control Block (CCB).
2856 */ 2849 */
2857 if (SegmentCount == 0 && BufferLength != 0) { 2850 Count = scsi_dma_map(Command);
2858 CCB->Opcode = BusLogic_InitiatorCCB; 2851 BUG_ON(Count < 0);
2859 CCB->DataLength = BufferLength; 2852 if (Count) {
2860 CCB->DataPointer = pci_map_single(HostAdapter->PCI_Device, 2853 struct scatterlist *sg;
2861 BufferPointer, BufferLength, 2854 int i;
2862 Command->sc_data_direction); 2855
2863 } else if (SegmentCount != 0) {
2864 struct scatterlist *ScatterList = (struct scatterlist *) BufferPointer;
2865 int Segment, Count;
2866
2867 Count = pci_map_sg(HostAdapter->PCI_Device, ScatterList, SegmentCount,
2868 Command->sc_data_direction);
2869 CCB->Opcode = BusLogic_InitiatorCCB_ScatterGather; 2856 CCB->Opcode = BusLogic_InitiatorCCB_ScatterGather;
2870 CCB->DataLength = Count * sizeof(struct BusLogic_ScatterGatherSegment); 2857 CCB->DataLength = Count * sizeof(struct BusLogic_ScatterGatherSegment);
2871 if (BusLogic_MultiMasterHostAdapterP(HostAdapter)) 2858 if (BusLogic_MultiMasterHostAdapterP(HostAdapter))
2872 CCB->DataPointer = (unsigned int) CCB->DMA_Handle + ((unsigned long) &CCB->ScatterGatherList - (unsigned long) CCB); 2859 CCB->DataPointer = (unsigned int) CCB->DMA_Handle + ((unsigned long) &CCB->ScatterGatherList - (unsigned long) CCB);
2873 else 2860 else
2874 CCB->DataPointer = Virtual_to_32Bit_Virtual(CCB->ScatterGatherList); 2861 CCB->DataPointer = Virtual_to_32Bit_Virtual(CCB->ScatterGatherList);
2875 for (Segment = 0; Segment < Count; Segment++) { 2862
2876 CCB->ScatterGatherList[Segment].SegmentByteCount = sg_dma_len(ScatterList + Segment); 2863 scsi_for_each_sg(Command, sg, Count, i) {
2877 CCB->ScatterGatherList[Segment].SegmentDataPointer = sg_dma_address(ScatterList + Segment); 2864 CCB->ScatterGatherList[i].SegmentByteCount =
2865 sg_dma_len(sg);
2866 CCB->ScatterGatherList[i].SegmentDataPointer =
2867 sg_dma_address(sg);
2878 } 2868 }
2879 } else { 2869 } else if (!Count) {
2880 CCB->Opcode = BusLogic_InitiatorCCB; 2870 CCB->Opcode = BusLogic_InitiatorCCB;
2881 CCB->DataLength = BufferLength; 2871 CCB->DataLength = BufferLength;
2882 CCB->DataPointer = 0; 2872 CCB->DataPointer = 0;
2883 } 2873 }
2874
2884 switch (CDB[0]) { 2875 switch (CDB[0]) {
2885 case READ_6: 2876 case READ_6:
2886 case READ_10: 2877 case READ_10: