Commit f9a7fa34 authored by Stanley Chu's avatar Stanley Chu Committed by Martin K. Petersen

scsi: ufs: Refactor cancelling clkscaling works

Cancelling suspend_work and resume_work is only required while suspending
clk-scaling. Move these two invocations into ufshcd_suspend_clkscaling()
function.

Link: https://lore.kernel.org/r/20210120150142.5049-2-stanley.chu@mediatek.comReviewed-by: default avatarCan Guo <cang@codeaurora.org>
Signed-off-by: default avatarStanley Chu <stanley.chu@mediatek.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent b02d51af
...@@ -1503,6 +1503,9 @@ static void ufshcd_suspend_clkscaling(struct ufs_hba *hba) ...@@ -1503,6 +1503,9 @@ static void ufshcd_suspend_clkscaling(struct ufs_hba *hba)
if (!ufshcd_is_clkscaling_supported(hba)) if (!ufshcd_is_clkscaling_supported(hba))
return; return;
cancel_work_sync(&hba->clk_scaling.suspend_work);
cancel_work_sync(&hba->clk_scaling.resume_work);
spin_lock_irqsave(hba->host->host_lock, flags); spin_lock_irqsave(hba->host->host_lock, flags);
if (!hba->clk_scaling.is_suspended) { if (!hba->clk_scaling.is_suspended) {
suspend = true; suspend = true;
...@@ -1564,9 +1567,6 @@ static ssize_t ufshcd_clkscale_enable_store(struct device *dev, ...@@ -1564,9 +1567,6 @@ static ssize_t ufshcd_clkscale_enable_store(struct device *dev,
pm_runtime_get_sync(hba->dev); pm_runtime_get_sync(hba->dev);
ufshcd_hold(hba, false); ufshcd_hold(hba, false);
cancel_work_sync(&hba->clk_scaling.suspend_work);
cancel_work_sync(&hba->clk_scaling.resume_work);
hba->clk_scaling.is_enabled = value; hba->clk_scaling.is_enabled = value;
if (value) { if (value) {
...@@ -5782,11 +5782,8 @@ static void ufshcd_err_handling_prepare(struct ufs_hba *hba) ...@@ -5782,11 +5782,8 @@ static void ufshcd_err_handling_prepare(struct ufs_hba *hba)
ufshcd_vops_resume(hba, pm_op); ufshcd_vops_resume(hba, pm_op);
} else { } else {
ufshcd_hold(hba, false); ufshcd_hold(hba, false);
if (hba->clk_scaling.is_enabled) { if (hba->clk_scaling.is_enabled)
cancel_work_sync(&hba->clk_scaling.suspend_work);
cancel_work_sync(&hba->clk_scaling.resume_work);
ufshcd_suspend_clkscaling(hba); ufshcd_suspend_clkscaling(hba);
}
down_write(&hba->clk_scaling_lock); down_write(&hba->clk_scaling_lock);
hba->clk_scaling.is_allowed = false; hba->clk_scaling.is_allowed = false;
up_write(&hba->clk_scaling_lock); up_write(&hba->clk_scaling_lock);
...@@ -8698,11 +8695,9 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) ...@@ -8698,11 +8695,9 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
ufshcd_hold(hba, false); ufshcd_hold(hba, false);
hba->clk_gating.is_suspended = true; hba->clk_gating.is_suspended = true;
if (hba->clk_scaling.is_enabled) { if (hba->clk_scaling.is_enabled)
cancel_work_sync(&hba->clk_scaling.suspend_work);
cancel_work_sync(&hba->clk_scaling.resume_work);
ufshcd_suspend_clkscaling(hba); ufshcd_suspend_clkscaling(hba);
}
down_write(&hba->clk_scaling_lock); down_write(&hba->clk_scaling_lock);
hba->clk_scaling.is_allowed = false; hba->clk_scaling.is_allowed = false;
up_write(&hba->clk_scaling_lock); up_write(&hba->clk_scaling_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment