diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2007-05-21 01:58:30 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2007-05-26 20:13:27 -0400 |
commit | a258c85d0866d93b0c76e60fe236b6483a0d5680 (patch) | |
tree | 226946eb0e005a95b49e9a4479d7ae16ab8aafc7 /drivers/scsi/initio.c | |
parent | c66cc13c16377d177d8887f15a3cc42ab3866f57 (diff) |
[SCSI] initio: 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/scsi/initio.c')
-rw-r--r-- | drivers/scsi/initio.c | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c index 65ca1424954e..d9dfb69ae031 100644 --- a/drivers/scsi/initio.c +++ b/drivers/scsi/initio.c | |||
@@ -2563,7 +2563,7 @@ static void initio_build_scb(struct initio_host * host, struct scsi_ctrl_blk * c | |||
2563 | { /* Create corresponding SCB */ | 2563 | { /* Create corresponding SCB */ |
2564 | struct scatterlist *sglist; | 2564 | struct scatterlist *sglist; |
2565 | struct sg_entry *sg; /* Pointer to SG list */ | 2565 | struct sg_entry *sg; /* Pointer to SG list */ |
2566 | int i; | 2566 | int i, nseg; |
2567 | long total_len; | 2567 | long total_len; |
2568 | dma_addr_t dma_addr; | 2568 | dma_addr_t dma_addr; |
2569 | 2569 | ||
@@ -2600,34 +2600,26 @@ static void initio_build_scb(struct initio_host * host, struct scsi_ctrl_blk * c | |||
2600 | } | 2600 | } |
2601 | 2601 | ||
2602 | /* todo handle map_sg error */ | 2602 | /* todo handle map_sg error */ |
2603 | if (cmnd->use_sg) { | 2603 | nseg = scsi_dma_map(cmnd); |
2604 | BUG_ON(nseg < 0); | ||
2605 | if (nseg) { | ||
2604 | dma_addr = dma_map_single(&host->pci_dev->dev, &cblk->sglist[0], | 2606 | dma_addr = dma_map_single(&host->pci_dev->dev, &cblk->sglist[0], |
2605 | sizeof(struct sg_entry) * TOTAL_SG_ENTRY, | 2607 | sizeof(struct sg_entry) * TOTAL_SG_ENTRY, |
2606 | DMA_BIDIRECTIONAL); | 2608 | DMA_BIDIRECTIONAL); |
2607 | cblk->bufptr = cpu_to_le32((u32)dma_addr); | 2609 | cblk->bufptr = cpu_to_le32((u32)dma_addr); |
2608 | cmnd->SCp.dma_handle = dma_addr; | 2610 | cmnd->SCp.dma_handle = dma_addr; |
2609 | 2611 | ||
2610 | sglist = (struct scatterlist *) cmnd->request_buffer; | ||
2611 | cblk->sglen = dma_map_sg(&host->pci_dev->dev, sglist, | ||
2612 | cmnd->use_sg, cmnd->sc_data_direction); | ||
2613 | 2612 | ||
2614 | cblk->flags |= SCF_SG; /* Turn on SG list flag */ | 2613 | cblk->flags |= SCF_SG; /* Turn on SG list flag */ |
2615 | for (i = 0, total_len = 0, sg = &cblk->sglist[0]; /* 1.01g */ | 2614 | total_len = 0; |
2616 | i < cblk->sglen; i++, sg++, sglist++) { | 2615 | sg = &cblk->sglist[0]; |
2616 | scsi_for_each_sg(cmnd, sglist, cblk->sglen, i) { | ||
2617 | sg->data = cpu_to_le32((u32)sg_dma_address(sglist)); | 2617 | sg->data = cpu_to_le32((u32)sg_dma_address(sglist)); |
2618 | total_len += sg->len = cpu_to_le32((u32)sg_dma_len(sglist)); | 2618 | total_len += sg->len = cpu_to_le32((u32)sg_dma_len(sglist)); |
2619 | } | 2619 | } |
2620 | 2620 | ||
2621 | cblk->buflen = (cmnd->request_bufflen > total_len) ? | 2621 | cblk->buflen = (scsi_bufflen(cmnd) > total_len) ? |
2622 | total_len : cmnd->request_bufflen; | 2622 | total_len : scsi_bufflen(cmnd); |
2623 | } else if (cmnd->request_bufflen) { /* Non SG */ | ||
2624 | dma_addr = dma_map_single(&host->pci_dev->dev, cmnd->request_buffer, | ||
2625 | cmnd->request_bufflen, | ||
2626 | cmnd->sc_data_direction); | ||
2627 | cmnd->SCp.dma_handle = dma_addr; | ||
2628 | cblk->bufptr = cpu_to_le32((u32)dma_addr); | ||
2629 | cblk->buflen = cpu_to_le32((u32)cmnd->request_bufflen); | ||
2630 | cblk->sglen = 0; | ||
2631 | } else { /* No data transfer required */ | 2623 | } else { /* No data transfer required */ |
2632 | cblk->buflen = 0; | 2624 | cblk->buflen = 0; |
2633 | cblk->sglen = 0; | 2625 | cblk->sglen = 0; |
@@ -2750,18 +2742,12 @@ static void i91u_unmap_scb(struct pci_dev *pci_dev, struct scsi_cmnd *cmnd) | |||
2750 | } | 2742 | } |
2751 | 2743 | ||
2752 | /* request buffer */ | 2744 | /* request buffer */ |
2753 | if (cmnd->use_sg) { | 2745 | if (scsi_sg_count(cmnd)) { |
2754 | dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle, | 2746 | dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle, |
2755 | sizeof(struct sg_entry) * TOTAL_SG_ENTRY, | 2747 | sizeof(struct sg_entry) * TOTAL_SG_ENTRY, |
2756 | DMA_BIDIRECTIONAL); | 2748 | DMA_BIDIRECTIONAL); |
2757 | 2749 | ||
2758 | dma_unmap_sg(&pci_dev->dev, cmnd->request_buffer, | 2750 | scsi_dma_unmap(cmnd); |
2759 | cmnd->use_sg, | ||
2760 | cmnd->sc_data_direction); | ||
2761 | } else if (cmnd->request_bufflen) { | ||
2762 | dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle, | ||
2763 | cmnd->request_bufflen, | ||
2764 | cmnd->sc_data_direction); | ||
2765 | } | 2751 | } |
2766 | } | 2752 | } |
2767 | 2753 | ||