scsi: ufs: core: Improve static type checking
authorBart Van Assche <bvanassche@acm.org>
Wed, 20 Oct 2021 21:40:17 +0000 (14:40 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 27 Oct 2021 03:24:49 +0000 (23:24 -0400)
Introduce an enumeration type for the overall command status to allow the
compiler to perform more static type checking.

Link: https://lore.kernel.org/r/20211020214024.2007615-4-bvanassche@acm.org
Acked-by: Avri Altman <Avri.Altman@wdc.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/ufs/ufshcd.c
drivers/scsi/ufs/ufshci.h

index 53dd42f95eedf7be6fb9b591f2127a6e6ff0d9e2..610be6746f740bed23083174c5d541e188e77e90 100644 (file)
@@ -711,7 +711,7 @@ static inline bool ufshcd_is_device_present(struct ufs_hba *hba)
  * This function is used to get the OCS field from UTRD
  * Returns the OCS field in the UTRD
  */
-static inline int ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp)
+static enum utp_ocs ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp)
 {
        return le32_to_cpu(lrbp->utr_descriptor_ptr->header.dword_2) & MASK_OCS;
 }
@@ -5089,7 +5089,7 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
 {
        int result = 0;
        int scsi_status;
-       int ocs;
+       enum utp_ocs ocs;
 
        /* overall command status of utrd */
        ocs = ufshcd_get_tr_ocs(lrbp);
@@ -6631,7 +6631,8 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id,
                u8 tm_function, u8 *tm_response)
 {
        struct utp_task_req_desc treq = { { 0 }, };
-       int ocs_value, err;
+       enum utp_ocs ocs_value;
+       int err;
 
        /* Configure task request descriptor */
        treq.header.dword_0 = cpu_to_le32(UTP_REQ_DESC_INT_CMD);
@@ -6809,7 +6810,7 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba,
        int err;
        enum dev_cmd_type cmd_type = DEV_CMD_TYPE_QUERY;
        struct utp_task_req_desc treq = { { 0 }, };
-       int ocs_value;
+       enum utp_ocs ocs_value;
        u8 tm_f = be32_to_cpu(req_upiu->header.dword_1) >> 16 & MASK_TM_FUNC;
 
        switch (msgcode) {
index 9a754fab890808d2b6acb8619d54a7a59c331574..f66cf9e477cb864a80e312b2500e6d5f39cb68d7 100644 (file)
@@ -389,7 +389,7 @@ enum {
 };
 
 /* Overall command status values */
-enum {
+enum utp_ocs {
        OCS_SUCCESS                     = 0x0,
        OCS_INVALID_CMD_TABLE_ATTR      = 0x1,
        OCS_INVALID_PRDT_ATTR           = 0x2,
@@ -402,6 +402,9 @@ enum {
        OCS_INVALID_CRYPTO_CONFIG       = 0x9,
        OCS_GENERAL_CRYPTO_ERROR        = 0xA,
        OCS_INVALID_COMMAND_STATUS      = 0x0F,
+};
+
+enum {
        MASK_OCS                        = 0x0F,
 };