UFSHCD_UIC_DME_ERROR = (1 << 5), /* DME error */
};
-/* Interrupt configuration options */
-enum {
- UFSHCD_INT_DISABLE,
- UFSHCD_INT_ENABLE,
- UFSHCD_INT_CLEAR,
-};
-
#define ufshcd_set_eh_in_progress(h) \
- (h->eh_flags |= UFSHCD_EH_IN_PROGRESS)
+ ((h)->eh_flags |= UFSHCD_EH_IN_PROGRESS)
#define ufshcd_eh_in_progress(h) \
- (h->eh_flags & UFSHCD_EH_IN_PROGRESS)
+ ((h)->eh_flags & UFSHCD_EH_IN_PROGRESS)
#define ufshcd_clear_eh_in_progress(h) \
- (h->eh_flags &= ~UFSHCD_EH_IN_PROGRESS)
+ ((h)->eh_flags &= ~UFSHCD_EH_IN_PROGRESS)
#define ufshcd_set_ufs_dev_active(h) \
((h)->curr_dev_pwr_mode = UFS_ACTIVE_PWR_MODE)
case UFSHCI_VERSION_10:
intr_mask = INTERRUPT_MASK_ALL_VER_10;
break;
- /* allow fall through */
case UFSHCI_VERSION_11:
case UFSHCI_VERSION_20:
intr_mask = INTERRUPT_MASK_ALL_VER_11;
break;
- /* allow fall through */
case UFSHCI_VERSION_21:
default:
intr_mask = INTERRUPT_MASK_ALL_VER_21;
+ break;
}
return intr_mask;
* the host controller
* @hba: pointer to adapter instance
*
- * Returns 1 if device present, 0 if no device detected
+ * Returns true if device present, false if no device detected
*/
-static inline int ufshcd_is_device_present(struct ufs_hba *hba)
+static inline bool ufshcd_is_device_present(struct ufs_hba *hba)
{
return (ufshcd_readl(hba, REG_CONTROLLER_STATUS) &
- DEVICE_PRESENT) ? 1 : 0;
+ DEVICE_PRESENT) ? true : false;
}
/**
*/
static inline int ufshcd_get_lists_status(u32 reg)
{
- /*
- * The mask 0xFF is for the following HCS register bits
- * Bit Description
- * 0 Device Present
- * 1 UTRLRDY
- * 2 UTMRLRDY
- * 3 UCRDY
- * 4-7 reserved
- */
- return ((reg & 0xFF) >> 1) ^ 0x07;
+ return !((reg & UFSHCD_STATUS_READY) == UFSHCD_STATUS_READY);
}
/**
* ufshcd_is_hba_active - Get controller state
* @hba: per adapter instance
*
- * Returns zero if controller is active, 1 otherwise
+ * Returns false if controller is active, true otherwise
*/
-static inline int ufshcd_is_hba_active(struct ufs_hba *hba)
+static inline bool ufshcd_is_hba_active(struct ufs_hba *hba)
{
- return (ufshcd_readl(hba, REG_CONTROLLER_ENABLE) & 0x1) ? 0 : 1;
+ return (ufshcd_readl(hba, REG_CONTROLLER_ENABLE) & CONTROLLER_ENABLE)
+ ? false : true;
}
static const char *ufschd_uic_link_state_to_string(
break;
}
/*
- * If we here, it means gating work is either done or
+ * If we are here, it means gating work is either done or
* currently running. Hence, fall through to cancel gating
* work and to enable clocks.
*/
u8 *buf,
u32 size)
{
- int err = 0;
- int retries;
-
- for (retries = QUERY_REQ_RETRIES; retries > 0; retries--) {
- /* Read descriptor*/
- err = ufshcd_read_desc(hba, QUERY_DESC_IDN_POWER, 0, buf, size);
- if (!err)
- break;
- dev_dbg(hba->dev, "%s: error %d retrying\n", __func__, err);
- }
-
- return err;
+ return ufshcd_read_desc(hba, QUERY_DESC_IDN_POWER, 0, buf, size);
}
static int ufshcd_read_device_desc(struct ufs_hba *hba, u8 *buf, u32 size)
{
int ret = 0;
u8 lun_qdepth;
- int retries;
struct ufs_hba *hba;
hba = shost_priv(sdev->host);
lun_qdepth = hba->nutrs;
- for (retries = QUERY_REQ_RETRIES; retries > 0; retries--) {
- /* Read descriptor*/
- ret = ufshcd_read_unit_desc_param(hba,
- ufshcd_scsi_to_upiu_lun(sdev->lun),
- UNIT_DESC_PARAM_LU_Q_DEPTH,
- &lun_qdepth,
- sizeof(lun_qdepth));
- if (!ret || ret == -ENOTSUPP)
- break;
-
- dev_dbg(hba->dev, "%s: error %d retrying\n", __func__, ret);
- }
+ ret = ufshcd_read_unit_desc_param(hba,
+ ufshcd_scsi_to_upiu_lun(sdev->lun),
+ UNIT_DESC_PARAM_LU_Q_DEPTH,
+ &lun_qdepth,
+ sizeof(lun_qdepth));
/* Some WLUN doesn't support unit descriptor */
if (ret == -EOPNOTSUPP)
goto out;
val = hba->ee_ctrl_mask & ~mask;
- val &= 0xFFFF; /* 2 bytes */
+ val &= MASK_EE_STATUS;
err = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_WRITE_ATTR,
QUERY_ATTR_IDN_EE_CONTROL, 0, 0, &val);
if (!err)
goto out;
val = hba->ee_ctrl_mask | mask;
- val &= 0xFFFF; /* 2 bytes */
+ val &= MASK_EE_STATUS;
err = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_WRITE_ATTR,
QUERY_ATTR_IDN_EE_CONTROL, 0, 0, &val);
if (!err)
return icc_level;
}
-static int ufshcd_set_icc_levels_attr(struct ufs_hba *hba, u32 icc_level)
-{
- int ret = 0;
- int retries;
-
- for (retries = QUERY_REQ_RETRIES; retries > 0; retries--) {
- /* write attribute */
- ret = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_WRITE_ATTR,
- QUERY_ATTR_IDN_ACTIVE_ICC_LVL, 0, 0, &icc_level);
- if (!ret)
- break;
-
- dev_dbg(hba->dev, "%s: failed with error %d\n", __func__, ret);
- }
-
- return ret;
-}
-
static void ufshcd_init_icc_levels(struct ufs_hba *hba)
{
int ret;
dev_dbg(hba->dev, "%s: setting icc_level 0x%x",
__func__, hba->init_prefetch_data.icc_level);
- ret = ufshcd_set_icc_levels_attr(hba,
- hba->init_prefetch_data.icc_level);
+ ret = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_WRITE_ATTR,
+ QUERY_ATTR_IDN_ACTIVE_ICC_LVL, 0, 0,
+ &hba->init_prefetch_data.icc_level);
if (ret)
dev_err(hba->dev,
INIT_WORK(&hba->clk_scaling.resume_work,
ufshcd_clk_scaling_resume_work);
- snprintf(wq_name, ARRAY_SIZE(wq_name), "ufs_clkscaling_%d",
+ snprintf(wq_name, sizeof(wq_name), "ufs_clkscaling_%d",
host->host_no);
hba->clk_scaling.workq = create_singlethread_workqueue(wq_name);