linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/23] i2c: Use new PM macros
@ 2023-07-05 20:42 Paul Cercueil
  2023-07-05 20:45 ` [PATCH 19/23] i2c: rcar: Remove #ifdef guards for PM related functions Paul Cercueil
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Cercueil @ 2023-07-05 20:42 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-i2c, linux-kernel, Paul Cercueil, Elie Morisse,
	Shyam Sundar S K, Ray Jui, Scott Branden, Kamal Dasu,
	Broadcom internal kernel review list, Florian Fainelli,
	Bartosz Golaszewski, Jarkko Nikula, Andy Shevchenko,
	Mika Westerberg, Jan Dabros, Jean Delvare, Qii Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Linus Walleij,
	Peter Korsgaard, Andrew Lunn, Vladimir Zapolskiy, Andy Gross,
	Bjorn Andersson, Konrad Dybcio, Wolfram Sang,
	Krzysztof Kozlowski, Alim Akhtar, Conghui Chen, Viresh Kumar,
	Peter Rosin, linux-arm-kernel, linux-arm-msm, linux-mediatek,
	linux-renesas-soc, linux-samsung-soc, virtualization

Hi Wolfram,

This patchset converts the I2C subsystem to use the PM macros that were
introduced in v5.17, which allow the dev_pm_ops and related callbacks to
be automatically dropped by the compiler when CONFIG_PM or
CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

The point of this, is that all this code is now compiled independently
of any Kconfig option, which makes bugs and regressions easier to catch.

This continues the work that has been started in other subsystems (DRM,
IIO, watchdog).

As an added bonus, the diff is 71+/192-, that means less code you will
have to maintain ;)

The patches generally don't change the behaviour, with a few exceptions,
that are documented in the corresponding patches.

I would like to draw the attention to a few patches in particular:

- [01/23] the driver most likely does something that it shouldn't do
  (use the same callbacks for runtime PM and system PM). The patch does
  not change this behaviour but I have questions.

- [11/23] uses platform_driver.{suspend,resume} instead of the regular
  .driver.pm. I have no idea why it does that and I believe it doesn't
  really have to.

- [18/23] I feel like the qup_i2c_suspend / qup_i2c_resume don't really
  need to exist, and the pm_runtime_force_suspend() /
  pm_runtime_force_resume() helpers should be used instead, using the
  DEFINE_RUNTIME_DEV_PM_OPS() macro.

Cheers,
-Paul

Paul Cercueil (23):
  i2c: amd-mp2: Remove #ifdef guards for PM related functions
  i2c: au1550: Remove #ifdef guards for PM related functions
  i2c: iproc: Remove #ifdef guards for PM related functions
  i2c: brcmstb: Remove #ifdef guards for PM related functions
  i2c: davinci: Remove #ifdef guards for PM related functions
  i2c: designware: Remove #ifdef guards for PM related functions
  i2c: exynos5: Remove #ifdef guards for PM related functions
  i2c: hix5hd2: Remove #ifdef guards for PM related functions
  i2c: i801: Remove #ifdef guards for PM related functions
  i2c: img-scb: Remove #ifdef guards for PM related functions
  i2c: kempld: Remove #ifdef guards for PM related functions
  i2c: lpc2k: Remove #ifdef guards for PM related functions
  i2c: mt65xx: Remove #ifdef guards for PM related functions
  i2c: nomadik: Remove #ifdef guards for PM related functions
  i2c: ocores: Remove #ifdef guards for PM related functions
  i2c: pnx: Remove #ifdef guards for PM related functions
  i2c: pxa: Remove #ifdef guards for PM related functions
  i2c: qup: Remove #ifdef guards for PM related functions
  i2c: rcar: Remove #ifdef guards for PM related functions
  i2c: s3c2410: Remove #ifdef guards for PM related functions
  i2c: sh-mobile: Remove #ifdef guards for PM related functions
  i2c: virtio: Remove #ifdef guards for PM related functions
  i2c: mux: pca954x: Remove #ifdef guards for PM related functions

 drivers/i2c/busses/i2c-amd-mp2-pci.c        | 14 +++++--------
 drivers/i2c/busses/i2c-amd-mp2-plat.c       |  8 ++------
 drivers/i2c/busses/i2c-amd-mp2.h            |  2 --
 drivers/i2c/busses/i2c-au1550.c             | 15 +++-----------
 drivers/i2c/busses/i2c-bcm-iproc.c          | 10 +---------
 drivers/i2c/busses/i2c-brcmstb.c            |  8 +++-----
 drivers/i2c/busses/i2c-davinci.c            | 12 +++--------
 drivers/i2c/busses/i2c-designware-platdrv.c | 22 ++++++---------------
 drivers/i2c/busses/i2c-exynos5.c            |  8 +++-----
 drivers/i2c/busses/i2c-hix5hd2.c            | 10 ++++------
 drivers/i2c/busses/i2c-i801.c               |  6 ++----
 drivers/i2c/busses/i2c-img-scb.c            | 13 ++++--------
 drivers/i2c/busses/i2c-kempld.c             |  9 ++-------
 drivers/i2c/busses/i2c-lpc2k.c              |  8 +-------
 drivers/i2c/busses/i2c-mt65xx.c             |  8 +++-----
 drivers/i2c/busses/i2c-nomadik.c            | 14 +++++--------
 drivers/i2c/busses/i2c-ocores.c             | 10 +++-------
 drivers/i2c/busses/i2c-pnx.c                | 12 ++++-------
 drivers/i2c/busses/i2c-pxa.c                |  8 +-------
 drivers/i2c/busses/i2c-qup.c                | 16 ++++-----------
 drivers/i2c/busses/i2c-rcar.c               | 10 ++--------
 drivers/i2c/busses/i2c-s3c2410.c            | 14 +++----------
 drivers/i2c/busses/i2c-sh_mobile.c          | 12 +++--------
 drivers/i2c/busses/i2c-virtio.c             |  8 ++------
 drivers/i2c/muxes/i2c-mux-pca954x.c         |  6 ++----
 25 files changed, 71 insertions(+), 192 deletions(-)

-- 
2.40.1


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

* [PATCH 19/23] i2c: rcar: Remove #ifdef guards for PM related functions
  2023-07-05 20:42 [PATCH 00/23] i2c: Use new PM macros Paul Cercueil
@ 2023-07-05 20:45 ` Paul Cercueil
  2023-07-05 20:45   ` [PATCH 21/23] i2c: sh-mobile: " Paul Cercueil
                     ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Paul Cercueil @ 2023-07-05 20:45 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-i2c, linux-kernel, Paul Cercueil, Wolfram Sang, linux-renesas-soc

Use the new PM macros for the suspend and resume functions to be
automatically dropped by the compiler when CONFIG_PM or
CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>

---
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-renesas-soc@vger.kernel.org
---
 drivers/i2c/busses/i2c-rcar.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 2d9c37410ebd..6b7f0f27d0c3 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -1169,7 +1169,6 @@ static void rcar_i2c_remove(struct platform_device *pdev)
 	pm_runtime_disable(dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int rcar_i2c_suspend(struct device *dev)
 {
 	struct rcar_i2c_priv *priv = dev_get_drvdata(dev);
@@ -1187,19 +1186,14 @@ static int rcar_i2c_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops rcar_i2c_pm_ops = {
-	SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(rcar_i2c_suspend, rcar_i2c_resume)
+	NOIRQ_SYSTEM_SLEEP_PM_OPS(rcar_i2c_suspend, rcar_i2c_resume)
 };
 
-#define DEV_PM_OPS (&rcar_i2c_pm_ops)
-#else
-#define DEV_PM_OPS NULL
-#endif /* CONFIG_PM_SLEEP */
-
 static struct platform_driver rcar_i2c_driver = {
 	.driver	= {
 		.name	= "i2c-rcar",
 		.of_match_table = rcar_i2c_dt_ids,
-		.pm	= DEV_PM_OPS,
+		.pm	= pm_sleep_ptr(&rcar_i2c_pm_ops),
 	},
 	.probe		= rcar_i2c_probe,
 	.remove_new	= rcar_i2c_remove,
-- 
2.40.1


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

* [PATCH 21/23] i2c: sh-mobile: Remove #ifdef guards for PM related functions
  2023-07-05 20:45 ` [PATCH 19/23] i2c: rcar: Remove #ifdef guards for PM related functions Paul Cercueil
