public inbox for linux-pwm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/11] pwm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
@ 2023-10-13 17:42 Uwe Kleine-König
  2023-10-13 17:42 ` [PATCH v2 01/11] pwm: atmel-hlcdc: " Uwe Kleine-König
                   ` (10 more replies)
  0 siblings, 11 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-13 17:42 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, linux-pwm,
	linux-arm-kernel, kernel, Florian Fainelli, Jonathan Cameron,
	Broadcom internal kernel review list, Shawn Guo, Sascha Hauer,
	Fabio Estevam, NXP Linux Team, Krzysztof Kozlowski, Alim Akhtar,
	linux-samsung-soc, Fabrice Gasnier, Maxime Coquelin,
	Alexandre Torgue, linux-stm32

Hello,

the only change here compared to (implicit) v1 sent with Message-Id:
20231010075112.755178-1-u.kleine-koenig@pengutronix.de is a rebase on
Thierry's current for-next branch and I added the tags I recieved on the
previous submission.

In v1 I did a small improvement for the brcmstb PWM driver en passant,
which was already done by Florian in a patch that is now commit
aacbd6543669 ("pwm: brcmstb: Checked clk_prepare_enable() return
value"). So the brcmstb patch in this series simplified to be similar to
the other patches here and so the commit log improvement that I promised
on Jonathan Cameron's feedback was dropped again.

Best regards
Uwe

Uwe Kleine-König (11):
  pwm: atmel-hlcdc: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  pwm: atmel-tcb: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  pwm: berlin: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  pwm: brcmstb: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  pwm: dwc: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  pwm: imx-tpm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  pwm: samsung: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  pwm: stm32-lp: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  pwm: stm32: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  pwm: tiecap: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  pwm: tiehrpwm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions

 drivers/pwm/pwm-atmel-hlcdc.c |  8 +++-----
 drivers/pwm/pwm-atmel-tcb.c   |  8 +++-----
 drivers/pwm/pwm-berlin.c      |  8 +++-----
 drivers/pwm/pwm-brcmstb.c     |  8 +++-----
 drivers/pwm/pwm-dwc.c         |  6 ++----
 drivers/pwm/pwm-imx-tpm.c     | 10 +++++-----
 drivers/pwm/pwm-samsung.c     |  6 ++----
 drivers/pwm/pwm-stm32-lp.c    | 10 +++++-----
 drivers/pwm/pwm-stm32.c       |  8 ++++----
 drivers/pwm/pwm-tiecap.c      |  6 ++----
 drivers/pwm/pwm-tiehrpwm.c    |  8 +++-----
 11 files changed, 35 insertions(+), 51 deletions(-)


base-commit: 4bb36d126cb3147d6bbfd00242a5b846dacad595
-- 
2.42.0


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

* [PATCH v2 01/11] pwm: atmel-hlcdc: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  2023-10-13 17:42 [PATCH v2 00/11] pwm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Uwe Kleine-König
@ 2023-10-13 17:42 ` Uwe Kleine-König
  2023-10-23 17:29   ` Uwe Kleine-König
  2023-10-13 17:42 ` [PATCH v2 02/11] pwm: atmel-tcb: " Uwe Kleine-König
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-13 17:42 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, linux-pwm,
	linux-arm-kernel, kernel, Jonathan Cameron

This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-atmel-hlcdc.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c
index 07920e034757..3f2c5031a3ba 100644
--- a/drivers/pwm/pwm-atmel-hlcdc.c
+++ b/drivers/pwm/pwm-atmel-hlcdc.c
@@ -180,7 +180,6 @@ static const struct atmel_hlcdc_pwm_errata atmel_hlcdc_pwm_sama5d3_errata = {
 	.div1_clk_erratum = true,
 };
 
-#ifdef CONFIG_PM_SLEEP
 static int atmel_hlcdc_pwm_suspend(struct device *dev)
 {
 	struct atmel_hlcdc_pwm *atmel = dev_get_drvdata(dev);
@@ -210,10 +209,9 @@ static int atmel_hlcdc_pwm_resume(struct device *dev)
 	return atmel_hlcdc_pwm_apply(&atmel->chip, &atmel->chip.pwms[0],
 				     &state);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(atmel_hlcdc_pwm_pm_ops,
-			 atmel_hlcdc_pwm_suspend, atmel_hlcdc_pwm_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(atmel_hlcdc_pwm_pm_ops,
+				atmel_hlcdc_pwm_suspend, atmel_hlcdc_pwm_resume);
 
 static const struct of_device_id atmel_hlcdc_dt_ids[] = {
 	{
@@ -297,7 +295,7 @@ static struct platform_driver atmel_hlcdc_pwm_driver = {
 	.driver = {
 		.name = "atmel-hlcdc-pwm",
 		.of_match_table = atmel_hlcdc_pwm_dt_ids,
-		.pm = &atmel_hlcdc_pwm_pm_ops,
+		.pm = pm_ptr(&atmel_hlcdc_pwm_pm_ops),
 	},
 	.probe = atmel_hlcdc_pwm_probe,
 	.remove_new = atmel_hlcdc_pwm_remove,
-- 
2.42.0


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

* [PATCH v2 02/11] pwm: atmel-tcb: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  2023-10-13 17:42 [PATCH v2 00/11] pwm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Uwe Kleine-König
  2023-10-13 17:42 ` [PATCH v2 01/11] pwm: atmel-hlcdc: " Uwe Kleine-König
@ 2023-10-13 17:42 ` Uwe Kleine-König
  2023-10-13 17:42 ` [PATCH v2 03/11] pwm: berlin: " Uwe Kleine-König
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-13 17:42 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, linux-pwm,
	linux-arm-kernel, kernel, Jonathan Cameron

This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-atmel-tcb.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c
index 98b33c016c3c..d42c897cb85e 100644
--- a/drivers/pwm/pwm-atmel-tcb.c
+++ b/drivers/pwm/pwm-atmel-tcb.c
@@ -489,7 +489,6 @@ static const struct of_device_id atmel_tcb_pwm_dt_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, atmel_tcb_pwm_dt_ids);
 
