scsi: ufs: Reduce power management code duplication
Move the dev_get_drvdata() calls into the ufshcd_{system,runtime}_*() functions. Remove ufshcd_runtime_idle() since it is empty. This patch does not change any functionality. Link: https://lore.kernel.org/r/20210722033439.26550-3-bvanassche@acm.org Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Stanley Chu <stanley.chu@mediatek.com> Cc: Can Guo <cang@codeaurora.org> Cc: Asutosh Das <asutoshd@codeaurora.org> Reviewed-by: Avri Altman <avri.altman@wdc.com> Reviewed-by: Bean Huo <beanhuo@micron.com> Reviewed-by: Daejun Park <daejun7.park@samsung.com> Reviewed-by: Stanley Chu <stanley.chu@mediatek.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
d3d9c45702
commit
f1ecbe1e54
|
@ -318,11 +318,8 @@ static int cdns_ufs_pltfrm_remove(struct platform_device *pdev)
|
|||
}
|
||||
|
||||
static const struct dev_pm_ops cdns_ufs_dev_pm_ops = {
|
||||
.suspend = ufshcd_pltfrm_suspend,
|
||||
.resume = ufshcd_pltfrm_resume,
|
||||
.runtime_suspend = ufshcd_pltfrm_runtime_suspend,
|
||||
.runtime_resume = ufshcd_pltfrm_runtime_resume,
|
||||
.runtime_idle = ufshcd_pltfrm_runtime_idle,
|
||||
SET_SYSTEM_SLEEP_PM_OPS(ufshcd_system_suspend, ufshcd_system_resume)
|
||||
SET_RUNTIME_PM_OPS(ufshcd_runtime_suspend, ufshcd_runtime_resume, NULL)
|
||||
.prepare = ufshcd_suspend_prepare,
|
||||
.complete = ufshcd_resume_complete,
|
||||
};
|
||||
|
|
|
@ -23,31 +23,6 @@ static int tc_type = TC_G210_INV;
|
|||
module_param(tc_type, int, 0);
|
||||
MODULE_PARM_DESC(tc_type, "Test Chip Type (20 = 20-bit, 40 = 40-bit)");
|
||||
|
||||
static int tc_dwc_g210_pci_suspend(struct device *dev)
|
||||
{
|
||||
return ufshcd_system_suspend(dev_get_drvdata(dev));
|
||||
}
|
||||
|
||||
static int tc_dwc_g210_pci_resume(struct device *dev)
|
||||
{
|
||||
return ufshcd_system_resume(dev_get_drvdata(dev));
|
||||
}
|
||||
|
||||
static int tc_dwc_g210_pci_runtime_suspend(struct device *dev)
|
||||
{
|
||||
return ufshcd_runtime_suspend(dev_get_drvdata(dev));
|
||||
}
|
||||
|
||||
static int tc_dwc_g210_pci_runtime_resume(struct device *dev)
|
||||
{
|
||||
return ufshcd_runtime_resume(dev_get_drvdata(dev));
|
||||
}
|
||||
|
||||
static int tc_dwc_g210_pci_runtime_idle(struct device *dev)
|
||||
{
|
||||
return ufshcd_runtime_idle(dev_get_drvdata(dev));
|
||||
}
|
||||
|
||||
/*
|
||||
* struct ufs_hba_dwc_vops - UFS DWC specific variant operations
|
||||
*/
|
||||
|
@ -143,11 +118,8 @@ tc_dwc_g210_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
|||
}
|
||||
|
||||
static const struct dev_pm_ops tc_dwc_g210_pci_pm_ops = {
|
||||
.suspend = tc_dwc_g210_pci_suspend,
|
||||
.resume = tc_dwc_g210_pci_resume,
|
||||
.runtime_suspend = tc_dwc_g210_pci_runtime_suspend,
|
||||
.runtime_resume = tc_dwc_g210_pci_runtime_resume,
|
||||
.runtime_idle = tc_dwc_g210_pci_runtime_idle,
|
||||
SET_SYSTEM_SLEEP_PM_OPS(ufshcd_system_suspend, ufshcd_system_resume)
|
||||
SET_RUNTIME_PM_OPS(ufshcd_runtime_suspend, ufshcd_runtime_resume, NULL)
|
||||
.prepare = ufshcd_suspend_prepare,
|
||||
.complete = ufshcd_resume_complete,
|
||||
};
|
||||
|
|
|
@ -84,11 +84,8 @@ static int tc_dwc_g210_pltfm_remove(struct platform_device *pdev)
|
|||
}
|
||||
|
||||
static const struct dev_pm_ops tc_dwc_g210_pltfm_pm_ops = {
|
||||
.suspend = ufshcd_pltfrm_suspend,
|
||||
.resume = ufshcd_pltfrm_resume,
|
||||
.runtime_suspend = ufshcd_pltfrm_runtime_suspend,
|
||||
.runtime_resume = ufshcd_pltfrm_runtime_resume,
|
||||
.runtime_idle = ufshcd_pltfrm_runtime_idle,
|
||||
SET_SYSTEM_SLEEP_PM_OPS(ufshcd_system_suspend, ufshcd_system_resume)
|
||||
SET_RUNTIME_PM_OPS(ufshcd_runtime_suspend, ufshcd_runtime_resume, NULL)
|
||||
};
|
||||
|
||||
static struct platform_driver tc_dwc_g210_pltfm_driver = {
|
||||
|
|
|
@ -1287,11 +1287,8 @@ static const struct of_device_id exynos_ufs_of_match[] = {
|
|||
};
|
||||
|
||||
static const struct dev_pm_ops exynos_ufs_pm_ops = {
|
||||
.suspend = ufshcd_pltfrm_suspend,
|
||||
.resume = ufshcd_pltfrm_resume,
|
||||
.runtime_suspend = ufshcd_pltfrm_runtime_suspend,
|
||||
.runtime_resume = ufshcd_pltfrm_runtime_resume,
|
||||
.runtime_idle = ufshcd_pltfrm_runtime_idle,
|
||||
SET_SYSTEM_SLEEP_PM_OPS(ufshcd_system_suspend, ufshcd_system_resume)
|
||||
SET_RUNTIME_PM_OPS(ufshcd_runtime_suspend, ufshcd_runtime_resume, NULL)
|
||||
.prepare = ufshcd_suspend_prepare,
|
||||
.complete = ufshcd_resume_complete,
|
||||
};
|
||||
|
|
|
@ -572,11 +572,8 @@ static int ufs_hisi_remove(struct platform_device *pdev)
|
|||
}
|
||||
|
||||
static const struct dev_pm_ops ufs_hisi_pm_ops = {
|
||||
.suspend = ufshcd_pltfrm_suspend,
|
||||
.resume = ufshcd_pltfrm_resume,
|
||||
.runtime_suspend = ufshcd_pltfrm_runtime_suspend,
|
||||
.runtime_resume = ufshcd_pltfrm_runtime_resume,
|
||||
.runtime_idle = ufshcd_pltfrm_runtime_idle,
|
||||
SET_SYSTEM_SLEEP_PM_OPS(ufshcd_system_suspend, ufshcd_system_resume)
|
||||
SET_RUNTIME_PM_OPS(ufshcd_runtime_suspend, ufshcd_runtime_resume, NULL)
|
||||
.prepare = ufshcd_suspend_prepare,
|
||||
.complete = ufshcd_resume_complete,
|
||||
};
|
||||
|
|
|
@ -1140,11 +1140,8 @@ static int ufs_mtk_remove(struct platform_device *pdev)
|
|||
}
|
||||
|
||||
static const struct dev_pm_ops ufs_mtk_pm_ops = {
|
||||
.suspend = ufshcd_pltfrm_suspend,
|
||||
.resume = ufshcd_pltfrm_resume,
|
||||
.runtime_suspend = ufshcd_pltfrm_runtime_suspend,
|
||||
.runtime_resume = ufshcd_pltfrm_runtime_resume,
|
||||
.runtime_idle = ufshcd_pltfrm_runtime_idle,
|
||||
SET_SYSTEM_SLEEP_PM_OPS(ufshcd_system_suspend, ufshcd_system_resume)
|
||||
SET_RUNTIME_PM_OPS(ufshcd_runtime_suspend, ufshcd_runtime_resume, NULL)
|
||||
.prepare = ufshcd_suspend_prepare,
|
||||
.complete = ufshcd_resume_complete,
|
||||
};
|
||||
|
|
|
@ -1546,11 +1546,8 @@ MODULE_DEVICE_TABLE(acpi, ufs_qcom_acpi_match);
|
|||
#endif
|
||||
|
||||
static const struct dev_pm_ops ufs_qcom_pm_ops = {
|
||||
.suspend = ufshcd_pltfrm_suspend,
|
||||
.resume = ufshcd_pltfrm_resume,
|
||||
.runtime_suspend = ufshcd_pltfrm_runtime_suspend,
|
||||
.runtime_resume = ufshcd_pltfrm_runtime_resume,
|
||||
.runtime_idle = ufshcd_pltfrm_runtime_idle,
|
||||
SET_SYSTEM_SLEEP_PM_OPS(ufshcd_system_suspend, ufshcd_system_resume)
|
||||
SET_RUNTIME_PM_OPS(ufshcd_runtime_suspend, ufshcd_runtime_resume, NULL)
|
||||
.prepare = ufshcd_suspend_prepare,
|
||||
.complete = ufshcd_resume_complete,
|
||||
};
|
||||
|
|
|
@ -385,48 +385,6 @@ static struct ufs_hba_variant_ops ufs_intel_lkf_hba_vops = {
|
|||
.device_reset = ufs_intel_device_reset,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
/**
|
||||
* ufshcd_pci_suspend - suspend power management function
|
||||
* @dev: pointer to PCI device handle
|
||||
*
|
||||
* Returns 0 if successful
|
||||
* Returns non-zero otherwise
|
||||
*/
|
||||
static int ufshcd_pci_suspend(struct device *dev)
|
||||
{
|
||||
return ufshcd_system_suspend(dev_get_drvdata(dev));
|
||||
}
|
||||
|
||||
/**
|
||||
* ufshcd_pci_resume - resume power management function
|
||||
* @dev: pointer to PCI device handle
|
||||
*
|
||||
* Returns 0 if successful
|
||||
* Returns non-zero otherwise
|
||||
*/
|
||||
static int ufshcd_pci_resume(struct device *dev)
|
||||
{
|
||||
return ufshcd_system_resume(dev_get_drvdata(dev));
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_PM_SLEEP */
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int ufshcd_pci_runtime_suspend(struct device *dev)
|
||||
{
|
||||
return ufshcd_runtime_suspend(dev_get_drvdata(dev));
|
||||
}
|
||||
static int ufshcd_pci_runtime_resume(struct device *dev)
|
||||
{
|
||||
return ufshcd_runtime_resume(dev_get_drvdata(dev));
|
||||
}
|
||||
static int ufshcd_pci_runtime_idle(struct device *dev)
|
||||
{
|
||||
return ufshcd_runtime_idle(dev_get_drvdata(dev));
|
||||
}
|
||||
#endif /* !CONFIG_PM */
|
||||
|
||||
/**
|
||||
* ufshcd_pci_shutdown - main function to put the controller in reset state
|
||||
* @pdev: pointer to PCI device handle
|
||||
|
@ -510,10 +468,8 @@ ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
|||
}
|
||||
|
||||
static const struct dev_pm_ops ufshcd_pci_pm_ops = {
|
||||
SET_RUNTIME_PM_OPS(ufshcd_pci_runtime_suspend,
|
||||
ufshcd_pci_runtime_resume,
|
||||
ufshcd_pci_runtime_idle)
|
||||
SET_SYSTEM_SLEEP_PM_OPS(ufshcd_pci_suspend, ufshcd_pci_resume)
|
||||
SET_SYSTEM_SLEEP_PM_OPS(ufshcd_system_suspend, ufshcd_system_resume)
|
||||
SET_RUNTIME_PM_OPS(ufshcd_runtime_suspend, ufshcd_runtime_resume, NULL)
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
.prepare = ufshcd_suspend_prepare,
|
||||
.complete = ufshcd_resume_complete,
|
||||
|
|
|
@ -170,53 +170,6 @@ out:
|
|||
return err;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
/**
|
||||
* ufshcd_pltfrm_suspend - suspend power management function
|
||||
* @dev: pointer to device handle
|
||||
*
|
||||
* Returns 0 if successful
|
||||
* Returns non-zero otherwise
|
||||
*/
|
||||
int ufshcd_pltfrm_suspend(struct device *dev)
|
||||
{
|
||||
return ufshcd_system_suspend(dev_get_drvdata(dev));
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ufshcd_pltfrm_suspend);
|
||||
|
||||
/**
|
||||
* ufshcd_pltfrm_resume - resume power management function
|
||||
* @dev: pointer to device handle
|
||||
*
|
||||
* Returns 0 if successful
|
||||
* Returns non-zero otherwise
|
||||
*/
|
||||
int ufshcd_pltfrm_resume(struct device *dev)
|
||||
{
|
||||
return ufshcd_system_resume(dev_get_drvdata(dev));
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ufshcd_pltfrm_resume);
|
||||
|
||||
int ufshcd_pltfrm_runtime_suspend(struct device *dev)
|
||||
{
|
||||
return ufshcd_runtime_suspend(dev_get_drvdata(dev));
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ufshcd_pltfrm_runtime_suspend);
|
||||
|
||||
int ufshcd_pltfrm_runtime_resume(struct device *dev)
|
||||
{
|
||||
return ufshcd_runtime_resume(dev_get_drvdata(dev));
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ufshcd_pltfrm_runtime_resume);
|
||||
|
||||
int ufshcd_pltfrm_runtime_idle(struct device *dev)
|
||||
{
|
||||
return ufshcd_runtime_idle(dev_get_drvdata(dev));
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ufshcd_pltfrm_runtime_idle);
|
||||
|
||||
#endif /* CONFIG_PM */
|
||||
|
||||
void ufshcd_pltfrm_shutdown(struct platform_device *pdev)
|
||||
{
|
||||
ufshcd_shutdown((struct ufs_hba *)platform_get_drvdata(pdev));
|
||||
|
|
|
@ -33,22 +33,4 @@ int ufshcd_pltfrm_init(struct platform_device *pdev,
|
|||
const struct ufs_hba_variant_ops *vops);
|
||||
void ufshcd_pltfrm_shutdown(struct platform_device *pdev);
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
|
||||
int ufshcd_pltfrm_suspend(struct device *dev);
|
||||
int ufshcd_pltfrm_resume(struct device *dev);
|
||||
int ufshcd_pltfrm_runtime_suspend(struct device *dev);
|
||||
int ufshcd_pltfrm_runtime_resume(struct device *dev);
|
||||
int ufshcd_pltfrm_runtime_idle(struct device *dev);
|
||||
|
||||
#else /* !CONFIG_PM */
|
||||
|
||||
#define ufshcd_pltfrm_suspend NULL
|
||||
#define ufshcd_pltfrm_resume NULL
|
||||
#define ufshcd_pltfrm_runtime_suspend NULL
|
||||
#define ufshcd_pltfrm_runtime_resume NULL
|
||||
#define ufshcd_pltfrm_runtime_idle NULL
|
||||
|
||||
#endif /* CONFIG_PM */
|
||||
|
||||
#endif /* UFSHCD_PLTFRM_H_ */
|
||||
|
|
|
@ -9278,15 +9278,17 @@ out:
|
|||
}
|
||||
|
||||
/**
|
||||
* ufshcd_system_suspend - system suspend routine
|
||||
* @hba: per adapter instance
|
||||
* ufshcd_system_suspend - system suspend callback
|
||||
* @dev: Device associated with the UFS controller.
|
||||
*
|
||||
* Check the description of ufshcd_suspend() function for more details.
|
||||
* Executed before putting the system into a sleep state in which the contents
|
||||
* of main memory are preserved.
|
||||
*
|
||||
* Returns 0 for success and non-zero for failure
|
||||
*/
|
||||
int ufshcd_system_suspend(struct ufs_hba *hba)
|
||||
int ufshcd_system_suspend(struct device *dev)
|
||||
{
|
||||
struct ufs_hba *hba = dev_get_drvdata(dev);
|
||||
int ret = 0;
|
||||
ktime_t start = ktime_get();
|
||||
|
||||
|
@ -9303,16 +9305,19 @@ out:
|
|||
EXPORT_SYMBOL(ufshcd_system_suspend);
|
||||
|
||||
/**
|
||||
* ufshcd_system_resume - system resume routine
|
||||
* @hba: per adapter instance
|
||||
* ufshcd_system_resume - system resume callback
|
||||
* @dev: Device associated with the UFS controller.
|
||||
*
|
||||
* Executed after waking the system up from a sleep state in which the contents
|
||||
* of main memory were preserved.
|
||||
*
|
||||
* Returns 0 for success and non-zero for failure
|
||||
*/
|
||||
|
||||
int ufshcd_system_resume(struct ufs_hba *hba)
|
||||
int ufshcd_system_resume(struct device *dev)
|
||||
{
|
||||
int ret = 0;
|
||||
struct ufs_hba *hba = dev_get_drvdata(dev);
|
||||
ktime_t start = ktime_get();
|
||||
int ret = 0;
|
||||
|
||||
if (pm_runtime_suspended(hba->dev))
|
||||
goto out;
|
||||
|
@ -9329,15 +9334,16 @@ out:
|
|||
EXPORT_SYMBOL(ufshcd_system_resume);
|
||||
|
||||
/**
|
||||
* ufshcd_runtime_suspend - runtime suspend routine
|
||||
* @hba: per adapter instance
|
||||
* ufshcd_runtime_suspend - runtime suspend callback
|
||||
* @dev: Device associated with the UFS controller.
|
||||
*
|
||||
* Check the description of ufshcd_suspend() function for more details.
|
||||
*
|
||||
* Returns 0 for success and non-zero for failure
|
||||
*/
|
||||
int ufshcd_runtime_suspend(struct ufs_hba *hba)
|
||||
int ufshcd_runtime_suspend(struct device *dev)
|
||||
{
|
||||
struct ufs_hba *hba = dev_get_drvdata(dev);
|
||||
int ret;
|
||||
ktime_t start = ktime_get();
|
||||
|
||||
|
@ -9352,7 +9358,7 @@ EXPORT_SYMBOL(ufshcd_runtime_suspend);
|
|||
|
||||
/**
|
||||
* ufshcd_runtime_resume - runtime resume routine
|
||||
* @hba: per adapter instance
|
||||
* @dev: Device associated with the UFS controller.
|
||||
*
|
||||
* This function basically brings controller
|
||||
* to active state. Following operations are done in this function:
|
||||
|
@ -9360,8 +9366,9 @@ EXPORT_SYMBOL(ufshcd_runtime_suspend);
|
|||
* 1. Turn on all the controller related clocks
|
||||
* 2. Turn ON VCC rail
|
||||
*/
|
||||
int ufshcd_runtime_resume(struct ufs_hba *hba)
|
||||
int ufshcd_runtime_resume(struct device *dev)
|
||||
{
|
||||
struct ufs_hba *hba = dev_get_drvdata(dev);
|
||||
int ret;
|
||||
ktime_t start = ktime_get();
|
||||
|
||||
|
@ -9374,12 +9381,6 @@ int ufshcd_runtime_resume(struct ufs_hba *hba)
|
|||
}
|
||||
EXPORT_SYMBOL(ufshcd_runtime_resume);
|
||||
|
||||
int ufshcd_runtime_idle(struct ufs_hba *hba)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(ufshcd_runtime_idle);
|
||||
|
||||
/**
|
||||
* ufshcd_shutdown - shutdown routine
|
||||
* @hba: per adapter instance
|
||||
|
|
|
@ -1030,11 +1030,10 @@ static inline u8 ufshcd_wb_get_query_index(struct ufs_hba *hba)
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern int ufshcd_runtime_suspend(struct ufs_hba *hba);
|
||||
extern int ufshcd_runtime_resume(struct ufs_hba *hba);
|
||||
extern int ufshcd_runtime_idle(struct ufs_hba *hba);
|
||||
extern int ufshcd_system_suspend(struct ufs_hba *hba);
|
||||
extern int ufshcd_system_resume(struct ufs_hba *hba);
|
||||
extern int ufshcd_runtime_suspend(struct device *dev);
|
||||
extern int ufshcd_runtime_resume(struct device *dev);
|
||||
extern int ufshcd_system_suspend(struct device *dev);
|
||||
extern int ufshcd_system_resume(struct device *dev);
|
||||
extern int ufshcd_shutdown(struct ufs_hba *hba);
|
||||
extern int ufshcd_dme_configure_adapt(struct ufs_hba *hba,
|
||||
int agreed_gear,
|
||||
|
|
Loading…
Reference in New Issue