@ 2023-07-05 20:45   ` Paul Cercueil
  2023-07-06  3:07     ` Jonathan Cameron
  2023-07-10 12:40     ` Geert Uytterhoeven
  2023-07-06  2:52   ` [PATCH 19/23] i2c: rcar: " Jonathan Cameron
  2023-07-10 12:41   ` Geert Uytterhoeven
  2 siblings, 2 replies; 7+ messages in thread
From: Paul Cercueil @ 2023-07-05 20:45 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-i2c, linux-kernel, Paul Cercueil, Wolfram Sang, linux-renesas-soc

Use the new PM macros for the suspend and resume functions to be
automatically dropped by the compiler when CONFIG_PM or
CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>

---
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-renesas-soc@vger.kernel.org
---
 drivers/i2c/busses/i2c-sh_mobile.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index 21717b943a9e..324407196a10 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -965,7 +965,6 @@ static void sh_mobile_i2c_remove(struct platform_device *dev)
 	pm_runtime_disable(&dev->dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sh_mobile_i2c_suspend(struct device *dev)
 {
 	struct sh_mobile_i2c_data *pd = dev_get_drvdata(dev);
@@ -983,20 +982,15 @@ static int sh_mobile_i2c_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops sh_mobile_i2c_pm_ops = {
-	SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sh_mobile_i2c_suspend,
-				      sh_mobile_i2c_resume)
+	NOIRQ_SYSTEM_SLEEP_PM_OPS(sh_mobile_i2c_suspend,
+				  sh_mobile_i2c_resume)
 };
 
-#define DEV_PM_OPS (&sh_mobile_i2c_pm_ops)
-#else
-#define DEV_PM_OPS NULL
-#endif /* CONFIG_PM_SLEEP */
-
 static struct platform_driver sh_mobile_i2c_driver = {
 	.driver		= {
 		.name		= "i2c-sh_mobile",
 		.of_match_table = sh_mobile_i2c_dt_ids,
-		.pm	= DEV_PM_OPS,
+		.pm	= pm_sleep_ptr(&sh_mobile_i2c_pm_ops),
 	},
 	.probe		= sh_mobile_i2c_probe,
 	.remove_new	= sh_mobile_i2c_remove,
-- 
2.40.1


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

* Re: [PATCH 19/23] i2c: rcar: Remove #ifdef guards for PM related functions
  2023-07-05 20:45 ` [PATCH 19/23] i2c: rcar: Remove #ifdef guards for PM related functions Paul Cercueil
  2023-07-05 20:45   ` [PATCH 21/23] i2c: sh-mobile: " Paul Cercueil
@ 2023-07-06  2:52   ` Jonathan Cameron
  2023-07-10 12:41   ` Geert Uytterhoeven
  2 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2023-07-06  2:52 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Wolfram Sang, linux-i2c, linux-kernel, Wolfram Sang, linux-renesas-soc

On Wed,  5 Jul 2023 22:45:17 +0200
Paul Cercueil <paul@crapouillou.net> wrote:

> Use the new PM macros for the suspend and resume functions to be
> automatically dropped by the compiler when CONFIG_PM or
> CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.
> 
> This has the advantage of always compiling these functions in,
> independently of any Kconfig option. Thanks to that, bugs and other
> regressions are subsequently easier to catch.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

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

* Re: [PATCH 21/23] i2c: sh-mobile: Remove #ifdef guards for PM related functions
  2023-07-05 20:45   ` [PATCH 21/23] i2c: sh-mobile: " Paul Cercueil
