Commit ad8a647e authored by Bart Van Assche's avatar Bart Van Assche Committed by Martin K. Petersen

scsi: ufs: Introduce ufshcd_clkgate_delay_set()

Since the code to modify delay_ms while holding the host lock occurs twice,
introduce a function that performs this action.

Link: https://lore.kernel.org/r/20220419225811.4127248-22-bvanassche@acm.orgTested-by: default avatarBean Huo <beanhuo@micron.com>
Reviewed-by: default avatarAvri Altman <avri.altman@wdc.com>
Reviewed-by: default avatarBean Huo <beanhuo@micron.com>
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 3fb20fcd
...@@ -857,7 +857,6 @@ static int ufs_mtk_pre_link(struct ufs_hba *hba) ...@@ -857,7 +857,6 @@ static int ufs_mtk_pre_link(struct ufs_hba *hba)
static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba) static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba)
{ {
unsigned long flags;
u32 ah_ms; u32 ah_ms;
if (ufshcd_is_clkgating_allowed(hba)) { if (ufshcd_is_clkgating_allowed(hba)) {
...@@ -866,9 +865,7 @@ static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba) ...@@ -866,9 +865,7 @@ static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba)
hba->ahit); hba->ahit);
else else
ah_ms = 10; ah_ms = 10;
spin_lock_irqsave(hba->host->host_lock, flags); ufshcd_clkgate_delay_set(hba->dev, ah_ms + 5);
hba->clk_gating.delay_ms = ah_ms + 5;
spin_unlock_irqrestore(hba->host->host_lock, flags);
} }
} }
......
...@@ -1864,18 +1864,26 @@ static ssize_t ufshcd_clkgate_delay_show(struct device *dev, ...@@ -1864,18 +1864,26 @@ static ssize_t ufshcd_clkgate_delay_show(struct device *dev,
return sysfs_emit(buf, "%lu\n", hba->clk_gating.delay_ms); return sysfs_emit(buf, "%lu\n", hba->clk_gating.delay_ms);
} }
void ufshcd_clkgate_delay_set(struct device *dev, unsigned long value)
{
struct ufs_hba *hba = dev_get_drvdata(dev);
unsigned long flags;
spin_lock_irqsave(hba->host->host_lock, flags);
hba->clk_gating.delay_ms = value;
spin_unlock_irqrestore(hba->host->host_lock, flags);
}
EXPORT_SYMBOL_GPL(ufshcd_clkgate_delay_set);
static ssize_t ufshcd_clkgate_delay_store(struct device *dev, static ssize_t ufshcd_clkgate_delay_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
struct ufs_hba *hba = dev_get_drvdata(dev); unsigned long value;
unsigned long flags, value;
if (kstrtoul(buf, 0, &value)) if (kstrtoul(buf, 0, &value))
return -EINVAL; return -EINVAL;
spin_lock_irqsave(hba->host->host_lock, flags); ufshcd_clkgate_delay_set(dev, value);
hba->clk_gating.delay_ms = value;
spin_unlock_irqrestore(hba->host->host_lock, flags);
return count; return count;
} }
......
...@@ -1184,6 +1184,8 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, ...@@ -1184,6 +1184,8 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
int ufshcd_hold(struct ufs_hba *hba, bool async); int ufshcd_hold(struct ufs_hba *hba, bool async);
void ufshcd_release(struct ufs_hba *hba); void ufshcd_release(struct ufs_hba *hba);
void ufshcd_clkgate_delay_set(struct device *dev, unsigned long value);
void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id, void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,
int *desc_length); int *desc_length);
......
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