[PATCH 20/20] usb/gadget/udc: snps: Use pm_ptr() macro

Paul Cercueil paul at crapouillou.net
Thu Sep 3 07:25:54 EDT 2020


Use the newly introduced pm_ptr() macro, and mark the suspend/resume
functions __maybe_unused. These functions can then be moved outside the
CONFIG_PM_SUSPEND block, and the compiler can then process them and
detect build failures independently of the config. If unused, they will
simply be discarded by the compiler.

Signed-off-by: Paul Cercueil <paul at crapouillou.net>
---
 drivers/usb/gadget/udc/snps_udc_plat.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/gadget/udc/snps_udc_plat.c b/drivers/usb/gadget/udc/snps_udc_plat.c
index 32f1d3e90c26..6b8f08287c84 100644
--- a/drivers/usb/gadget/udc/snps_udc_plat.c
+++ b/drivers/usb/gadget/udc/snps_udc_plat.c
@@ -257,8 +257,7 @@ static int udc_plat_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int udc_plat_suspend(struct device *dev)
+static int __maybe_unused udc_plat_suspend(struct device *dev)
 {
 	struct udc *udc;
 
@@ -275,7 +274,7 @@ static int udc_plat_suspend(struct device *dev)
 	return 0;
 }
 
-static int udc_plat_resume(struct device *dev)
+static int __maybe_unused udc_plat_resume(struct device *dev)
 {
 	struct udc *udc;
 	int ret;
@@ -302,11 +301,8 @@ static int udc_plat_resume(struct device *dev)
 
 	return 0;
 }
-static const struct dev_pm_ops udc_plat_pm_ops = {
-	.suspend	= udc_plat_suspend,
-	.resume		= udc_plat_resume,
-};
-#endif
+
+static SIMPLE_DEV_PM_OPS(plat_pm_ops, udc_plat_suspend, udc_plat_resume);
 
 #if defined(CONFIG_OF)
 static const struct of_device_id of_udc_match[] = {
@@ -324,9 +320,7 @@ static struct platform_driver udc_plat_driver = {
 	.driver		= {
 		.name	= "snps-udc-plat",
 		.of_match_table = of_match_ptr(of_udc_match),
-#ifdef CONFIG_PM_SLEEP
-		.pm	= &udc_plat_pm_ops,
-#endif
+		.pm	= pm_ptr(&udc_plat_pm_ops),
 	},
 };
 module_platform_driver(udc_plat_driver);
-- 
2.28.0




More information about the linux-arm-kernel mailing list