@ 2023-07-06  3:07     ` Jonathan Cameron
  2023-07-10 12:40     ` Geert Uytterhoeven
  1 sibling, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2023-07-06  3:07 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Wolfram Sang, linux-i2c, linux-kernel, Wolfram Sang, linux-renesas-soc

On Wed,  5 Jul 2023 22:45:19 +0200
Paul Cercueil <paul@crapouillou.net> wrote:

> Use the new PM macros for the suspend and resume functions to be
> automatically dropped by the compiler when CONFIG_PM or
> CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.
> 
> This has the advantage of always compiling these functions in,
> independently of any Kconfig option. Thanks to that, bugs and other
> regressions are subsequently easier to catch.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


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

* Re: [PATCH 21/23] i2c: sh-mobile: Remove #ifdef guards for PM related functions
  2023-07-05 20:45   ` [PATCH 21/23] i2c: sh-mobile: " Paul Cercueil
  2023-07-06  3:07     ` Jonathan Cameron
@ 2023-07-10 12:40     ` Geert Uytterhoeven
  1 sibling, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2023-07-10 12:40 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Wolfram Sang, linux-i2c, linux-kernel, Wolfram Sang, linux-renesas-soc

On Wed, Jul 5, 2023 at 10:49 PM Paul Cercueil <paul@crapouillou.net> wrote:
> Use the new PM macros for the suspend and resume functions to be
> automatically dropped by the compiler when CONFIG_PM or
> CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.
>
> This has the advantage of always compiling these functions in,
> independently of any Kconfig option. Thanks to that, bugs and other
> regressions are subsequently easier to catch.
>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 19/23] i2c: rcar: Remove #ifdef guards for PM related functions
  2023-07-05 20:45 ` [PATCH 19/23] i2c: rcar: Remove #ifdef guards for PM related functions Paul Cercueil
  2023-07-05 20:45   ` [PATCH 21/23] i2c: sh-mobile: " Paul Cercueil
  2023-07-06  2:52   ` [PATCH 19/23] i2c: rcar: " Jonathan Cameron
@ 2023-07-10 12:41   ` Geert Uytterhoeven
  2 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2023-07-10 12:41 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Wolfram Sang, linux-i2c, linux-kernel, Wolfram Sang, linux-renesas-soc

On Wed, Jul 5, 2023 at 10:49 PM Paul Cercueil <paul@crapouillou.net> wrote:
> Use the new PM macros for the suspend and resume functions to be
> automatically dropped by the compiler when CONFIG_PM or
> CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.
>
> This has the advantage of always compiling these functions in,
> independently of any Kconfig option. Thanks to that, bugs and other
> regressions are subsequently easier to catch.
>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

end of thread, other threads:[~2023-07-10 12:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-05 20:42 [PATCH 00/23] i2c: Use new PM macros Paul Cercueil
2023-07-05 20:45 ` [PATCH 19/23] i2c: rcar: Remove #ifdef guards for PM related functions Paul Cercueil
2023-07-05 20:45   ` [PATCH 21/23] i2c: sh-mobile: " Paul Cercueil
2023-07-06  3:07     ` Jonathan Cameron
2023-07-10 12:40     ` Geert Uytterhoeven
2023-07-06  2:52   ` [PATCH 19/23] i2c: rcar: " Jonathan Cameron
2023-07-10 12:41   ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).