scsi: ufs: Introduce ufshcd_is_auto_hibern8_supported()
The checking of Auto-Hibernation support is used in many places in the driver, thus re-factor it as ufshcd_is_auto_hibern8_supported() to make code more clean. Signed-off-by: Stanley Chu <stanley.chu@mediatek.com> Reviewed-by: Bean Huo <beanhuo@micron.com> Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com> Reviewed-by: Avri Altman <Avri.Altman@wdc.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
a1b6fb947f
commit
ee5f1042b2
@ -122,7 +122,7 @@ static void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit)
|
|||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (!(hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT))
|
if (!ufshcd_is_auto_hibern8_supported(hba))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
spin_lock_irqsave(hba->host->host_lock, flags);
|
spin_lock_irqsave(hba->host->host_lock, flags);
|
||||||
@ -164,7 +164,7 @@ static ssize_t auto_hibern8_show(struct device *dev,
|
|||||||
{
|
{
|
||||||
struct ufs_hba *hba = dev_get_drvdata(dev);
|
struct ufs_hba *hba = dev_get_drvdata(dev);
|
||||||
|
|
||||||
if (!(hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT))
|
if (!ufshcd_is_auto_hibern8_supported(hba))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
return snprintf(buf, PAGE_SIZE, "%d\n", ufshcd_ahit_to_us(hba->ahit));
|
return snprintf(buf, PAGE_SIZE, "%d\n", ufshcd_ahit_to_us(hba->ahit));
|
||||||
@ -177,7 +177,7 @@ static ssize_t auto_hibern8_store(struct device *dev,
|
|||||||
struct ufs_hba *hba = dev_get_drvdata(dev);
|
struct ufs_hba *hba = dev_get_drvdata(dev);
|
||||||
unsigned int timer;
|
unsigned int timer;
|
||||||
|
|
||||||
if (!(hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT))
|
if (!ufshcd_is_auto_hibern8_supported(hba))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
if (kstrtouint(buf, 0, &timer))
|
if (kstrtouint(buf, 0, &timer))
|
||||||
|
@ -3907,7 +3907,7 @@ static void ufshcd_auto_hibern8_enable(struct ufs_hba *hba)
|
|||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (!(hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT) || !hba->ahit)
|
if (!ufshcd_is_auto_hibern8_supported(hba) || !hba->ahit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
spin_lock_irqsave(hba->host->host_lock, flags);
|
spin_lock_irqsave(hba->host->host_lock, flags);
|
||||||
@ -8312,7 +8312,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
|
|||||||
UIC_LINK_HIBERN8_STATE);
|
UIC_LINK_HIBERN8_STATE);
|
||||||
|
|
||||||
/* Set the default auto-hiberate idle timer value to 150 ms */
|
/* Set the default auto-hiberate idle timer value to 150 ms */
|
||||||
if (hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT) {
|
if (ufshcd_is_auto_hibern8_supported(hba)) {
|
||||||
hba->ahit = FIELD_PREP(UFSHCI_AHIBERN8_TIMER_MASK, 150) |
|
hba->ahit = FIELD_PREP(UFSHCI_AHIBERN8_TIMER_MASK, 150) |
|
||||||
FIELD_PREP(UFSHCI_AHIBERN8_SCALE_MASK, 3);
|
FIELD_PREP(UFSHCI_AHIBERN8_SCALE_MASK, 3);
|
||||||
}
|
}
|
||||||
|
@ -740,6 +740,11 @@ return true;
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool ufshcd_is_auto_hibern8_supported(struct ufs_hba *hba)
|
||||||
|
{
|
||||||
|
return (hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT);
|
||||||
|
}
|
||||||
|
|
||||||
#define ufshcd_writel(hba, val, reg) \
|
#define ufshcd_writel(hba, val, reg) \
|
||||||
writel((val), (hba)->mmio_base + (reg))
|
writel((val), (hba)->mmio_base + (reg))
|
||||||
#define ufshcd_readl(hba, reg) \
|
#define ufshcd_readl(hba, reg) \
|
||||||
|
Loading…
Reference in New Issue
Block a user