-#ifdef CONFIG_PM_SLEEP
 static int atmel_tcb_pwm_suspend(struct device *dev)
 {
 	struct atmel_tcb_pwm_chip *tcbpwm = dev_get_drvdata(dev);
@@ -522,16 +521,15 @@ static int atmel_tcb_pwm_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(atmel_tcb_pwm_pm_ops, atmel_tcb_pwm_suspend,
-			 atmel_tcb_pwm_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(atmel_tcb_pwm_pm_ops, atmel_tcb_pwm_suspend,
+				atmel_tcb_pwm_resume);
 
 static struct platform_driver atmel_tcb_pwm_driver = {
 	.driver = {
 		.name = "atmel-tcb-pwm",
 		.of_match_table = atmel_tcb_pwm_dt_ids,
-		.pm = &atmel_tcb_pwm_pm_ops,
+		.pm = pm_ptr(&atmel_tcb_pwm_pm_ops),
 	},
 	.probe = atmel_tcb_pwm_probe,
 	.remove_new = atmel_tcb_pwm_remove,
-- 
2.42.0


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

* [PATCH v2 03/11] pwm: berlin: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  2023-10-13 17:42 [PATCH v2 00/11] pwm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Uwe Kleine-König
  2023-10-13 17:42 ` [PATCH v2 01/11] pwm: atmel-hlcdc: " Uwe Kleine-König
  2023-10-13 17:42 ` [PATCH v2 02/11] pwm: atmel-tcb: " Uwe Kleine-König
@ 2023-10-13 17:42 ` Uwe Kleine-König
  2023-10-13 17:42 ` [PATCH v2 04/11] pwm: brcmstb: " Uwe Kleine-König
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-13 17:42 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-pwm, kernel

This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-berlin.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/pwm/pwm-berlin.c b/drivers/pwm/pwm-berlin.c
index ba2d79991769..442913232dc0 100644
--- a/drivers/pwm/pwm-berlin.c
+++ b/drivers/pwm/pwm-berlin.c
@@ -226,7 +226,6 @@ static int berlin_pwm_probe(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int berlin_pwm_suspend(struct device *dev)
 {
 	struct berlin_pwm_chip *bpc = dev_get_drvdata(dev);
@@ -267,17 +266,16 @@ static int berlin_pwm_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(berlin_pwm_pm_ops, berlin_pwm_suspend,
-			 berlin_pwm_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(berlin_pwm_pm_ops, berlin_pwm_suspend,
+				berlin_pwm_resume);
 
 static struct platform_driver berlin_pwm_driver = {
 	.probe = berlin_pwm_probe,
 	.driver = {
 		.name = "berlin-pwm",
 		.of_match_table = berlin_pwm_match,
-		.pm = &berlin_pwm_pm_ops,
+		.pm = pm_ptr(&berlin_pwm_pm_ops),
 	},
 };
 module_platform_driver(berlin_pwm_driver);
-- 
2.42.0


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

* [PATCH v2 04/11] pwm: brcmstb: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  2023-10-13 17:42 [PATCH v2 00/11] pwm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Uwe Kleine-König
                   ` (2 preceding siblings ...)
  2023-10-13 17:42 ` [PATCH v2 03/11] pwm: berlin: " Uwe Kleine-König
@ 2023-10-13 17:42 ` Uwe Kleine-König
  2023-10-16 10:45   ` Jonathan Cameron
  2023-10-13 17:42 ` [PATCH v2 05/11] pwm: dwc: " Uwe Kleine-König
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-13 17:42 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Florian Fainelli, Jonathan Cameron,
	Broadcom internal kernel review list, linux-pwm, linux-arm-kernel,
	kernel

This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Acked-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-brcmstb.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/pwm/pwm-brcmstb.c b/drivers/pwm/pwm-brcmstb.c
index b723c2d4f485..0fdeb0b2dbf3 100644
--- a/drivers/pwm/pwm-brcmstb.c
+++ b/drivers/pwm/pwm-brcmstb.c
@@ -259,7 +259,6 @@ static int brcmstb_pwm_probe(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int brcmstb_pwm_suspend(struct device *dev)
 {
 	struct brcmstb_pwm *p = dev_get_drvdata(dev);
@@ -275,17 +274,16 @@ static int brcmstb_pwm_resume(struct device *dev)
 
 	return clk_prepare_enable(p->clk);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(brcmstb_pwm_pm_ops, brcmstb_pwm_suspend,
-			 brcmstb_pwm_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(brcmstb_pwm_pm_ops, brcmstb_pwm_suspend,
+				brcmstb_pwm_resume);
 
 static struct platform_driver brcmstb_pwm_driver = {
 	.probe = brcmstb_pwm_probe,
 	.driver = {
 		.name = "pwm-brcmstb",
 		.of_match_table = brcmstb_pwm_of_match,
-		.pm = &brcmstb_pwm_pm_ops,
+		.pm = pm_ptr(&brcmstb_pwm_pm_ops),
 	},
 };
 module_platform_driver(brcmstb_pwm_driver);
-- 
2.42.0


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

* [PATCH v2 05/11] pwm: dwc: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  2023-10-13 17:42 [PATCH v2 00/11] pwm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Uwe Kleine-König
                   ` (3 preceding siblings ...)
  2023-10-13 17:42 ` [PATCH v2 04/11] pwm: brcmstb: " Uwe Kleine-König
@ 2023-10-13 17:42 ` Uwe Kleine-König
  2023-10-13 17:42 ` [PATCH v2 06/11] pwm: imx-tpm: " Uwe Kleine-König
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-13 17:42 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-pwm, kernel

This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-dwc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c
index bd9cadb497d7..4929354f8cd9 100644
--- a/drivers/pwm/pwm-dwc.c
+++ b/drivers/pwm/pwm-dwc.c
@@ -71,7 +71,6 @@ static void dwc_pwm_remove(struct pci_dev *pci)
 	pm_runtime_get_noresume(&pci->dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int dwc_pwm_suspend(struct device *dev)
 {
 	struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
@@ -106,9 +105,8 @@ static int dwc_pwm_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(dwc_pwm_pm_ops, dwc_pwm_suspend, dwc_pwm_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(dwc_pwm_pm_ops, dwc_pwm_suspend, dwc_pwm_resume);
 
 static const struct pci_device_id dwc_pwm_id_table[] = {
 	{ PCI_VDEVICE(INTEL, 0x4bb7) }, /* Elkhart Lake */
@@ -122,7 +120,7 @@ static struct pci_driver dwc_pwm_driver = {
 	.remove = dwc_pwm_remove,
 	.id_table = dwc_pwm_id_table,
 	.driver = {
-		.pm = &dwc_pwm_pm_ops,
+		.pm = pm_ptr(&dwc_pwm_pm_ops),
 	},
 };
 
-- 
2.42.0


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

* [PATCH v2 06/11] pwm: imx-tpm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  2023-10-13 17:42 [PATCH v2 00/11] pwm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Uwe Kleine-König
                   ` (4 preceding siblings ...)
  2023-10-13 17:42 ` [PATCH v2 05/11] pwm: dwc: " Uwe Kleine-König
@ 2023-10-13 17:42 ` Uwe Kleine-König
  2023-10-13 17:42 ` [PATCH v2 07/11] pwm: samsung: " Uwe Kleine-König
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-13 17:42 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, linux-pwm, linux-arm-kernel, Jonathan Cameron

This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding
__maybe_unused can be dropped.

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-imx-tpm.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c
index dc6aafeb9f7b..9fc290e647e1 100644
--- a/drivers/pwm/pwm-imx-tpm.c
+++ b/drivers/pwm/pwm-imx-tpm.c
@@ -371,7 +371,7 @@ static int pwm_imx_tpm_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int __maybe_unused pwm_imx_tpm_suspend(struct device *dev)
+static int pwm_imx_tpm_suspend(struct device *dev)
 {
 	struct imx_tpm_pwm_chip *tpm = dev_get_drvdata(dev);
 
@@ -390,7 +390,7 @@ static int __maybe_unused pwm_imx_tpm_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused pwm_imx_tpm_resume(struct device *dev)
+static int pwm_imx_tpm_resume(struct device *dev)
 {
 	struct imx_tpm_pwm_chip *tpm = dev_get_drvdata(dev);
 	int ret = 0;
@@ -402,8 +402,8 @@ static int __maybe_unused pwm_imx_tpm_resume(struct device *dev)
 	return ret;
 }
 
-static SIMPLE_DEV_PM_OPS(imx_tpm_pwm_pm,
-			 pwm_imx_tpm_suspend, pwm_imx_tpm_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(imx_tpm_pwm_pm,
+				pwm_imx_tpm_suspend, pwm_imx_tpm_resume);
 
 static const struct of_device_id imx_tpm_pwm_dt_ids[] = {
 	{ .compatible = "fsl,imx7ulp-pwm", },
@@ -415,7 +415,7 @@ static struct platform_driver imx_tpm_pwm_driver = {
 	.driver = {
 		.name = "imx7ulp-tpm-pwm",
 		.of_match_table = imx_tpm_pwm_dt_ids,
-		.pm = &imx_tpm_pwm_pm,
+		.pm = pm_ptr(&imx_tpm_pwm_pm),
 	},
 	.probe	= pwm_imx_tpm_probe,
 };
-- 
2.42.0


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

* [PATCH v2 07/11] pwm: samsung: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  2023-10-13 17:42 [PATCH v2 00/11] pwm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Uwe Kleine-König
                   ` (5 preceding siblings ...)
  2023-10-13 17:42 ` [PATCH v2 06/11] pwm: imx-tpm: " Uwe Kleine-König
@ 2023-10-13 17:42 ` Uwe Kleine-König
  2023-10-13 17:42 ` [PATCH v2 08/11] pwm: stm32-lp: " Uwe Kleine-König
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-13 17:42 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Krzysztof Kozlowski, Alim Akhtar, linux-arm-kernel,
	linux-samsung-soc, linux-pwm, kernel, Jonathan Cameron

This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-samsung.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c
index 568491ed6829..e6a8fa77aac7 100644
--- a/drivers/pwm/pwm-samsung.c
+++ b/drivers/pwm/pwm-samsung.c
@@ -620,7 +620,6 @@ static void pwm_samsung_remove(struct platform_device *pdev)
 	clk_disable_unprepare(our_chip->base_clk);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int pwm_samsung_resume(struct device *dev)
 {
 	struct samsung_pwm_chip *our_chip = dev_get_drvdata(dev);
@@ -653,14 +652,13 @@ static int pwm_samsung_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(pwm_samsung_pm_ops, NULL, pwm_samsung_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(pwm_samsung_pm_ops, NULL, pwm_samsung_resume);
 
 static struct platform_driver pwm_samsung_driver = {
 	.driver		= {
 		.name	= "samsung-pwm",
-		.pm	= &pwm_samsung_pm_ops,
+		.pm	= pm_ptr(&pwm_samsung_pm_ops),
 		.of_match_table = of_match_ptr(samsung_pwm_matches),
 	},
 	.probe		= pwm_samsung_probe,
-- 
2.42.0


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

* [PATCH v2 08/11] pwm: stm32-lp: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  2023-10-13 17:42 [PATCH v2 00/11] pwm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Uwe Kleine-König
                   ` (6 preceding siblings ...)
  2023-10-13 17:42 ` [PATCH v2 07/11] pwm: samsung: " Uwe Kleine-König
@ 2023-10-13 17:42 ` Uwe Kleine-König
  2023-10-13 17:42 ` [PATCH v2 09/11] pwm: stm32: " Uwe Kleine-König
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-13 17:42 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Fabrice Gasnier, Maxime Coquelin, Alexandre Torgue, linux-pwm,
	linux-stm32, linux-arm-kernel, kernel, Jonathan Cameron

This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding
__maybe_unused can be dropped.

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-stm32-lp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/pwm/pwm-stm32-lp.c b/drivers/pwm/pwm-stm32-lp.c
index b67974cc1872..439068f3eca1 100644
--- a/drivers/pwm/pwm-stm32-lp.c
+++ b/drivers/pwm/pwm-stm32-lp.c
@@ -218,7 +218,7 @@ static int stm32_pwm_lp_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int __maybe_unused stm32_pwm_lp_suspend(struct device *dev)
+static int stm32_pwm_lp_suspend(struct device *dev)
 {
 	struct stm32_pwm_lp *priv = dev_get_drvdata(dev);
 	struct pwm_state state;
@@ -233,13 +233,13 @@ static int __maybe_unused stm32_pwm_lp_suspend(struct device *dev)
 	return pinctrl_pm_select_sleep_state(dev);
 }
 
-static int __maybe_unused stm32_pwm_lp_resume(struct device *dev)
+static int stm32_pwm_lp_resume(struct device *dev)
 {
 	return pinctrl_pm_select_default_state(dev);
 }
 
-static SIMPLE_DEV_PM_OPS(stm32_pwm_lp_pm_ops, stm32_pwm_lp_suspend,
-			 stm32_pwm_lp_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(stm32_pwm_lp_pm_ops, stm32_pwm_lp_suspend,
+				stm32_pwm_lp_resume);
 
 static const struct of_device_id stm32_pwm_lp_of_match[] = {
 	{ .compatible = "st,stm32-pwm-lp", },
@@ -252,7 +252,7 @@ static struct platform_driver stm32_pwm_lp_driver = {
 	.driver	= {
 		.name = "stm32-pwm-lp",
 		.of_match_table = stm32_pwm_lp_of_match,
-		.pm = &stm32_pwm_lp_pm_ops,
+		.pm = pm_ptr(&stm32_pwm_lp_pm_ops),
 	},
 };
 module_platform_driver(stm32_pwm_lp_driver);
-- 
2.42.0


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

* [PATCH v2 09/11] pwm: stm32: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  2023-10-13 17:42 [PATCH v2 00/11] pwm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Uwe Kleine-König
                   ` (7 preceding siblings ...)
  2023-10-13 17:42 ` [PATCH v2 08/11] pwm: stm32-lp: " Uwe Kleine-König
@ 2023-10-13 17:42 ` Uwe Kleine-König
  2023-10-13 17:42 ` [PATCH v2 10/11] pwm: tiecap: " Uwe Kleine-König
  2023-10-13 17:42 ` [PATCH v2 11/11] pwm: tiehrpwm: " Uwe Kleine-König
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-13 17:42 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Fabrice Gasnier, Maxime Coquelin, Alexandre Torgue, linux-pwm,
	linux-stm32, linux-arm-kernel, kernel, Jonathan Cameron

This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding
__maybe_unused can be dropped.

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-stm32.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
index 3303a754ea02..8be037757b8b 100644
--- a/drivers/pwm/pwm-stm32.c
+++ b/drivers/pwm/pwm-stm32.c
@@ -645,7 +645,7 @@ static int stm32_pwm_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int __maybe_unused stm32_pwm_suspend(struct device *dev)
+static int stm32_pwm_suspend(struct device *dev)
 {
 	struct stm32_pwm *priv = dev_get_drvdata(dev);
 	unsigned int i;
@@ -666,7 +666,7 @@ static int __maybe_unused stm32_pwm_suspend(struct device *dev)
 	return pinctrl_pm_select_sleep_state(dev);
 }
 
-static int __maybe_unused stm32_pwm_resume(struct device *dev)
+static int stm32_pwm_resume(struct device *dev)
 {
 	struct stm32_pwm *priv = dev_get_drvdata(dev);
 	int ret;
@@ -679,7 +679,7 @@ static int __maybe_unused stm32_pwm_resume(struct device *dev)
 	return stm32_pwm_apply_breakinputs(priv);
 }
 
-static SIMPLE_DEV_PM_OPS(stm32_pwm_pm_ops, stm32_pwm_suspend, stm32_pwm_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(stm32_pwm_pm_ops, stm32_pwm_suspend, stm32_pwm_resume);
 
 static const struct of_device_id stm32_pwm_of_match[] = {
 	{ .compatible = "st,stm32-pwm",	},
@@ -692,7 +692,7 @@ static struct platform_driver stm32_pwm_driver = {
 	.driver	= {
 		.name = "stm32-pwm",
 		.of_match_table = stm32_pwm_of_match,
-		.pm = &stm32_pwm_pm_ops,
+		.pm = pm_ptr(&stm32_pwm_pm_ops),
 	},
 };
 module_platform_driver(stm32_pwm_driver);
-- 
2.42.0


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

* [PATCH v2 10/11] pwm: tiecap: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  2023-10-13 17:42 [PATCH v2 00/11] pwm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Uwe Kleine-König
                   ` (8 preceding siblings ...)
  2023-10-13 17:42 ` [PATCH v2 09/11] pwm: stm32: " Uwe Kleine-König
@ 2023-10-13 17:42 ` Uwe Kleine-König
  2023-10-13 17:42 ` [PATCH v2 11/11] pwm: tiehrpwm: " Uwe Kleine-König
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-13 17:42 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-pwm, kernel

This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-tiecap.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/pwm/pwm-tiecap.c b/drivers/pwm/pwm-tiecap.c
index 11e3549cf103..d974f4414ac9 100644
--- a/drivers/pwm/pwm-tiecap.c
+++ b/drivers/pwm/pwm-tiecap.c
@@ -269,7 +269,6 @@ static void ecap_pwm_remove(struct platform_device *pdev)
 	pm_runtime_disable(&pdev->dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static void ecap_pwm_save_context(struct ecap_pwm_chip *pc)
 {
 	pm_runtime_get_sync(pc->chip.dev);
@@ -312,15 +311,14 @@ static int ecap_pwm_resume(struct device *dev)
 	ecap_pwm_restore_context(pc);
 	return 0;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(ecap_pwm_pm_ops, ecap_pwm_suspend, ecap_pwm_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(ecap_pwm_pm_ops, ecap_pwm_suspend, ecap_pwm_resume);
 
 static struct platform_driver ecap_pwm_driver = {
 	.driver = {
 		.name = "ecap",
 		.of_match_table = ecap_of_match,
-		.pm = &ecap_pwm_pm_ops,
+		.pm = pm_ptr(&ecap_pwm_pm_ops),
 	},
 	.probe = ecap_pwm_probe,
 	.remove_new = ecap_pwm_remove,
-- 
2.42.0


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

* [PATCH v2 11/11] pwm: tiehrpwm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  2023-10-13 17:42 [PATCH v2 00/11] pwm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Uwe Kleine-König
                   ` (9 preceding siblings ...)
  2023-10-13 17:42 ` [PATCH v2 10/11] pwm: tiecap: " Uwe Kleine-König
@ 2023-10-13 17:42 ` Uwe Kleine-König
  10 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-13 17:42 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-pwm, kernel

This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-tiehrpwm.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
index 66ac2655845f..af231fa74fa9 100644
--- a/drivers/pwm/pwm-tiehrpwm.c
+++ b/drivers/pwm/pwm-tiehrpwm.c
@@ -521,7 +521,6 @@ static void ehrpwm_pwm_remove(struct platform_device *pdev)
 	pm_runtime_disable(&pdev->dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static void ehrpwm_pwm_save_context(struct ehrpwm_pwm_chip *pc)
 {
 	pm_runtime_get_sync(pc->chip.dev);
@@ -589,16 +588,15 @@ static int ehrpwm_pwm_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(ehrpwm_pwm_pm_ops, ehrpwm_pwm_suspend,
-			 ehrpwm_pwm_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(ehrpwm_pwm_pm_ops, ehrpwm_pwm_suspend,
+				ehrpwm_pwm_resume);
 
 static struct platform_driver ehrpwm_pwm_driver = {
 	.driver = {
 		.name = "ehrpwm",
 		.of_match_table = ehrpwm_of_match,
-		.pm = &ehrpwm_pwm_pm_ops,
+		.pm = pm_ptr(&ehrpwm_pwm_pm_ops),
 	},
 	.probe = ehrpwm_pwm_probe,
 	.remove_new = ehrpwm_pwm_remove,
-- 
2.42.0


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

* Re: [PATCH v2 04/11] pwm: brcmstb: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  2023-10-13 17:42 ` [PATCH v2 04/11] pwm: brcmstb: " Uwe Kleine-König
@ 2023-10-16 10:45   ` Jonathan Cameron
  0 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2023-10-16 10:45 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Thierry Reding, Florian Fainelli,
	Broadcom internal kernel review list, linux-pwm, linux-arm-kernel,
	kernel

On Fri, 13 Oct 2023 19:42:09 +0200
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:

> This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
> care about when the functions are actually used, so the corresponding
> 
> Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
> isn't enabled.
> 
> Acked-by: Florian Fainelli <florian.fainelli@broadcom.com>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Given the bit I commented on in v1 has gone away...

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/pwm/pwm-brcmstb.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-brcmstb.c b/drivers/pwm/pwm-brcmstb.c
> index b723c2d4f485..0fdeb0b2dbf3 100644
> --- a/drivers/pwm/pwm-brcmstb.c
> +++ b/drivers/pwm/pwm-brcmstb.c
> @@ -259,7 +259,6 @@ static int brcmstb_pwm_probe(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -#ifdef CONFIG_PM_SLEEP
>  static int brcmstb_pwm_suspend(struct device *dev)
>  {
>  	struct brcmstb_pwm *p = dev_get_drvdata(dev);
> @@ -275,17 +274,16 @@ static int brcmstb_pwm_resume(struct device *dev)
>  
>  	return clk_prepare_enable(p->clk);
>  }
> -#endif
>  
> -static SIMPLE_DEV_PM_OPS(brcmstb_pwm_pm_ops, brcmstb_pwm_suspend,
> -			 brcmstb_pwm_resume);
> +static DEFINE_SIMPLE_DEV_PM_OPS(brcmstb_pwm_pm_ops, brcmstb_pwm_suspend,
> +				brcmstb_pwm_resume);
>  
>  static struct platform_driver brcmstb_pwm_driver = {
>  	.probe = brcmstb_pwm_probe,
>  	.driver = {
>  		.name = "pwm-brcmstb",
>  		.of_match_table = brcmstb_pwm_of_match,
> -		.pm = &brcmstb_pwm_pm_ops,
> +		.pm = pm_ptr(&brcmstb_pwm_pm_ops),
>  	},
>  };
>  module_platform_driver(brcmstb_pwm_driver);


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

* Re: [PATCH v2 01/11] pwm: atmel-hlcdc: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
  2023-10-13 17:42 ` [PATCH v2 01/11] pwm: atmel-hlcdc: " Uwe Kleine-König
@ 2023-10-23 17:29   ` Uwe Kleine-König
  0 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-23 17:29 UTC (permalink / raw)
  To: Thierry Reding
  Cc: linux-pwm, Alexandre Belloni, Nicolas Ferre, Claudiu Beznea,
	kernel, Jonathan Cameron, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 979 bytes --]

On Fri, Oct 13, 2023 at 07:42:06PM +0200, Uwe Kleine-König wrote:
> This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
> care about when the functions are actually used, so the corresponding
> 
> Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
> isn't enabled.
> 
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Something in my processing queue ate a line after the first paragraph:

	#ifdef can be dropped.

I don't understand yet where this happend. It also affects a few other
patches in this series. I'll investigate and resend. In the meantime I
discard this series from patchwork.

Thanks to Jan Lübbe who pointed out that problem to me (by PM).

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2023-10-23 17:31 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-13 17:42 [PATCH v2 00/11] pwm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions Uwe Kleine-König
2023-10-13 17:42 ` [PATCH v2 01/11] pwm: atmel-hlcdc: " Uwe Kleine-König
2023-10-23 17:29   ` Uwe Kleine-König
2023-10-13 17:42 ` [PATCH v2 02/11] pwm: atmel-tcb: " Uwe Kleine-König
2023-10-13 17:42 ` [PATCH v2 03/11] pwm: berlin: " Uwe Kleine-König
2023-10-13 17:42 ` [PATCH v2 04/11] pwm: brcmstb: " Uwe Kleine-König
2023-10-16 10:45   ` Jonathan Cameron
2023-10-13 17:42 ` [PATCH v2 05/11] pwm: dwc: " Uwe Kleine-König
2023-10-13 17:42 ` [PATCH v2 06/11] pwm: imx-tpm: " Uwe Kleine-König
2023-10-13 17:42 ` [PATCH v2 07/11] pwm: samsung: " Uwe Kleine-König
2023-10-13 17:42 ` [PATCH v2 08/11] pwm: stm32-lp: " Uwe Kleine-König
2023-10-13 17:42 ` [PATCH v2 09/11] pwm: stm32: " Uwe Kleine-König
2023-10-13 17:42 ` [PATCH v2 10/11] pwm: tiecap: " Uwe Kleine-König
2023-10-13 17:42 ` [PATCH v2 11/11] pwm: tiehrpwm: " Uwe Kleine-König

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