scsi: ufs: core: Convert UPIU_HEADER_DWORD() into a function
authorBart Van Assche <bvanassche@acm.org>
Thu, 6 Jul 2023 21:50:24 +0000 (14:50 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 11 Jul 2023 18:59:53 +0000 (14:59 -0400)
This change reduces the number of parentheses that are required in the
definition of this function and also when using this function.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20230706215054.4113469-1-bvanassche@acm.org
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ufs/core/ufshcd.c
drivers/ufs/core/ufshpb.c
include/ufs/ufs.h

index 983fae84d9e80995468c7ff2fd1b8e92bd1537e6..f00375daaf99f4dc16eca2959e5412d75150043a 100644 (file)
@@ -2637,10 +2637,10 @@ void ufshcd_prepare_utp_scsi_cmd_upiu(struct ufshcd_lrb *lrbp, u8 upiu_flags)
        unsigned short cdb_len;
 
        /* command descriptor fields */
-       ucd_req_ptr->header.dword_0 = UPIU_HEADER_DWORD(
+       ucd_req_ptr->header.dword_0 = upiu_header_dword(
                                UPIU_TRANSACTION_COMMAND, upiu_flags,
                                lrbp->lun, lrbp->task_tag);
-       ucd_req_ptr->header.dword_1 = UPIU_HEADER_DWORD(
+       ucd_req_ptr->header.dword_1 = upiu_header_dword(
                                UPIU_COMMAND_SET_TYPE_SCSI, 0, 0, 0);
 
        /* Total EHS length and Data segment length will be zero */
@@ -2669,16 +2669,16 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba,
        u16 len = be16_to_cpu(query->request.upiu_req.length);
 
        /* Query request header */
-       ucd_req_ptr->header.dword_0 = UPIU_HEADER_DWORD(
+       ucd_req_ptr->header.dword_0 = upiu_header_dword(
                        UPIU_TRANSACTION_QUERY_REQ, upiu_flags,
                        lrbp->lun, lrbp->task_tag);
-       ucd_req_ptr->header.dword_1 = UPIU_HEADER_DWORD(
+       ucd_req_ptr->header.dword_1 = upiu_header_dword(
                        0, query->request.query_func, 0, 0);
 
        /* Data segment length only need for WRITE_DESC */
        if (query->request.upiu_req.opcode == UPIU_QUERY_OPCODE_WRITE_DESC)
                ucd_req_ptr->header.dword_2 =
-                       UPIU_HEADER_DWORD(0, 0, (len >> 8), (u8)len);
+                       upiu_header_dword(0, 0, len >> 8, (u8)len);
        else
                ucd_req_ptr->header.dword_2 = 0;
 
@@ -2700,8 +2700,7 @@ static inline void ufshcd_prepare_utp_nop_upiu(struct ufshcd_lrb *lrbp)
        memset(ucd_req_ptr, 0, sizeof(struct utp_upiu_req));
 
        /* command descriptor fields */
-       ucd_req_ptr->header.dword_0 =
-               UPIU_HEADER_DWORD(
+       ucd_req_ptr->header.dword_0 = upiu_header_dword(
                        UPIU_TRANSACTION_NOP_OUT, 0, 0, lrbp->task_tag);
        /* clear rest of the fields of basic header */
        ucd_req_ptr->header.dword_1 = 0;
index 255f8b38d0c2d29f2ad016e10229e1039de6e21c..92398db10e33c56e209fd53e76788e16c4c44f79 100644 (file)
@@ -121,7 +121,7 @@ static bool ufshpb_is_hpb_rsp_valid(struct ufs_hba *hba,
 {
        /* Check HPB_UPDATE_ALERT */
        if (!(lrbp->ucd_rsp_ptr->header.dword_2 &
-             UPIU_HEADER_DWORD(0, 2, 0, 0)))
+             upiu_header_dword(0, 2, 0, 0)))
                return false;
 
        if (be16_to_cpu(rsp_field->sense_data_len) != DEV_SENSE_SEG_LEN ||
index 4e8d6240e589bdf1b735f7527651eb149f4ff949..a2bc025a748e929664012a35f363bded03fae460 100644 (file)
                                        (sizeof(struct utp_upiu_header)))
 #define UFS_SENSE_SIZE 18
 
-#define UPIU_HEADER_DWORD(byte3, byte2, byte1, byte0)\
-                       cpu_to_be32((byte3 << 24) | (byte2 << 16) |\
-                        (byte1 << 8) | (byte0))
+static inline __be32 upiu_header_dword(u8 byte3, u8 byte2, u8 byte1, u8 byte0)
+{
+       return cpu_to_be32(byte3 << 24 | byte2 << 16 | byte1 << 8 | byte0);
+}
+
 /*
  * UFS device may have standard LUs and LUN id could be from 0x00 to
  * 0x7F. Standard LUs use "Peripheral Device Addressing Format".