diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2007-05-14 06:24:58 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2007-05-26 20:19:04 -0400 |
commit | fea97f9ab26a17c29eadc102c04b88776d6262d4 (patch) | |
tree | c8a315f0a569d57d649504f4a2bacbd28e2b7920 /drivers | |
parent | d17867135639bec1bce5b38d29e6fa4cfea050ea (diff) |
[SCSI] u14-34f: 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.
Jens Axboe <jens.axboe@oracle.com> did the for_each_sg cleanup.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/u14-34f.c | 60 |
1 files changed, 27 insertions, 33 deletions
diff --git a/drivers/scsi/u14-34f.c b/drivers/scsi/u14-34f.c index 3de08a15de40..9e8232a1f169 100644 --- a/drivers/scsi/u14-34f.c +++ b/drivers/scsi/u14-34f.c | |||
@@ -1111,7 +1111,7 @@ static int u14_34f_detect(struct scsi_host_template *tpnt) { | |||
1111 | static void map_dma(unsigned int i, unsigned int j) { | 1111 | static void map_dma(unsigned int i, unsigned int j) { |
1112 | unsigned int data_len = 0; | 1112 | unsigned int data_len = 0; |
1113 | unsigned int k, count, pci_dir; | 1113 | unsigned int k, count, pci_dir; |
1114 | struct scatterlist *sgpnt; | 1114 | struct scatterlist *sg; |
1115 | struct mscp *cpp; | 1115 | struct mscp *cpp; |
1116 | struct scsi_cmnd *SCpnt; | 1116 | struct scsi_cmnd *SCpnt; |
1117 | 1117 | ||
@@ -1124,33 +1124,28 @@ static void map_dma(unsigned int i, unsigned int j) { | |||
1124 | 1124 | ||
1125 | cpp->sense_len = sizeof SCpnt->sense_buffer; | 1125 | cpp->sense_len = sizeof SCpnt->sense_buffer; |
1126 | 1126 | ||
1127 | if (!SCpnt->use_sg) { | 1127 | if (scsi_bufflen(SCpnt)) { |
1128 | 1128 | count = scsi_dma_map(SCpnt); | |
1129 | /* If we get here with PCI_DMA_NONE, pci_map_single triggers a BUG() */ | 1129 | BUG_ON(count < 0); |
1130 | if (!SCpnt->request_bufflen) pci_dir = PCI_DMA_BIDIRECTIONAL; | 1130 | |
1131 | 1131 | scsi_for_each_sg(SCpnt, sg, count, k) { | |
1132 | if (SCpnt->request_buffer) | 1132 | cpp->sglist[k].address = H2DEV(sg_dma_address(sg)); |
1133 | cpp->data_address = H2DEV(pci_map_single(HD(j)->pdev, | 1133 | cpp->sglist[k].num_bytes = H2DEV(sg_dma_len(sg)); |
1134 | SCpnt->request_buffer, SCpnt->request_bufflen, pci_dir)); | 1134 | data_len += sg->length; |
1135 | 1135 | } | |
1136 | cpp->data_len = H2DEV(SCpnt->request_bufflen); | 1136 | |
1137 | return; | 1137 | cpp->sg = TRUE; |
1138 | } | 1138 | cpp->use_sg = scsi_sg_count(SCpnt); |
1139 | 1139 | cpp->data_address = | |
1140 | sgpnt = (struct scatterlist *) SCpnt->request_buffer; | 1140 | H2DEV(pci_map_single(HD(j)->pdev, cpp->sglist, |
1141 | count = pci_map_sg(HD(j)->pdev, sgpnt, SCpnt->use_sg, pci_dir); | 1141 | cpp->use_sg * sizeof(struct sg_list), |
1142 | 1142 | pci_dir)); | |
1143 | for (k = 0; k < count; k++) { | 1143 | cpp->data_len = H2DEV(data_len); |
1144 | cpp->sglist[k].address = H2DEV(sg_dma_address(&sgpnt[k])); | 1144 | |
1145 | cpp->sglist[k].num_bytes = H2DEV(sg_dma_len(&sgpnt[k])); | 1145 | } else { |
1146 | data_len += sgpnt[k].length; | 1146 | pci_dir = PCI_DMA_BIDIRECTIONAL; |
1147 | } | 1147 | cpp->data_len = H2DEV(scsi_bufflen(SCpnt)); |
1148 | 1148 | } | |
1149 | cpp->sg = TRUE; | ||
1150 | cpp->use_sg = SCpnt->use_sg; | ||
1151 | cpp->data_address = H2DEV(pci_map_single(HD(j)->pdev, cpp->sglist, | ||
1152 | SCpnt->use_sg * sizeof(struct sg_list), pci_dir)); | ||
1153 | cpp->data_len = H2DEV(data_len); | ||
1154 | } | 1149 | } |
1155 | 1150 | ||
1156 | static void unmap_dma(unsigned int i, unsigned int j) { | 1151 | static void unmap_dma(unsigned int i, unsigned int j) { |
@@ -1165,8 +1160,7 @@ static void unmap_dma(unsigned int i, unsigned int j) { | |||
1165 | pci_unmap_single(HD(j)->pdev, DEV2H(cpp->sense_addr), | 1160 | pci_unmap_single(HD(j)->pdev, DEV2H(cpp->sense_addr), |
1166 | DEV2H(cpp->sense_len), PCI_DMA_FROMDEVICE); | 1161 | DEV2H(cpp->sense_len), PCI_DMA_FROMDEVICE); |
1167 | 1162 | ||
1168 | if (SCpnt->use_sg) | 1163 | scsi_dma_unmap(SCpnt); |
1169 | pci_unmap_sg(HD(j)->pdev, SCpnt->request_buffer, SCpnt->use_sg, pci_dir); | ||
1170 | 1164 | ||
1171 | if (!DEV2H(cpp->data_len)) pci_dir = PCI_DMA_BIDIRECTIONAL; | 1165 | if (!DEV2H(cpp->data_len)) pci_dir = PCI_DMA_BIDIRECTIONAL; |
1172 | 1166 | ||
@@ -1187,9 +1181,9 @@ static void sync_dma(unsigned int i, unsigned int j) { | |||
1187 | pci_dma_sync_single_for_cpu(HD(j)->pdev, DEV2H(cpp->sense_addr), | 1181 | pci_dma_sync_single_for_cpu(HD(j)->pdev, DEV2H(cpp->sense_addr), |
1188 | DEV2H(cpp->sense_len), PCI_DMA_FROMDEVICE); | 1182 | DEV2H(cpp->sense_len), PCI_DMA_FROMDEVICE); |
1189 | 1183 | ||
1190 | if (SCpnt->use_sg) | 1184 | if (scsi_sg_count(SCpnt)) |
1191 | pci_dma_sync_sg_for_cpu(HD(j)->pdev, SCpnt->request_buffer, | 1185 | pci_dma_sync_sg_for_cpu(HD(j)->pdev, scsi_sglist(SCpnt), |
1192 | SCpnt->use_sg, pci_dir); | 1186 | scsi_sg_count(SCpnt), pci_dir); |
1193 | 1187 | ||
1194 | if (!DEV2H(cpp->data_len)) pci_dir = PCI_DMA_BIDIRECTIONAL; | 1188 | if (!DEV2H(cpp->data_len)) pci_dir = PCI_DMA_BIDIRECTIONAL; |
1195 | 1189 | ||