diff mbox series

[v3] pinctrl: imx: Switch to LATE_SYSTEM_SLEEP_PM_OPS()

Message ID 20240808162750.244092-1-festevam@gmail.com
State New
Headers show
Series [v3] pinctrl: imx: Switch to LATE_SYSTEM_SLEEP_PM_OPS() | expand

Commit Message

Fabio Estevam Aug. 8, 2024, 4:27 p.m. UTC
From: Fabio Estevam <festevam@denx.de>

Replace SET_LATE_SYSTEM_SLEEP_PM_OPS() with its modern
LATE_SYSTEM_SLEEP_PM_OPS() alternative.

The combined usage of pm_sleep_ptr() and LATE_SYSTEM_SLEEP_PM_OPS() allows
the compiler to evaluate if the runtime suspend/resume() functions
are used at build time or are simply dead code.

This allows removing the __maybe_unused notation from the runtime
suspend/resume() functions.

Signed-off-by: Fabio Estevam <festevam@denx.de>
---
Changes since v2:
- Use pm_sleep_ptr() (Peng).

 drivers/pinctrl/freescale/pinctrl-imx.c    | 7 +++----
 drivers/pinctrl/freescale/pinctrl-imx8mq.c | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

Comments

Peng Fan Aug. 12, 2024, 8:41 a.m. UTC | #1
> Subject: [PATCH v3] pinctrl: imx: Switch to
> LATE_SYSTEM_SLEEP_PM_OPS()
> 
> From: Fabio Estevam <festevam@denx.de>
> 
> Replace SET_LATE_SYSTEM_SLEEP_PM_OPS() with its modern
> LATE_SYSTEM_SLEEP_PM_OPS() alternative.
> 
> The combined usage of pm_sleep_ptr() and
> LATE_SYSTEM_SLEEP_PM_OPS() allows the compiler to evaluate if the
> runtime suspend/resume() functions are used at build time or are
> simply dead code.
> 
> This allows removing the __maybe_unused notation from the runtime
> suspend/resume() functions.
> 
> Signed-off-by: Fabio Estevam <festevam@denx.de>
> ---

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Linus Walleij Aug. 23, 2024, 4:16 p.m. UTC | #2
On Thu, Aug 8, 2024 at 6:28 PM Fabio Estevam <festevam@gmail.com> wrote:

> From: Fabio Estevam <festevam@denx.de>
>
> Replace SET_LATE_SYSTEM_SLEEP_PM_OPS() with its modern
> LATE_SYSTEM_SLEEP_PM_OPS() alternative.
>
> The combined usage of pm_sleep_ptr() and LATE_SYSTEM_SLEEP_PM_OPS() allows
> the compiler to evaluate if the runtime suspend/resume() functions
> are used at build time or are simply dead code.
>
> This allows removing the __maybe_unused notation from the runtime
> suspend/resume() functions.
>
> Signed-off-by: Fabio Estevam <festevam@denx.de>

Patch applied!

Yours,
Linus Walleij
Andy Shevchenko Aug. 23, 2024, 7:02 p.m. UTC | #3
On Thu, Aug 08, 2024 at 01:27:50PM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <festevam@denx.de>
> 
> Replace SET_LATE_SYSTEM_SLEEP_PM_OPS() with its modern
> LATE_SYSTEM_SLEEP_PM_OPS() alternative.
> 
> The combined usage of pm_sleep_ptr() and LATE_SYSTEM_SLEEP_PM_OPS() allows
> the compiler to evaluate if the runtime suspend/resume() functions
> are used at build time or are simply dead code.
> 
> This allows removing the __maybe_unused notation from the runtime
> suspend/resume() functions.

...

>  const struct dev_pm_ops imx_pinctrl_pm_ops = {
> -	SET_LATE_SYSTEM_SLEEP_PM_OPS(imx_pinctrl_suspend,
> -					imx_pinctrl_resume)
> +	LATE_SYSTEM_SLEEP_PM_OPS(imx_pinctrl_suspend, imx_pinctrl_resume)
>  };
>  EXPORT_SYMBOL_GPL(imx_pinctrl_pm_ops);

Can go even further

	EXPORT_GPL_DEV_PM_OPS(...) = {
		LATE_SYSTEM_SLEEP_PM_OPS(...)
	};
diff mbox series

Patch

diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
index 9c2680df082c..d05c2c478e79 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx.c
@@ -804,14 +804,14 @@  int imx_pinctrl_probe(struct platform_device *pdev,
 }
 EXPORT_SYMBOL_GPL(imx_pinctrl_probe);
 
-static int __maybe_unused imx_pinctrl_suspend(struct device *dev)
+static int imx_pinctrl_suspend(struct device *dev)
 {
 	struct imx_pinctrl *ipctl = dev_get_drvdata(dev);
 
 	return pinctrl_force_sleep(ipctl->pctl);
 }
 
-static int __maybe_unused imx_pinctrl_resume(struct device *dev)
+static int imx_pinctrl_resume(struct device *dev)
 {
 	struct imx_pinctrl *ipctl = dev_get_drvdata(dev);
 
@@ -819,8 +819,7 @@  static int __maybe_unused imx_pinctrl_resume(struct device *dev)
 }
 
 const struct dev_pm_ops imx_pinctrl_pm_ops = {
-	SET_LATE_SYSTEM_SLEEP_PM_OPS(imx_pinctrl_suspend,
-					imx_pinctrl_resume)
+	LATE_SYSTEM_SLEEP_PM_OPS(imx_pinctrl_suspend, imx_pinctrl_resume)
 };
 EXPORT_SYMBOL_GPL(imx_pinctrl_pm_ops);
 
diff --git a/drivers/pinctrl/freescale/pinctrl-imx8mq.c b/drivers/pinctrl/freescale/pinctrl-imx8mq.c
index 529eebe46298..e59e4fc80193 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx8mq.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx8mq.c
@@ -341,7 +341,7 @@  static struct platform_driver imx8mq_pinctrl_driver = {
 	.driver = {
 		.name = "imx8mq-pinctrl",
 		.of_match_table = imx8mq_pinctrl_of_match,
-		.pm = &imx_pinctrl_pm_ops,
+		.pm = pm_sleep_ptr(&imx_pinctrl_pm_ops),
 		.suppress_bind_attrs = true,
 	},
 	.probe = imx8mq_pinctrl_probe,