linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: ufs: Don't check UFSHCD_CAP_WB_EN capability in ufshcd_wb_toggle{_flush}
@ 2021-03-19  6:53 Yue Hu
  0 siblings, 0 replies; only message in thread
From: Yue Hu @ 2021-03-19  6:53 UTC (permalink / raw)
  To: martin.petersen, avri.altman, jejb, alim.akhtar, linux-scsi
  Cc: linux-kernel, huyue2, zbestahu

From: Yue Hu <huyue2@yulong.com>

There are several redundant calls to ufshcd_is_wb_allowed() as below:

ufshcd_wb_config()
  |-> ufshcd_is_wb_allowed()
  |-> ufshcd_wb_toggle() -> ufshcd_is_wb_allowed()
  |-> ufshcd_wb_toggle_flush() -> ufshcd_is_wb_allowed()

wb_on_store()
  |-> ufshcd_is_wb_allowed()
  |-> ufshcd_wb_toggle() -> ufshcd_is_wb_allowed()

Considering code handling in wb_on_store(), let's remove needless
ufshcd_is_wb_allowed() in ufshcd_wb_toggle(). Meanwhile, keep the
check in caller ufshcd_devfreq_scale(). Accordingly, also remove
the redundant check in ufshcd_wb_toggle_flush().

Signed-off-by: Yue Hu <huyue2@yulong.com>
---
 drivers/scsi/ufs/ufshcd.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index b6bfc80..ee71cba 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1260,7 +1260,8 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up)
 	/* Enable Write Booster if we have scaled up else disable it */
 	downgrade_write(&hba->clk_scaling_lock);
 	is_writelock = false;
-	ufshcd_wb_toggle(hba, scale_up);
+	if (ufshcd_is_wb_allowed(hba))
+		ufshcd_wb_toggle(hba, scale_up);
 
 out_unprepare:
 	ufshcd_clock_scaling_unprepare(hba, is_writelock);
@@ -5438,9 +5439,6 @@ int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable)
 {
 	int ret;
 
-	if (!ufshcd_is_wb_allowed(hba))
-		return 0;
-
 	if (!(enable ^ hba->dev_info.wb_enabled))
 		return 0;
 
@@ -5477,8 +5475,7 @@ static inline void ufshcd_wb_toggle_flush(struct ufs_hba *hba, bool enable)
 {
 	int ret;
 
-	if (!ufshcd_is_wb_allowed(hba) ||
-	    hba->dev_info.wb_buf_flush_enabled == enable)
+	if (hba->dev_info.wb_buf_flush_enabled == enable)
 		return;
 
 	ret = __ufshcd_wb_toggle(hba, enable, QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-19  6:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19  6:53 [PATCH] scsi: ufs: Don't check UFSHCD_CAP_WB_EN capability in ufshcd_wb_toggle{_flush} Yue Hu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).