Skip to contentSkip to conversation

usb: dwc3: qcom: use modern PM macros

PATCH In review Arnd Bergmann 3 participants 3 messages Apr 23, 2025 – Apr 24, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: dwc3: qcom: use modern PM macros

From: Arnd Bergmann <[email protected]>

The use of the old SET_SYSTEM_SLEEP_PM_OPS/SET_RUNTIME_PM_OPS macros without __maybe_unused annotations causes warnings when build testing without CONFIG_PM:

drivers/usb/dwc3/dwc3-qcom.c:421:12: error: unused function 'dwc3_qcom_suspend' [-Werror,-Wunused-function]
421 | static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup)

      |            ^~~~~~~~~~~~~~~~~

drivers/usb/dwc3/dwc3-qcom.c:457:12: error: unused function 'dwc3_qcom_resume' [-Werror,-Wunused-function]
457 | static int dwc3_qcom_resume(struct dwc3_qcom *qcom, bool wakeup)

Change these to the modern SYSTEM_SLEEP_PM_OPS/RUNTIME_PM_OPS/pm_ptr macros, which avoids the warnings and improves readability at the same time.

Fixes 1881a32fe14d ("usb: dwc3: qcom: Transition to flattened model")
---
 drivers/usb/dwc3/dwc3-qcom.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +5 -12
index d512002e1e88..cbba11589cd0 100644
@@ -832,7 +832,6 @@ static void dwc3_qcom_remove(struct platform_device *pdev)
 	reset_control_assert(qcom->resets);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int dwc3_qcom_pm_suspend(struct device *dev)
 {
 	struct dwc3 *dwc = dev_get_drvdata(dev);
@@ -886,12 +885,7 @@ static int dwc3_qcom_prepare(struct device *dev)
 
 	return dwc3_pm_prepare(dwc);
 }
-#else
-#define dwc3_qcom_complete NULL
-#define dwc3_qcom_prepare NULL
-#endif /* CONFIG_PM_SLEEP */
 
-#ifdef CONFIG_PM
 static int dwc3_qcom_runtime_suspend(struct device *dev)
 {
 	struct dwc3 *dwc = dev_get_drvdata(dev);
@@ -922,14 +916,13 @@ static int dwc3_qcom_runtime_idle(struct device *dev)
 {
 	return dwc3_runtime_idle(dev_get_drvdata(dev));
 }
-#endif /* CONFIG_PM */
 
 static const struct dev_pm_ops dwc3_qcom_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(dwc3_qcom_pm_suspend, dwc3_qcom_pm_resume)
-	SET_RUNTIME_PM_OPS(dwc3_qcom_runtime_suspend, dwc3_qcom_runtime_resume,
+	SYSTEM_SLEEP_PM_OPS(dwc3_qcom_pm_suspend, dwc3_qcom_pm_resume)
+	RUNTIME_PM_OPS(dwc3_qcom_runtime_suspend, dwc3_qcom_runtime_resume,
 			   dwc3_qcom_runtime_idle)
-	.complete = dwc3_qcom_complete,
-	.prepare = dwc3_qcom_prepare,
+	.complete = pm_sleep_ptr(dwc3_qcom_complete),
+	.prepare = pm_sleep_ptr(dwc3_qcom_prepare),
 };
 
 static const struct of_device_id dwc3_qcom_of_match[] = {
@@ -943,7 +936,7 @@ static struct platform_driver dwc3_qcom_driver = {
 	.remove		= dwc3_qcom_remove,
 	.driver		= {
 		.name	= "dwc3-qcom",
-		.pm	= &dwc3_qcom_dev_pm_ops,
+		.pm	= pm_ptr(&dwc3_qcom_dev_pm_ops),
 		.of_match_table	= dwc3_qcom_of_match,
 	},
 };
Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The use of the old SET_SYSTEM_SLEEP_PM_OPS/SET_RUNTIME_PM_OPS macros without __maybe_unused annotations causes warnings when build testing without CONFIG_PM:

drivers/usb/dwc3/dwc3-qcom.c:421:12: error: unused function 'dwc3_qcom_suspend' [-Werror,-Wunused-function]
421 | static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup)

      |            ^~~~~~~~~~~~~~~~~

drivers/usb/dwc3/dwc3-qcom.c:457:12: error: unused function 'dwc3_qcom_resume' [-Werror,-Wunused-function]
457 | static int dwc3_qcom_resume(struct dwc3_qcom *qcom, bool wakeup)

Quoted 6 lines

Change these to the modern SYSTEM_SLEEP_PM_OPS/RUNTIME_PM_OPS/pm_ptr macros, which avoids the warnings and improves readability at the same time.

Fixes 1881a32fe14d ("usb: dwc3: qcom: Transition to flattened model")
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 49 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The use of the old SET_SYSTEM_SLEEP_PM_OPS/SET_RUNTIME_PM_OPS macros without __maybe_unused annotations causes warnings when build testing without CONFIG_PM:

drivers/usb/dwc3/dwc3-qcom.c:421:12: error: unused function 'dwc3_qcom_suspend' [-Werror,-Wunused-function]
421 | static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup)

      |            ^~~~~~~~~~~~~~~~~

