diff options
author | Bart Van Assche <bvanassche@acm.org> | 2022-04-20 01:58:04 +0300 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2022-04-26 06:23:03 +0300 |
commit | ad8a647e77294dde3487c86847ca28bd4c8543cd (patch) | |
tree | a45dcc91ebfeb84b2803d5876f8c3c0b0e9b72cc /drivers/scsi/ufs/ufshcd.c | |
parent | 3fb20fcd93fe5a1580355f1ea73f6daed1712f06 (diff) | |
download | linux-ad8a647e77294dde3487c86847ca28bd4c8543cd.tar.xz |
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.org
Tested-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/ufs/ufshcd.c')
-rw-r--r-- | drivers/scsi/ufs/ufshcd.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 254dd1e568dd..ba6b35f36bcc 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -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); } +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, struct device_attribute *attr, const char *buf, size_t count) { - struct ufs_hba *hba = dev_get_drvdata(dev); - unsigned long flags, value; + unsigned long value; if (kstrtoul(buf, 0, &value)) return -EINVAL; - spin_lock_irqsave(hba->host->host_lock, flags); - hba->clk_gating.delay_ms = value; - spin_unlock_irqrestore(hba->host->host_lock, flags); + ufshcd_clkgate_delay_set(dev, value); return count; } |