aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/aacraid/aachba.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/aacraid/aachba.c')
-rw-r--r--drivers/scsi/aacraid/aachba.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 31319d052102..fb8350e86d98 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -1607,13 +1607,14 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1607 cp[11] = 0; 1607 cp[11] = 0;
1608 cp[12] = 0; 1608 cp[12] = 0;
1609 aac_internal_transfer(scsicmd, cp, 0, 1609 aac_internal_transfer(scsicmd, cp, 0,
1610 min((unsigned int)scsicmd->cmnd[13], sizeof(cp))); 1610 min_t(size_t, scsicmd->cmnd[13], sizeof(cp)));
1611 if (sizeof(cp) < scsicmd->cmnd[13]) { 1611 if (sizeof(cp) < scsicmd->cmnd[13]) {
1612 unsigned int len, offset = sizeof(cp); 1612 unsigned int len, offset = sizeof(cp);
1613 1613
1614 memset(cp, 0, offset); 1614 memset(cp, 0, offset);
1615 do { 1615 do {
1616 len = min(scsicmd->cmnd[13]-offset, sizeof(cp)); 1616 len = min_t(size_t, scsicmd->cmnd[13] - offset,
1617 sizeof(cp));
1617 aac_internal_transfer(scsicmd, cp, offset, len); 1618 aac_internal_transfer(scsicmd, cp, offset, len);
1618 } while ((offset += len) < scsicmd->cmnd[13]); 1619 } while ((offset += len) < scsicmd->cmnd[13]);
1619 } 1620 }
@@ -2080,7 +2081,6 @@ static int aac_send_srb_fib(struct scsi_cmnd* scsicmd)
2080 return 0; 2081 return 0;
2081 } 2082 }
2082 2083
2083 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
2084 switch(scsicmd->sc_data_direction){ 2084 switch(scsicmd->sc_data_direction){
2085 case DMA_TO_DEVICE: 2085 case DMA_TO_DEVICE:
2086 flag = SRB_DataOut; 2086 flag = SRB_DataOut;
@@ -2198,8 +2198,6 @@ static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* psg)
2198 scsicmd->sc_data_direction); 2198 scsicmd->sc_data_direction);
2199 psg->count = cpu_to_le32(sg_count); 2199 psg->count = cpu_to_le32(sg_count);
2200 2200
2201 byte_count = 0;
2202
2203 for (i = 0; i < sg_count; i++) { 2201 for (i = 0; i < sg_count; i++) {
2204 psg->sg[i].addr = cpu_to_le32(sg_dma_address(sg)); 2202 psg->sg[i].addr = cpu_to_le32(sg_dma_address(sg));
2205 psg->sg[i].count = cpu_to_le32(sg_dma_len(sg)); 2203 psg->sg[i].count = cpu_to_le32(sg_dma_len(sg));
@@ -2255,18 +2253,17 @@ static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* p
2255 2253
2256 sg_count = pci_map_sg(dev->pdev, sg, scsicmd->use_sg, 2254 sg_count = pci_map_sg(dev->pdev, sg, scsicmd->use_sg,
2257 scsicmd->sc_data_direction); 2255 scsicmd->sc_data_direction);
2258 psg->count = cpu_to_le32(sg_count);
2259
2260 byte_count = 0;
2261 2256
2262 for (i = 0; i < sg_count; i++) { 2257 for (i = 0; i < sg_count; i++) {
2258 int count = sg_dma_len(sg);
2263 addr = sg_dma_address(sg); 2259 addr = sg_dma_address(sg);
2264 psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff); 2260 psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff);
2265 psg->sg[i].addr[1] = cpu_to_le32(addr>>32); 2261 psg->sg[i].addr[1] = cpu_to_le32(addr>>32);
2266 psg->sg[i].count = cpu_to_le32(sg_dma_len(sg)); 2262 psg->sg[i].count = cpu_to_le32(count);
2267 byte_count += sg_dma_len(sg); 2263 byte_count += count;
2268 sg++; 2264 sg++;
2269 } 2265 }
2266 psg->count = cpu_to_le32(sg_count);
2270 /* hba wants the size to be exact */ 2267 /* hba wants the size to be exact */
2271 if(byte_count > scsicmd->request_bufflen){ 2268 if(byte_count > scsicmd->request_bufflen){
2272 u32 temp = le32_to_cpu(psg->sg[i-1].count) - 2269 u32 temp = le32_to_cpu(psg->sg[i-1].count) -
@@ -2281,16 +2278,15 @@ static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* p
2281 } 2278 }
2282 } 2279 }
2283 else if(scsicmd->request_bufflen) { 2280 else if(scsicmd->request_bufflen) {
2284 u64 addr; 2281 scsicmd->SCp.dma_handle = pci_map_single(dev->pdev,
2285 addr = pci_map_single(dev->pdev,
2286 scsicmd->request_buffer, 2282 scsicmd->request_buffer,
2287 scsicmd->request_bufflen, 2283 scsicmd->request_bufflen,
2288 scsicmd->sc_data_direction); 2284 scsicmd->sc_data_direction);
2285 addr = scsicmd->SCp.dma_handle;
2289 psg->count = cpu_to_le32(1); 2286 psg->count = cpu_to_le32(1);
2290 psg->sg[0].addr[0] = cpu_to_le32(addr & 0xffffffff); 2287 psg->sg[0].addr[0] = cpu_to_le32(addr & 0xffffffff);
2291 psg->sg[0].addr[1] = cpu_to_le32(addr >> 32); 2288 psg->sg[0].addr[1] = cpu_to_le32(addr >> 32);
2292 psg->sg[0].count = cpu_to_le32(scsicmd->request_bufflen); 2289 psg->sg[0].count = cpu_to_le32(scsicmd->request_bufflen);
2293 scsicmd->SCp.dma_handle = addr;
2294 byte_count = scsicmd->request_bufflen; 2290 byte_count = scsicmd->request_bufflen;
2295 } 2291 }
2296 return byte_count; 2292 return byte_count;