From 1dc9ea01ecbbac7907000979084f9d7ab19316d6 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 5 Oct 2013 18:07:52 +0000 Subject: [PATCH] qla2x00t: Clean up DMA address computation code (merge r4778) git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/2.2.x@5043 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t/qla2x00-target/qla2x00t.c | 46 +++++++++++++----------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/qla2x00t/qla2x00-target/qla2x00t.c b/qla2x00t/qla2x00-target/qla2x00t.c index ff74be6cd..f5cce3e38 100644 --- a/qla2x00t/qla2x00-target/qla2x00t.c +++ b/qla2x00t/qla2x00-target/qla2x00t.c @@ -2287,20 +2287,18 @@ static void q2t_load_cont_data_segments(struct q2t_prm *prm) for (cnt = 0; cnt < prm->tgt->datasegs_per_cont && prm->seg_cnt; cnt++, prm->seg_cnt--) { - *dword_ptr++ = - cpu_to_le32(pci_dma_lo32 - (sg_dma_address(prm->sg))); + dma_addr_t dma_addr = sg_dma_address(prm->sg); + + *dword_ptr++ = cpu_to_le32(pci_dma_lo32(dma_addr)); if (enable_64bit_addressing) { *dword_ptr++ = - cpu_to_le32(pci_dma_hi32 - (sg_dma_address - (prm->sg))); + cpu_to_le32(pci_dma_hi32(dma_addr)); } *dword_ptr++ = cpu_to_le32(sg_dma_len(prm->sg)); TRACE_SG("S/G Segment Cont. phys_addr=%llx:%llx, len=%d", - (long long unsigned int)pci_dma_hi32(sg_dma_address(prm->sg)), - (long long unsigned int)pci_dma_lo32(sg_dma_address(prm->sg)), + (long long unsigned int)pci_dma_hi32(dma_addr), + (long long unsigned int)pci_dma_lo32(dma_addr), (int)sg_dma_len(prm->sg)); prm->sg++; @@ -2352,17 +2350,16 @@ static void q2x_load_data_segments(struct q2t_prm *prm) for (cnt = 0; (cnt < prm->tgt->datasegs_per_cmd) && prm->seg_cnt; cnt++, prm->seg_cnt--) { - *dword_ptr++ = - cpu_to_le32(pci_dma_lo32(sg_dma_address(prm->sg))); - if (enable_64bit_addressing) { - *dword_ptr++ = - cpu_to_le32(pci_dma_hi32(sg_dma_address(prm->sg))); - } + dma_addr_t dma_addr = sg_dma_address(prm->sg); + + *dword_ptr++ = cpu_to_le32(pci_dma_lo32(dma_addr)); + if (enable_64bit_addressing) + *dword_ptr++ = cpu_to_le32(pci_dma_hi32(dma_addr)); *dword_ptr++ = cpu_to_le32(sg_dma_len(prm->sg)); TRACE_SG("S/G Segment phys_addr=%llx:%llx, len=%d", - (long long unsigned int)pci_dma_hi32(sg_dma_address(prm->sg)), - (long long unsigned int)pci_dma_lo32(sg_dma_address(prm->sg)), + (long long unsigned int)pci_dma_hi32(dma_addr), + (long long unsigned int)pci_dma_lo32(dma_addr), (int)sg_dma_len(prm->sg)); prm->sg++; @@ -2415,19 +2412,16 @@ static void q24_load_data_segments(struct q2t_prm *prm) for (cnt = 0; (cnt < prm->tgt->datasegs_per_cmd) && prm->seg_cnt; cnt++, prm->seg_cnt--) { - *dword_ptr++ = - cpu_to_le32(pci_dma_lo32(sg_dma_address(prm->sg))); - if (enable_64bit_addressing) { - *dword_ptr++ = - cpu_to_le32(pci_dma_hi32(sg_dma_address(prm->sg))); - } + dma_addr_t dma_addr = sg_dma_address(prm->sg); + + *dword_ptr++ = cpu_to_le32(pci_dma_lo32(dma_addr)); + if (enable_64bit_addressing) + *dword_ptr++ = cpu_to_le32(pci_dma_hi32(dma_addr)); *dword_ptr++ = cpu_to_le32(sg_dma_len(prm->sg)); TRACE_SG("S/G Segment phys_addr=%llx:%llx, len=%d", - (long long unsigned int)pci_dma_hi32(sg_dma_address( - prm->sg)), - (long long unsigned int)pci_dma_lo32(sg_dma_address( - prm->sg)), + (long long unsigned int)pci_dma_hi32(dma_addr), + (long long unsigned int)pci_dma_lo32(dma_addr), (int)sg_dma_len(prm->sg)); prm->sg++;