diff options
-rw-r--r-- | drivers/scsi/eata.c | 48 |
1 files changed, 14 insertions, 34 deletions
diff --git a/drivers/scsi/eata.c b/drivers/scsi/eata.c index 2d38025861a5..a83e9f150b97 100644 --- a/drivers/scsi/eata.c +++ b/drivers/scsi/eata.c | |||
@@ -1609,8 +1609,9 @@ static int eata2x_detect(struct scsi_host_template *tpnt) | |||
1609 | 1609 | ||
1610 | static void map_dma(unsigned int i, struct hostdata *ha) | 1610 | static void map_dma(unsigned int i, struct hostdata *ha) |
1611 | { | 1611 | { |
1612 | unsigned int k, count, pci_dir; | 1612 | unsigned int k, pci_dir; |
1613 | struct scatterlist *sgpnt; | 1613 | int count; |
1614 | struct scatterlist *sg; | ||
1614 | struct mscp *cpp; | 1615 | struct mscp *cpp; |
1615 | struct scsi_cmnd *SCpnt; | 1616 | struct scsi_cmnd *SCpnt; |
1616 | 1617 | ||
@@ -1625,38 +1626,19 @@ static void map_dma(unsigned int i, struct hostdata *ha) | |||
1625 | 1626 | ||
1626 | cpp->sense_len = sizeof SCpnt->sense_buffer; | 1627 | cpp->sense_len = sizeof SCpnt->sense_buffer; |
1627 | 1628 | ||
1628 | if (!SCpnt->use_sg) { | 1629 | count = scsi_dma_map(SCpnt); |
1629 | 1630 | BUG_ON(count < 0); | |
1630 | /* If we get here with PCI_DMA_NONE, pci_map_single triggers a BUG() */ | 1631 | scsi_for_each_sg(SCpnt, sg, count, k) { |
1631 | if (!SCpnt->request_bufflen) | 1632 | cpp->sglist[k].address = H2DEV(sg_dma_address(sg)); |
1632 | pci_dir = PCI_DMA_BIDIRECTIONAL; | 1633 | cpp->sglist[k].num_bytes = H2DEV(sg_dma_len(sg)); |
1633 | |||
1634 | if (SCpnt->request_buffer) | ||
1635 | cpp->data_address = H2DEV(pci_map_single(ha->pdev, | ||
1636 | SCpnt-> | ||
1637 | request_buffer, | ||
1638 | SCpnt-> | ||
1639 | request_bufflen, | ||
1640 | pci_dir)); | ||
1641 | |||
1642 | cpp->data_len = H2DEV(SCpnt->request_bufflen); | ||
1643 | return; | ||
1644 | } | ||
1645 | |||
1646 | sgpnt = (struct scatterlist *)SCpnt->request_buffer; | ||
1647 | count = pci_map_sg(ha->pdev, sgpnt, SCpnt->use_sg, pci_dir); | ||
1648 | |||
1649 | for (k = 0; k < count; k++) { | ||
1650 | cpp->sglist[k].address = H2DEV(sg_dma_address(&sgpnt[k])); | ||
1651 | cpp->sglist[k].num_bytes = H2DEV(sg_dma_len(&sgpnt[k])); | ||
1652 | } | 1634 | } |
1653 | 1635 | ||
1654 | cpp->sg = 1; | 1636 | cpp->sg = 1; |
1655 | cpp->data_address = H2DEV(pci_map_single(ha->pdev, cpp->sglist, | 1637 | cpp->data_address = H2DEV(pci_map_single(ha->pdev, cpp->sglist, |
1656 | SCpnt->use_sg * | 1638 | scsi_sg_count(SCpnt) * |
1657 | sizeof(struct sg_list), | 1639 | sizeof(struct sg_list), |
1658 | pci_dir)); | 1640 | pci_dir)); |
1659 | cpp->data_len = H2DEV((SCpnt->use_sg * sizeof(struct sg_list))); | 1641 | cpp->data_len = H2DEV((scsi_sg_count(SCpnt) * sizeof(struct sg_list))); |
1660 | } | 1642 | } |
1661 | 1643 | ||
1662 | static void unmap_dma(unsigned int i, struct hostdata *ha) | 1644 | static void unmap_dma(unsigned int i, struct hostdata *ha) |
@@ -1673,9 +1655,7 @@ static void unmap_dma(unsigned int i, struct hostdata *ha) | |||
1673 | pci_unmap_single(ha->pdev, DEV2H(cpp->sense_addr), | 1655 | pci_unmap_single(ha->pdev, DEV2H(cpp->sense_addr), |
1674 | DEV2H(cpp->sense_len), PCI_DMA_FROMDEVICE); | 1656 | DEV2H(cpp->sense_len), PCI_DMA_FROMDEVICE); |
1675 | 1657 | ||
1676 | if (SCpnt->use_sg) | 1658 | scsi_dma_unmap(SCpnt); |
1677 | pci_unmap_sg(ha->pdev, SCpnt->request_buffer, SCpnt->use_sg, | ||
1678 | pci_dir); | ||
1679 | 1659 | ||
1680 | if (!DEV2H(cpp->data_len)) | 1660 | if (!DEV2H(cpp->data_len)) |
1681 | pci_dir = PCI_DMA_BIDIRECTIONAL; | 1661 | pci_dir = PCI_DMA_BIDIRECTIONAL; |
@@ -1700,9 +1680,9 @@ static void sync_dma(unsigned int i, struct hostdata *ha) | |||
1700 | DEV2H(cpp->sense_len), | 1680 | DEV2H(cpp->sense_len), |
1701 | PCI_DMA_FROMDEVICE); | 1681 | PCI_DMA_FROMDEVICE); |
1702 | 1682 | ||
1703 | if (SCpnt->use_sg) | 1683 | if (scsi_sg_count(SCpnt)) |
1704 | pci_dma_sync_sg_for_cpu(ha->pdev, SCpnt->request_buffer, | 1684 | pci_dma_sync_sg_for_cpu(ha->pdev, scsi_sglist(SCpnt), |
1705 | SCpnt->use_sg, pci_dir); | 1685 | scsi_sg_count(SCpnt), pci_dir); |
1706 | 1686 | ||
1707 | if (!DEV2H(cpp->data_len)) | 1687 | if (!DEV2H(cpp->data_len)) |
1708 | pci_dir = PCI_DMA_BIDIRECTIONAL; | 1688 | pci_dir = PCI_DMA_BIDIRECTIONAL; |