Commit 957d63e7 authored by Bart Van Assche's avatar Bart Van Assche Committed by Martin K. Petersen

scsi: ufs: core: Improve static type checking

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.orgAcked-by: default avatarAvri Altman <Avri.Altman@wdc.com>
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 91bb765c
...@@ -711,7 +711,7 @@ static inline bool ufshcd_is_device_present(struct ufs_hba *hba) ...@@ -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 * This function is used to get the OCS field from UTRD
* Returns the OCS field in the 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; 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) ...@@ -5089,7 +5089,7 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
{ {
int result = 0; int result = 0;
int scsi_status; int scsi_status;
int ocs; enum utp_ocs ocs;
/* overall command status of utrd */ /* overall command status of utrd */
ocs = ufshcd_get_tr_ocs(lrbp); 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, ...@@ -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) u8 tm_function, u8 *tm_response)
{ {
struct utp_task_req_desc treq = { { 0 }, }; struct utp_task_req_desc treq = { { 0 }, };
int ocs_value, err; enum utp_ocs ocs_value;
int err;
/* Configure task request descriptor */ /* Configure task request descriptor */
treq.header.dword_0 = cpu_to_le32(UTP_REQ_DESC_INT_CMD); 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, ...@@ -6809,7 +6810,7 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba,
int err; int err;
enum dev_cmd_type cmd_type = DEV_CMD_TYPE_QUERY; enum dev_cmd_type cmd_type = DEV_CMD_TYPE_QUERY;
struct utp_task_req_desc treq = { { 0 }, }; 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; u8 tm_f = be32_to_cpu(req_upiu->header.dword_1) >> 16 & MASK_TM_FUNC;
switch (msgcode) { switch (msgcode) {
......
...@@ -389,7 +389,7 @@ enum { ...@@ -389,7 +389,7 @@ enum {
}; };
/* Overall command status values */ /* Overall command status values */
enum { enum utp_ocs {
OCS_SUCCESS = 0x0, OCS_SUCCESS = 0x0,
OCS_INVALID_CMD_TABLE_ATTR = 0x1, OCS_INVALID_CMD_TABLE_ATTR = 0x1,
OCS_INVALID_PRDT_ATTR = 0x2, OCS_INVALID_PRDT_ATTR = 0x2,
...@@ -402,6 +402,9 @@ enum { ...@@ -402,6 +402,9 @@ enum {
OCS_INVALID_CRYPTO_CONFIG = 0x9, OCS_INVALID_CRYPTO_CONFIG = 0x9,
OCS_GENERAL_CRYPTO_ERROR = 0xA, OCS_GENERAL_CRYPTO_ERROR = 0xA,
OCS_INVALID_COMMAND_STATUS = 0x0F, OCS_INVALID_COMMAND_STATUS = 0x0F,
};
enum {
MASK_OCS = 0x0F, MASK_OCS = 0x0F,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment