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)
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,