Skip to content

Commit f20f43c

Browse files
Christoph Hellwigmartinkpetersen
authored andcommitted
scsi: qla1280: use lower_32_bits and upper_32_bits instead of reinventing them
This also moves the optimization for builds with 32-bit dma_addr_t to the compiler (where it belongs) instead of opencoding it. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 88693b3 commit f20f43c

File tree

1 file changed

+20
-27
lines changed

1 file changed

+20
-27
lines changed

drivers/scsi/qla1280.c

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,6 @@
390390
#define QLA_64BIT_PTR 1
391391
#endif
392392

393-
#ifdef QLA_64BIT_PTR
394-
#define pci_dma_hi32(a) ((a >> 16) >> 16)
395-
#else
396-
#define pci_dma_hi32(a) 0
397-
#endif
398-
#define pci_dma_lo32(a) (a & 0xffffffff)
399-
400393
#define NVRAM_DELAY() udelay(500) /* 2 microseconds */
401394

402395
#if defined(__ia64__) && !defined(ia64_platform_is)
@@ -1790,8 +1783,8 @@ qla1280_load_firmware_dma(struct scsi_qla_host *ha)
17901783
mb[4] = cnt;
17911784
mb[3] = ha->request_dma & 0xffff;
17921785
mb[2] = (ha->request_dma >> 16) & 0xffff;
1793-
mb[7] = pci_dma_hi32(ha->request_dma) & 0xffff;
1794-
mb[6] = pci_dma_hi32(ha->request_dma) >> 16;
1786+
mb[7] = upper_32_bits(ha->request_dma) & 0xffff;
1787+
mb[6] = upper_32_bits(ha->request_dma) >> 16;
17951788
dprintk(2, "%s: op=%d 0x%p = 0x%4x,0x%4x,0x%4x,0x%4x\n",
17961789
__func__, mb[0],
17971790
(void *)(long)ha->request_dma,
@@ -1810,8 +1803,8 @@ qla1280_load_firmware_dma(struct scsi_qla_host *ha)
18101803
mb[4] = cnt;
18111804
mb[3] = p_tbuf & 0xffff;
18121805
mb[2] = (p_tbuf >> 16) & 0xffff;
1813-
mb[7] = pci_dma_hi32(p_tbuf) & 0xffff;
1814-
mb[6] = pci_dma_hi32(p_tbuf) >> 16;
1806+
mb[7] = upper_32_bits(p_tbuf) & 0xffff;
1807+
mb[6] = upper_32_bits(p_tbuf) >> 16;
18151808

18161809
err = qla1280_mailbox_command(ha, BIT_4 | BIT_3 | BIT_2 |
18171810
BIT_1 | BIT_0, mb);
@@ -1933,8 +1926,8 @@ qla1280_init_rings(struct scsi_qla_host *ha)
19331926
mb[3] = ha->request_dma & 0xffff;
19341927
mb[2] = (ha->request_dma >> 16) & 0xffff;
19351928
mb[4] = 0;
1936-
mb[7] = pci_dma_hi32(ha->request_dma) & 0xffff;
1937-
mb[6] = pci_dma_hi32(ha->request_dma) >> 16;
1929+
mb[7] = upper_32_bits(ha->request_dma) & 0xffff;
1930+
mb[6] = upper_32_bits(ha->request_dma) >> 16;
19381931
if (!(status = qla1280_mailbox_command(ha, BIT_7 | BIT_6 | BIT_4 |
19391932
BIT_3 | BIT_2 | BIT_1 | BIT_0,
19401933
&mb[0]))) {
@@ -1947,8 +1940,8 @@ qla1280_init_rings(struct scsi_qla_host *ha)
19471940
mb[3] = ha->response_dma & 0xffff;
19481941
mb[2] = (ha->response_dma >> 16) & 0xffff;
19491942
mb[5] = 0;
1950-
mb[7] = pci_dma_hi32(ha->response_dma) & 0xffff;
1951-
mb[6] = pci_dma_hi32(ha->response_dma) >> 16;
1943+
mb[7] = upper_32_bits(ha->response_dma) & 0xffff;
1944+
mb[6] = upper_32_bits(ha->response_dma) >> 16;
19521945
status = qla1280_mailbox_command(ha, BIT_7 | BIT_6 | BIT_5 |
19531946
BIT_3 | BIT_2 | BIT_1 | BIT_0,
19541947
&mb[0]);
@@ -2914,13 +2907,13 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
29142907
SCSI_BUS_32(cmd));
29152908
#endif
29162909
*dword_ptr++ =
2917-
cpu_to_le32(pci_dma_lo32(dma_handle));
2910+
cpu_to_le32(lower_32_bits(dma_handle));
29182911
*dword_ptr++ =
2919-
cpu_to_le32(pci_dma_hi32(dma_handle));
2912+
cpu_to_le32(upper_32_bits(dma_handle));
29202913
*dword_ptr++ = cpu_to_le32(sg_dma_len(s));
29212914
dprintk(3, "S/G Segment phys_addr=%x %x, len=0x%x\n",
2922-
cpu_to_le32(pci_dma_hi32(dma_handle)),
2923-
cpu_to_le32(pci_dma_lo32(dma_handle)),
2915+
cpu_to_le32(upper_32_bits(dma_handle)),
2916+
cpu_to_le32(lower_32_bits(dma_handle)),
29242917
cpu_to_le32(sg_dma_len(sg_next(s))));
29252918
remseg--;
29262919
}
@@ -2976,14 +2969,14 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
29762969
SCSI_BUS_32(cmd));
29772970
#endif
29782971
*dword_ptr++ =
2979-
cpu_to_le32(pci_dma_lo32(dma_handle));
2972+
cpu_to_le32(lower_32_bits(dma_handle));
29802973
*dword_ptr++ =
2981-
cpu_to_le32(pci_dma_hi32(dma_handle));
2974+
cpu_to_le32(upper_32_bits(dma_handle));
29822975
*dword_ptr++ =
29832976
cpu_to_le32(sg_dma_len(s));
29842977
dprintk(3, "S/G Segment Cont. phys_addr=%x %x, len=0x%x\n",
2985-
cpu_to_le32(pci_dma_hi32(dma_handle)),
2986-
cpu_to_le32(pci_dma_lo32(dma_handle)),
2978+
cpu_to_le32(upper_32_bits(dma_handle)),
2979+
cpu_to_le32(lower_32_bits(dma_handle)),
29872980
cpu_to_le32(sg_dma_len(s)));
29882981
}
29892982
remseg -= cnt;
@@ -3178,10 +3171,10 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
31783171
if (cnt == 4)
31793172
break;
31803173
*dword_ptr++ =
3181-
cpu_to_le32(pci_dma_lo32(sg_dma_address(s)));
3174+
cpu_to_le32(lower_32_bits(sg_dma_address(s)));
31823175
*dword_ptr++ = cpu_to_le32(sg_dma_len(s));
31833176
dprintk(3, "S/G Segment phys_addr=0x%lx, len=0x%x\n",
3184-
(pci_dma_lo32(sg_dma_address(s))),
3177+
(lower_32_bits(sg_dma_address(s))),
31853178
(sg_dma_len(s)));
31863179
remseg--;
31873180
}
@@ -3224,13 +3217,13 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
32243217
if (cnt == 7)
32253218
break;
32263219
*dword_ptr++ =
3227-
cpu_to_le32(pci_dma_lo32(sg_dma_address(s)));
3220+
cpu_to_le32(lower_32_bits(sg_dma_address(s)));
32283221
*dword_ptr++ =
32293222
cpu_to_le32(sg_dma_len(s));
32303223
dprintk(1,
32313224
"S/G Segment Cont. phys_addr=0x%x, "
32323225
"len=0x%x\n",
3233-
cpu_to_le32(pci_dma_lo32(sg_dma_address(s))),
3226+
cpu_to_le32(lower_32_bits(sg_dma_address(s))),
32343227
cpu_to_le32(sg_dma_len(s)));
32353228
}
32363229
remseg -= cnt;

0 commit comments

Comments
 (0)