Skip to content

Commit d3ba622

Browse files
beanhuomartinkpetersen
authored andcommitted
scsi: ufs: Cleanup WB buffer flush toggle implementation
Delete ufshcd_wb_buf_flush_enable() and ufshcd_wb_buf_flush_disable(). Move the implementation into ufshcd_wb_toggle_flush(). Link: https://lore.kernel.org/r/20210121185736.12471-1-huobean@gmail.com Reviewed-by: Stanley Chu <stanley.chu@mediatek.com> Reviewed-by: Can Guo <cang@codeaurora.org> Signed-off-by: Bean Huo <beanhuo@micron.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent c750a9c commit d3ba622

1 file changed

Lines changed: 19 additions & 42 deletions

File tree

drivers/scsi/ufs/ufshcd.c

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,8 @@ static int ufshcd_setup_vreg(struct ufs_hba *hba, bool on);
247247
static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba,
248248
struct ufs_vreg *vreg);
249249
static int ufshcd_try_to_abort_task(struct ufs_hba *hba, int tag);
250-
static int ufshcd_wb_buf_flush_enable(struct ufs_hba *hba);
251-
static int ufshcd_wb_buf_flush_disable(struct ufs_hba *hba);
252250
static int ufshcd_wb_toggle_flush_during_h8(struct ufs_hba *hba, bool set);
253-
static inline void ufshcd_wb_toggle_flush(struct ufs_hba *hba, bool enable);
251+
static inline int ufshcd_wb_toggle_flush(struct ufs_hba *hba, bool enable);
254252
static void ufshcd_hba_vreg_set_lpm(struct ufs_hba *hba);
255253
static void ufshcd_hba_vreg_set_hpm(struct ufs_hba *hba);
256254

@@ -5474,58 +5472,37 @@ static int ufshcd_wb_toggle_flush_during_h8(struct ufs_hba *hba, bool set)
54745472
index, NULL);
54755473
}
54765474

5477-
static inline void ufshcd_wb_toggle_flush(struct ufs_hba *hba, bool enable)
5478-
{
5479-
if (enable)
5480-
ufshcd_wb_buf_flush_enable(hba);
5481-
else
5482-
ufshcd_wb_buf_flush_disable(hba);
5483-
5484-
}
5485-
5486-
static int ufshcd_wb_buf_flush_enable(struct ufs_hba *hba)
5475+
static inline int ufshcd_wb_toggle_flush(struct ufs_hba *hba, bool enable)
54875476
{
54885477
int ret;
54895478
u8 index;
5479+
enum query_opcode opcode;
54905480

5491-
if (!ufshcd_is_wb_allowed(hba) || hba->dev_info.wb_buf_flush_enabled)
5481+
if (!ufshcd_is_wb_allowed(hba) ||
5482+
hba->dev_info.wb_buf_flush_enabled == enable)
54925483
return 0;
54935484

5494-
index = ufshcd_wb_get_query_index(hba);
5495-
ret = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_SET_FLAG,
5496-
QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN,
5497-
index, NULL);
5498-
if (ret)
5499-
dev_err(hba->dev, "%s WB - buf flush enable failed %d\n",
5500-
__func__, ret);
5485+
if (enable)
5486+
opcode = UPIU_QUERY_OPCODE_SET_FLAG;
55015487
else
5502-
hba->dev_info.wb_buf_flush_enabled = true;
5503-
5504-
dev_dbg(hba->dev, "WB - Flush enabled: %d\n", ret);
5505-
return ret;
5506-
}
5507-
5508-
static int ufshcd_wb_buf_flush_disable(struct ufs_hba *hba)
5509-
{
5510-
int ret;
5511-
u8 index;
5512-
5513-
if (!ufshcd_is_wb_allowed(hba) || !hba->dev_info.wb_buf_flush_enabled)
5514-
return 0;
5488+
opcode = UPIU_QUERY_OPCODE_CLEAR_FLAG;
55155489

55165490
index = ufshcd_wb_get_query_index(hba);
5517-
ret = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_CLEAR_FLAG,
5518-
QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN,
5519-
index, NULL);
5491+
ret = ufshcd_query_flag_retry(hba, opcode,
5492+
QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN, index,
5493+
NULL);
55205494
if (ret) {
5521-
dev_warn(hba->dev, "%s: WB - buf flush disable failed %d\n",
5522-
__func__, ret);
5523-
} else {
5524-
hba->dev_info.wb_buf_flush_enabled = false;
5525-
dev_dbg(hba->dev, "WB - Flush disabled: %d\n", ret);
5495+
dev_err(hba->dev, "%s WB-Buf Flush %s failed %d\n", __func__,
5496+
enable ? "enable" : "disable", ret);
5497+
goto out;
55265498
}
55275499

5500+
hba->dev_info.wb_buf_flush_enabled = enable;
5501+
5502+
dev_dbg(hba->dev, "WB-Buf Flush %s\n", enable ? "enabled" : "disabled");
5503+
out:
55285504
return ret;
5505+
55295506
}
55305507

55315508
static bool ufshcd_wb_presrv_usrspc_keep_vcc_on(struct ufs_hba *hba,

0 commit comments

Comments
 (0)