drivers/usb/dwc3/dwc3-qcom.c:457:12: error: unused function 'dwc3_qcom_resume' [-Werror,-Wunused-function]
457 | static int dwc3_qcom_resume(struct dwc3_qcom *qcom, bool wakeup)

Change these to the modern SYSTEM_SLEEP_PM_OPS/RUNTIME_PM_OPS/pm_ptr macros, which avoids the warnings and improves readability at the same time.

Fixes 1881a32fe14d ("usb: dwc3: qcom: Transition to flattened model")
---
 drivers/usb/dwc3/dwc3-qcom.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +0 -6
index d512002e1e88..cbba11589cd0 100644
@@ -832,7 +832,6 @@ static void dwc3_qcom_remove(struct platform_device *pdev)
 	reset_control_assert(qcom->resets);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int dwc3_qcom_pm_suspend(struct device *dev)
 {
 	struct dwc3 *dwc = dev_get_drvdata(dev);
@@ -886,12 +885,7 @@ static int dwc3_qcom_prepare(struct device *dev)
 
 	return dwc3_pm_prepare(dwc);
 }
-#else
-#define dwc3_qcom_complete NULL
-#define dwc3_qcom_prepare NULL
-#endif /* CONFIG_PM_SLEEP */
 
-#ifdef CONFIG_PM
 static int dwc3_qcom_runtime_suspend(struct device *dev)
 {
 	struct dwc3 *dwc = dev_get_drvdata(dev);
@@ -922,14 +916,13 @@ static int dwc3_qcom_runtime_idle(struct device *dev)
 {

drivers/usb/dwc3/dwc3-qcom.c static int dwc3_qcom_runtime_idle(struct device *dev) · line 923

Quoted 10 lines
drivers/usb/dwc3/dwc3-qcom.c +2 -3
 	return dwc3_runtime_idle(dev_get_drvdata(dev));
 }
-#endif /* CONFIG_PM */
 
 static const struct dev_pm_ops dwc3_qcom_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(dwc3_qcom_pm_suspend, dwc3_qcom_pm_resume)
-	SET_RUNTIME_PM_OPS(dwc3_qcom_runtime_suspend, dwc3_qcom_runtime_resume,
+	SYSTEM_SLEEP_PM_OPS(dwc3_qcom_pm_suspend, dwc3_qcom_pm_resume)
+	RUNTIME_PM_OPS(dwc3_qcom_runtime_suspend, dwc3_qcom_runtime_resume,
 			   dwc3_qcom_runtime_idle)

Minor nit: can you fix the alignment. Either align it to the paren above or just use tabs.

You can add this on the next version:

Thanks,
Thinh

Quoted 19 lines
drivers/usb/dwc3/dwc3-qcom.c +3 -3
-	.complete = dwc3_qcom_complete,
-	.prepare = dwc3_qcom_prepare,
+	.complete = pm_sleep_ptr(dwc3_qcom_complete),
+	.prepare = pm_sleep_ptr(dwc3_qcom_prepare),
 };
 
 static const struct of_device_id dwc3_qcom_of_match[] = {
@@ -943,7 +936,7 @@ static struct platform_driver dwc3_qcom_driver = {
 	.remove		= dwc3_qcom_remove,
 	.driver		= {
 		.name	= "dwc3-qcom",
-		.pm	= &dwc3_qcom_dev_pm_ops,
+		.pm	= pm_ptr(&dwc3_qcom_dev_pm_ops),
 		.of_match_table	= dwc3_qcom_of_match,
 	},
 };
Signature · 1 line
2.39.5