Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
* [PATCH v2] pinctrl: imx: Switch to LATE_SYSTEM_SLEEP_PM_OPS()
@ 2024-08-07 18:10 Fabio Estevam
  2024-08-08  2:21 ` Peng Fan
  0 siblings, 1 reply; 2+ messages in thread
From: Fabio Estevam @ 2024-08-07 18:10 UTC (permalink / raw)
  To: linus.walleij; +Cc: aisheng.dong, ping.bai, linux-gpio, imx, Fabio Estevam

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_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 v1:
- Pass pm_ptr() to the correct ops structure.

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

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..316469e72a17 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_ptr(&imx_pinctrl_pm_ops),
 		.suppress_bind_attrs = true,
 	},
 	.probe = imx8mq_pinctrl_probe,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH v2] pinctrl: imx: Switch to LATE_SYSTEM_SLEEP_PM_OPS()
  2024-08-07 18:10 [PATCH v2] pinctrl: imx: Switch to LATE_SYSTEM_SLEEP_PM_OPS() Fabio Estevam
@ 2024-08-08  2:21 ` Peng Fan
  0 siblings, 0 replies; 2+ messages in thread
From: Peng Fan @ 2024-08-08  2:21 UTC (permalink / raw)
  To: Fabio Estevam, linus.walleij@linaro.org
  Cc: Aisheng Dong, Jacky Bai, linux-gpio@vger.kernel.org,
	imx@lists.linux.dev, Fabio Estevam

> Subject: [PATCH v2] 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_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 v1:
> - Pass pm_ptr() to the correct ops structure.
> 
>  drivers/pinctrl/freescale/pinctrl-imx.c    | 7 +++----
>  drivers/pinctrl/freescale/pinctrl-imx8mq.c | 2 +-
>  2 files changed, 4 insertions(+), 5 deletions(-)
> 
> 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..316469e72a17 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_ptr(&imx_pinctrl_pm_ops),

I see other pinctrl drivers are using pm_sleep_ptr,
pm_sleep_ptr is better here?

Thanks,
Peng.

>  		.suppress_bind_attrs = true,
>  	},
>  	.probe = imx8mq_pinctrl_probe,
> --
> 2.34.1
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-08  2:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-07 18:10 [PATCH v2] pinctrl: imx: Switch to LATE_SYSTEM_SLEEP_PM_OPS() Fabio Estevam
2024-08-08  2:21 ` Peng Fan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox