The Function names were changed clearly, and the location of the
comments was modified and added properly.
In addition, the conditional test of the toggle functions was
different, so it was modified.
Unnecessary logs were removed and modified appropriately.
diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c
index 0a088b47d557..6253606b93b4 100644
--- a/drivers/ufs/core/ufs-sysfs.c
+++ b/drivers/ufs/core/ufs-sysfs.c
@@ -230,7 +230,7 @@ static ssize_t wb_on_store(struct device *dev, struct device_attribute *attr,
* If the platform supports UFSHCD_CAP_CLK_SCALING, turn WB
* on/off will be done while clock scaling up/down.
*/
- dev_warn(dev, "To control WB through wb_on is not allowed!\n");
+ dev_warn(dev, "It is not allowed to control WB!\n");
static void ufshcd_scsi_unblock_requests(struct ufs_hba *hba)
@@ -1289,9 +1288,10 @@ 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;
+
+ /* Enable Write Booster if we have scaled up else disable it */
ufshcd_wb_toggle(hba, scale_up);
out_unprepare:
@@ -5715,6 +5715,9 @@ static int __ufshcd_wb_toggle(struct ufs_hba *hba, bool set, enum flag_idn idn)
enum query_opcode opcode = set ? UPIU_QUERY_OPCODE_SET_FLAG :
UPIU_QUERY_OPCODE_CLEAR_FLAG;
+ if (!ufshcd_is_wb_allowed(hba))
+ return -EPERM;
+
- if (!(enable ^ hba->dev_info.wb_enabled))
+ if (hba->dev_info.wb_enabled == enable)
return 0;
- dev_info(hba->dev, "%s Write Booster %s\n",
- __func__, enable ? "enabled" : "disabled");
- ret = __ufshcd_wb_toggle(hba, set,
- QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8);
- if (ret) {
- dev_err(hba->dev, "%s: WB-Buf Flush during H8 %s failed: %d\n",
- __func__, set ? "enable" : "disable", ret);
- return;
- }
- dev_dbg(hba->dev, "%s WB-Buf Flush during H8 %s\n",
- __func__, set ? "enabled" : "disabled");
+ ret = __ufshcd_wb_toggle(hba, enable,
+ QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8);
+ if (ret)
+ dev_err(hba->dev, "%s: failed to %s WB buf flush during H8 %d\n",
+ __func__, enable ? "enable" : "disable", ret);