scsi: qla2xxx: Use get/put_unaligned where appropriate
authorBart Van Assche <bvanassche@acm.org>
Thu, 4 Apr 2019 19:44:45 +0000 (12:44 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 9 Apr 2019 02:16:34 +0000 (22:16 -0400)
This patch makes the code easier to read but does not change any
functionality.

Cc: Himanshu Madhani <hmadhani@marvell.com>
Cc: Giridhar Malavali <gmalavali@marvell.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/qla2xxx/qla_bsg.c
drivers/scsi/qla2xxx/qla_iocb.c
drivers/scsi/qla2xxx/qla_nvme.c

index d1456a03661bfd012d2434fced0008ae04897276..471d04a49a1550eb3ee942b20412c6e46eee427b 100644 (file)
@@ -1043,7 +1043,7 @@ qla84xx_updatefw(struct bsg_job *bsg_job)
        }
 
        flag = bsg_request->rqst_data.h_vendor.vendor_cmd[1];
-       fw_ver = le32_to_cpu(*((uint32_t *)((uint32_t *)fw_buf + 2)));
+       fw_ver = get_unaligned_le32((uint32_t *)fw_buf + 2);
 
        mn->entry_type = VERIFY_CHIP_IOCB_TYPE;
        mn->entry_count = 1;
index 8d139f1d53e54a9fa27eb721af8388fb37bc6b3d..56278da413319142e5e8e1591f0625be3ef11ce0 100644 (file)
@@ -107,7 +107,7 @@ qla2x00_prep_cont_type0_iocb(struct scsi_qla_host *vha)
        cont_pkt = (cont_entry_t *)req->ring_ptr;
 
        /* Load packet defaults. */
-       *((uint32_t *)(&cont_pkt->entry_type)) = cpu_to_le32(CONTINUE_TYPE);
+       put_unaligned_le32(CONTINUE_TYPE, &cont_pkt->entry_type);
 
        return (cont_pkt);
 }
@@ -136,9 +136,8 @@ qla2x00_prep_cont_type1_iocb(scsi_qla_host_t *vha, struct req_que *req)
        cont_pkt = (cont_a64_entry_t *)req->ring_ptr;
 
        /* Load packet defaults. */
-       *((uint32_t *)(&cont_pkt->entry_type)) = IS_QLAFX00(vha->hw) ?
-           cpu_to_le32(CONTINUE_A64_TYPE_FX00) :
-           cpu_to_le32(CONTINUE_A64_TYPE);
+       put_unaligned_le32(IS_QLAFX00(vha->hw) ? CONTINUE_A64_TYPE_FX00 :
+                          CONTINUE_A64_TYPE, &cont_pkt->entry_type);
 
        return (cont_pkt);
 }
@@ -202,8 +201,7 @@ void qla2x00_build_scsi_iocbs_32(srb_t *sp, cmd_entry_t *cmd_pkt,
        cmd = GET_CMD_SP(sp);
 
        /* Update entry type to indicate Command Type 2 IOCB */
-       *((uint32_t *)(&cmd_pkt->entry_type)) =
-           cpu_to_le32(COMMAND_TYPE);
+       put_unaligned_le32(COMMAND_TYPE, &cmd_pkt->entry_type);
 
        /* No data transfer */
        if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
@@ -260,7 +258,7 @@ void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt,
        cmd = GET_CMD_SP(sp);
 
        /* Update entry type to indicate Command Type 3 IOCB */
-       *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_A64_TYPE);
+       put_unaligned_le32(COMMAND_A64_TYPE, &cmd_pkt->entry_type);
 
        /* No data transfer */
        if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
@@ -596,7 +594,7 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt,
        cmd = GET_CMD_SP(sp);
 
        /* Update entry type to indicate Command Type 3 IOCB */
-       *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_TYPE_6);
+       put_unaligned_le32(COMMAND_TYPE_6, &cmd_pkt->entry_type);
 
        /* No data transfer */
        if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
@@ -711,7 +709,7 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
        cmd = GET_CMD_SP(sp);
 
        /* Update entry type to indicate Command Type 3 IOCB */
-       *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_TYPE_7);
+       put_unaligned_le32(COMMAND_TYPE_7, &cmd_pkt->entry_type);
 
        /* No data transfer */
        if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
@@ -1427,7 +1425,7 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt,
        cmd = GET_CMD_SP(sp);
 
        /* Update entry type to indicate Command Type CRC_2 IOCB */
-       *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_TYPE_CRC_2);
+       put_unaligned_le32(COMMAND_TYPE_CRC_2, &cmd_pkt->entry_type);
 
        vha = sp->vha;
        ha = vha->hw;
@@ -3747,8 +3745,7 @@ qla25xx_build_bidir_iocb(srb_t *sp, struct scsi_qla_host *vha,
        struct bsg_job *bsg_job = sp->u.bsg_job;
 
        /*Update entry type to indicate bidir command */
-       *((uint32_t *)(&cmd_pkt->entry_type)) =
-               cpu_to_le32(COMMAND_BIDIRECTIONAL);
+       put_unaligned_le32(COMMAND_BIDIRECTIONAL, &cmd_pkt->entry_type);
 
        /* Set the transfer direction, in this set both flags
         * Also set the BD_WRAP_BACK flag, firmware will take care
index 3a6160ca9b4a51bd0c2407780404ca2375be5500..f084936e68f906efdbe656bc39337f30e0e286d9 100644 (file)
@@ -449,8 +449,8 @@ static inline int qla2x00_start_nvme_mq(srb_t *sp)
                                req->ring_ptr++;
                        }
                        cont_pkt = (cont_a64_entry_t *)req->ring_ptr;
-                       *((uint32_t *)(&cont_pkt->entry_type)) =
-                           cpu_to_le32(CONTINUE_A64_TYPE);
+                       put_unaligned_le32(CONTINUE_A64_TYPE,
+                                          &cont_pkt->entry_type);
 
                        cur_dsd = (uint32_t *)cont_pkt->dseg_0_address;
                        avail_dsds = 5;