2023-07-22 12:24:43

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 00/22] i2c: Use new PM macros

Hi Wolfram,

Here is a revised version of my patchset that converts the I2C drivers
to use the new PM macros.

Changes since V1 include:
- Previous patch [01/23] that updated the amd-mp2 driver has been
dropped per Jonathan's request.
- [09/22]: Unfold _DEV_PM_OPS() macro
- [10/22]: Convert to use regular device PM instead of using
platform_driver.{suspend,resume}. I figured it was OK to also change
it to use the new PM macros and keep it in one single patch.
- [13/22]: Rewrap runtime PM line

Cheers,
-Paul

Paul Cercueil (22):
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: Convert to use regular device PM
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-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 | 10 +++-------
drivers/i2c/busses/i2c-kempld.c | 19 ++++++++----------
drivers/i2c/busses/i2c-lpc2k.c | 8 +-------
drivers/i2c/busses/i2c-mt65xx.c | 8 +++-----
drivers/i2c/busses/i2c-nomadik.c | 12 +++--------
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 ++----
22 files changed, 67 insertions(+), 177 deletions(-)

--
2.40.1



2023-07-22 12:27:12

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 01/22] i2c: au1550: Remove #ifdef guards for PM related functions

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.

Note that the behaviour is slightly different than before; the original
code wrapped the suspend/resume with #ifdef CONFIG_PM guards, which
resulted in these functions being compiled in but never used when
CONFIG_PM_SLEEP was disabled.

Now, those functions are only compiled in when CONFIG_PM_SLEEP is
enabled.

Signed-off-by: Paul Cercueil <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
---
drivers/i2c/busses/i2c-au1550.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/i2c/busses/i2c-au1550.c b/drivers/i2c/busses/i2c-au1550.c
index e66c12ecf270..8e43f25c117e 100644
--- a/drivers/i2c/busses/i2c-au1550.c
+++ b/drivers/i2c/busses/i2c-au1550.c
@@ -342,7 +342,6 @@ static void i2c_au1550_remove(struct platform_device *pdev)
i2c_au1550_disable(priv);
}

-#ifdef CONFIG_PM
static int i2c_au1550_suspend(struct device *dev)
{
struct i2c_au1550_data *priv = dev_get_drvdata(dev);
@@ -361,21 +360,13 @@ static int i2c_au1550_resume(struct device *dev)
return 0;
}

-static const struct dev_pm_ops i2c_au1550_pmops = {
- .suspend = i2c_au1550_suspend,
- .resume = i2c_au1550_resume,
-};
-
-#define AU1XPSC_SMBUS_PMOPS (&i2c_au1550_pmops)
-
-#else
-#define AU1XPSC_SMBUS_PMOPS NULL
-#endif
+static DEFINE_SIMPLE_DEV_PM_OPS(i2c_au1550_pmops,
+ i2c_au1550_suspend, i2c_au1550_resume);

static struct platform_driver au1xpsc_smbus_driver = {
.driver = {
.name = "au1xpsc_smbus",
- .pm = AU1XPSC_SMBUS_PMOPS,
+ .pm = pm_sleep_ptr(&i2c_au1550_pmops),
},
.probe = i2c_au1550_probe,
.remove_new = i2c_au1550_remove,
--
2.40.1


2023-07-22 12:28:03

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 20/22] i2c: sh-mobile: Remove #ifdef guards for PM related functions

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 <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Geert Uytterhoeven <[email protected]>

---
Cc: Wolfram Sang <[email protected]>
Cc: [email protected]
---
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


2023-07-22 12:28:46

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 17/22] i2c: qup: Remove #ifdef guards for PM related functions

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.

Note that the driver should probably use the DEFINE_RUNTIME_DEV_PM_OPS()
macro, as the system suspend/resume callbacks seem to not do anything
more than triggering the runtime-PM states.

Signed-off-by: Paul Cercueil <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>

---
Cc: Andy Gross <[email protected]>
Cc: Bjorn Andersson <[email protected]>
Cc: Konrad Dybcio <[email protected]>
Cc: [email protected]
---
drivers/i2c/busses/i2c-qup.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
index ae90170023b0..598102d16677 100644
--- a/drivers/i2c/busses/i2c-qup.c
+++ b/drivers/i2c/busses/i2c-qup.c
@@ -1927,7 +1927,6 @@ static void qup_i2c_remove(struct platform_device *pdev)
pm_runtime_set_suspended(qup->dev);
}

-#ifdef CONFIG_PM
static int qup_i2c_pm_suspend_runtime(struct device *device)
{
struct qup_i2c_dev *qup = dev_get_drvdata(device);
@@ -1945,9 +1944,7 @@ static int qup_i2c_pm_resume_runtime(struct device *device)
qup_i2c_enable_clocks(qup);
return 0;
}
-#endif

-#ifdef CONFIG_PM_SLEEP
static int qup_i2c_suspend(struct device *device)
{
if (!pm_runtime_suspended(device))
@@ -1962,16 +1959,11 @@ static int qup_i2c_resume(struct device *device)
pm_request_autosuspend(device);
return 0;
}
-#endif

static const struct dev_pm_ops qup_i2c_qup_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(
- qup_i2c_suspend,
- qup_i2c_resume)
- SET_RUNTIME_PM_OPS(
- qup_i2c_pm_suspend_runtime,
- qup_i2c_pm_resume_runtime,
- NULL)
+ SYSTEM_SLEEP_PM_OPS(qup_i2c_suspend, qup_i2c_resume)
+ RUNTIME_PM_OPS(qup_i2c_pm_suspend_runtime,
+ qup_i2c_pm_resume_runtime, NULL)
};

static const struct of_device_id qup_i2c_dt_match[] = {
@@ -1987,7 +1979,7 @@ static struct platform_driver qup_i2c_driver = {
.remove_new = qup_i2c_remove,
.driver = {
.name = "i2c_qup",
- .pm = &qup_i2c_qup_pm_ops,
+ .pm = pm_ptr(&qup_i2c_qup_pm_ops),
.of_match_table = qup_i2c_dt_match,
.acpi_match_table = ACPI_PTR(qup_i2c_acpi_match),
},
--
2.40.1


2023-07-22 12:29:09

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 09/22] i2c: img-scb: Remove #ifdef guards for PM related functions

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 <[email protected]>

---
v2: Unfold _DEFINE_DEV_PM_OPS() macro
---
drivers/i2c/busses/i2c-img-scb.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
index 66ba36949ab5..f9d4bfef511c 100644
--- a/drivers/i2c/busses/i2c-img-scb.c
+++ b/drivers/i2c/busses/i2c-img-scb.c
@@ -1454,7 +1454,6 @@ static int img_i2c_runtime_resume(struct device *dev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
static int img_i2c_suspend(struct device *dev)
{
struct img_i2c *i2c = dev_get_drvdata(dev);
@@ -1482,13 +1481,10 @@ static int img_i2c_resume(struct device *dev)

return 0;
}
-#endif /* CONFIG_PM_SLEEP */

static const struct dev_pm_ops img_i2c_pm = {
- SET_RUNTIME_PM_OPS(img_i2c_runtime_suspend,
- img_i2c_runtime_resume,
- NULL)
- SET_SYSTEM_SLEEP_PM_OPS(img_i2c_suspend, img_i2c_resume)
+ RUNTIME_PM_OPS(img_i2c_runtime_suspend, img_i2c_runtime_resume, NULL)
+ SYSTEM_SLEEP_PM_OPS(img_i2c_suspend, img_i2c_resume)
};

static const struct of_device_id img_scb_i2c_match[] = {
@@ -1501,7 +1497,7 @@ static struct platform_driver img_scb_i2c_driver = {
.driver = {
.name = "img-i2c-scb",
.of_match_table = img_scb_i2c_match,
- .pm = &img_i2c_pm,
+ .pm = pm_ptr(&img_i2c_pm),
},
.probe = img_i2c_probe,
.remove_new = img_i2c_remove,
--
2.40.1


2023-07-22 12:29:31

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 19/22] i2c: s3c2410: Remove #ifdef guards for PM related functions

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 <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>

---
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Alim Akhtar <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
drivers/i2c/busses/i2c-s3c2410.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 28f0e5c64f32..d23a9e7fcb48 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -1125,7 +1125,6 @@ static void s3c24xx_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(&i2c->adap);
}

-#ifdef CONFIG_PM_SLEEP
static int s3c24xx_i2c_suspend_noirq(struct device *dev)
{
struct s3c24xx_i2c *i2c = dev_get_drvdata(dev);
@@ -1155,26 +1154,19 @@ static int s3c24xx_i2c_resume_noirq(struct device *dev)

return 0;
}
-#endif

-#ifdef CONFIG_PM
static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
- SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(s3c24xx_i2c_suspend_noirq,
- s3c24xx_i2c_resume_noirq)
+ NOIRQ_SYSTEM_SLEEP_PM_OPS(s3c24xx_i2c_suspend_noirq,
+ s3c24xx_i2c_resume_noirq)
};

-#define S3C24XX_DEV_PM_OPS (&s3c24xx_i2c_dev_pm_ops)
-#else
-#define S3C24XX_DEV_PM_OPS NULL
-#endif
-
static struct platform_driver s3c24xx_i2c_driver = {
.probe = s3c24xx_i2c_probe,
.remove_new = s3c24xx_i2c_remove,
.id_table = s3c24xx_driver_ids,
.driver = {
.name = "s3c-i2c",
- .pm = S3C24XX_DEV_PM_OPS,
+ .pm = pm_sleep_ptr(&s3c24xx_i2c_dev_pm_ops),
.of_match_table = of_match_ptr(s3c24xx_i2c_match),
},
};
--
2.40.1


2023-07-22 12:33:49

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 14/22] i2c: ocores: Remove #ifdef guards for PM related functions

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 <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>

---
Cc: Peter Korsgaard <[email protected]>
Cc: Andrew Lunn <[email protected]>
---
drivers/i2c/busses/i2c-ocores.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index 4ac77e57bbbf..041a76f71a49 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -743,7 +743,6 @@ static void ocores_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(&i2c->adap);
}

-#ifdef CONFIG_PM_SLEEP
static int ocores_i2c_suspend(struct device *dev)
{
struct ocores_i2c *i2c = dev_get_drvdata(dev);
@@ -772,11 +771,8 @@ static int ocores_i2c_resume(struct device *dev)
return ocores_init(dev, i2c);
}

-static SIMPLE_DEV_PM_OPS(ocores_i2c_pm, ocores_i2c_suspend, ocores_i2c_resume);
-#define OCORES_I2C_PM (&ocores_i2c_pm)
-#else
-#define OCORES_I2C_PM NULL
-#endif
+static DEFINE_SIMPLE_DEV_PM_OPS(ocores_i2c_pm,
+ ocores_i2c_suspend, ocores_i2c_resume);

static struct platform_driver ocores_i2c_driver = {
.probe = ocores_i2c_probe,
@@ -784,7 +780,7 @@ static struct platform_driver ocores_i2c_driver = {
.driver = {
.name = "ocores-i2c",
.of_match_table = ocores_i2c_match,
- .pm = OCORES_I2C_PM,
+ .pm = pm_sleep_ptr(&ocores_i2c_pm),
},
};

--
2.40.1


2023-07-22 12:34:16

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 21/22] i2c: virtio: Remove #ifdef guards for PM related functions

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 <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Acked-by: Viresh Kumar <[email protected]>

---
Cc: Conghui Chen <[email protected]>
Cc: Viresh Kumar <[email protected]>
Cc: [email protected]
---
drivers/i2c/busses/i2c-virtio.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-virtio.c b/drivers/i2c/busses/i2c-virtio.c
index 4b9536f50800..c60ae531ba57 100644
--- a/drivers/i2c/busses/i2c-virtio.c
+++ b/drivers/i2c/busses/i2c-virtio.c
@@ -243,7 +243,6 @@ static struct virtio_device_id id_table[] = {
};
MODULE_DEVICE_TABLE(virtio, id_table);

-#ifdef CONFIG_PM_SLEEP
static int virtio_i2c_freeze(struct virtio_device *vdev)
{
virtio_i2c_del_vqs(vdev);
@@ -254,7 +253,6 @@ static int virtio_i2c_restore(struct virtio_device *vdev)
{
return virtio_i2c_setup_vqs(vdev->priv);
}
-#endif

static const unsigned int features[] = {
VIRTIO_I2C_F_ZERO_LENGTH_REQUEST,
@@ -269,10 +267,8 @@ static struct virtio_driver virtio_i2c_driver = {
.driver = {
.name = "i2c_virtio",
},
-#ifdef CONFIG_PM_SLEEP
- .freeze = virtio_i2c_freeze,
- .restore = virtio_i2c_restore,
-#endif
+ .freeze = pm_sleep_ptr(virtio_i2c_freeze),
+ .restore = pm_sleep_ptr(virtio_i2c_restore),
};
module_virtio_driver(virtio_i2c_driver);

--
2.40.1


2023-07-22 12:36:55

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 16/22] i2c: pxa: Remove #ifdef guards for PM related functions

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.

Note that the behaviour is slightly different than before; the original
code wrapped the suspend/resume with #ifdef CONFIG_PM guards, which
resulted in these functions being compiled in but never used when
CONFIG_PM_SLEEP was disabled.

Now, those functions are only compiled in when CONFIG_PM_SLEEP is
enabled.

Signed-off-by: Paul Cercueil <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
---
drivers/i2c/busses/i2c-pxa.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 937f7eebe906..65a18d73be5c 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -1491,7 +1491,6 @@ static void i2c_pxa_remove(struct platform_device *dev)
clk_disable_unprepare(i2c->clk);
}

-#ifdef CONFIG_PM
static int i2c_pxa_suspend_noirq(struct device *dev)
{
struct pxa_i2c *i2c = dev_get_drvdata(dev);
@@ -1516,17 +1515,12 @@ static const struct dev_pm_ops i2c_pxa_dev_pm_ops = {
.resume_noirq = i2c_pxa_resume_noirq,
};

-#define I2C_PXA_DEV_PM_OPS (&i2c_pxa_dev_pm_ops)
-#else
-#define I2C_PXA_DEV_PM_OPS NULL
-#endif
-
static struct platform_driver i2c_pxa_driver = {
.probe = i2c_pxa_probe,
.remove_new = i2c_pxa_remove,
.driver = {
.name = "pxa2xx-i2c",
- .pm = I2C_PXA_DEV_PM_OPS,
+ .pm = pm_sleep_ptr(&i2c_pxa_dev_pm_ops),
.of_match_table = i2c_pxa_dt_ids,
},
.id_table = i2c_pxa_id_table,
--
2.40.1


2023-07-22 12:40:15

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 08/22] i2c: i801: Remove #ifdef guards for PM related functions

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 <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>

---
Cc: Jean Delvare <[email protected]>
---
drivers/i2c/busses/i2c-i801.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 943b8e6d026d..73ae06432133 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -1808,7 +1808,6 @@ static void i801_shutdown(struct pci_dev *dev)
pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg);
}

-#ifdef CONFIG_PM_SLEEP
static int i801_suspend(struct device *dev)
{
struct i801_priv *priv = dev_get_drvdata(dev);
@@ -1827,9 +1826,8 @@ static int i801_resume(struct device *dev)

return 0;
}
-#endif

-static SIMPLE_DEV_PM_OPS(i801_pm_ops, i801_suspend, i801_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(i801_pm_ops, i801_suspend, i801_resume);

static struct pci_driver i801_driver = {
.name = DRV_NAME,
@@ -1838,7 +1836,7 @@ static struct pci_driver i801_driver = {
.remove = i801_remove,
.shutdown = i801_shutdown,
.driver = {
- .pm = &i801_pm_ops,
+ .pm = pm_sleep_ptr(&i801_pm_ops),
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
},
};
--
2.40.1


2023-07-22 12:40:15

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 03/22] i2c: brcmstb: Remove #ifdef guards for PM related functions

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 <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>

---
Cc: Kamal Dasu <[email protected]>
Cc: Broadcom internal kernel review list <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: [email protected]
---
drivers/i2c/busses/i2c-brcmstb.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-brcmstb.c b/drivers/i2c/busses/i2c-brcmstb.c
index cf92cbcb8c86..c778bcca95fe 100644
--- a/drivers/i2c/busses/i2c-brcmstb.c
+++ b/drivers/i2c/busses/i2c-brcmstb.c
@@ -697,7 +697,6 @@ static void brcmstb_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(&dev->adapter);
}

-#ifdef CONFIG_PM_SLEEP
static int brcmstb_i2c_suspend(struct device *dev)
{
struct brcmstb_i2c_dev *i2c_dev = dev_get_drvdata(dev);
@@ -715,10 +714,9 @@ static int brcmstb_i2c_resume(struct device *dev)

return 0;
}
-#endif

-static SIMPLE_DEV_PM_OPS(brcmstb_i2c_pm, brcmstb_i2c_suspend,
- brcmstb_i2c_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(brcmstb_i2c_pm, brcmstb_i2c_suspend,
+ brcmstb_i2c_resume);

static const struct of_device_id brcmstb_i2c_of_match[] = {
{.compatible = "brcm,brcmstb-i2c"},
@@ -732,7 +730,7 @@ static struct platform_driver brcmstb_i2c_driver = {
.driver = {
.name = "brcmstb-i2c",
.of_match_table = brcmstb_i2c_of_match,
- .pm = &brcmstb_i2c_pm,
+ .pm = pm_sleep_ptr(&brcmstb_i2c_pm),
},
.probe = brcmstb_i2c_probe,
.remove_new = brcmstb_i2c_remove,
--
2.40.1


2023-07-22 12:41:05

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 13/22] i2c: nomadik: Remove #ifdef guards for PM related functions

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 <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>

---
v2: Rewrapped runtime PM line

---
Cc: [email protected]
---
drivers/i2c/busses/i2c-nomadik.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 212f412f1c74..b10574d42b7a 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -873,7 +873,6 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg)
return IRQ_HANDLED;
}

-#ifdef CONFIG_PM_SLEEP
static int nmk_i2c_suspend_late(struct device *dev)
{
int ret;
@@ -890,9 +889,7 @@ static int nmk_i2c_resume_early(struct device *dev)
{
return pm_runtime_force_resume(dev);
}
-#endif

-#ifdef CONFIG_PM
static int nmk_i2c_runtime_suspend(struct device *dev)
{
struct amba_device *adev = to_amba_device(dev);
@@ -925,13 +922,10 @@ static int nmk_i2c_runtime_resume(struct device *dev)

return ret;
}
-#endif

static const struct dev_pm_ops nmk_i2c_pm = {
- SET_LATE_SYSTEM_SLEEP_PM_OPS(nmk_i2c_suspend_late, nmk_i2c_resume_early)
- SET_RUNTIME_PM_OPS(nmk_i2c_runtime_suspend,
- nmk_i2c_runtime_resume,
- NULL)
+ LATE_SYSTEM_SLEEP_PM_OPS(nmk_i2c_suspend_late, nmk_i2c_resume_early)
+ RUNTIME_PM_OPS(nmk_i2c_runtime_suspend, nmk_i2c_runtime_resume, NULL)
};

static unsigned int nmk_i2c_functionality(struct i2c_adapter *adap)
@@ -1078,7 +1072,7 @@ static struct amba_driver nmk_i2c_driver = {
.drv = {
.owner = THIS_MODULE,
.name = DRIVER_NAME,
- .pm = &nmk_i2c_pm,
+ .pm = pm_ptr(&nmk_i2c_pm),
},
.id_table = nmk_i2c_ids,
.probe = nmk_i2c_probe,
--
2.40.1


2023-07-22 12:41:05

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 11/22] i2c: lpc2k: Remove #ifdef guards for PM related functions

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.

Note that the behaviour is slightly different than before; the original
code wrapped the suspend/resume with #ifdef CONFIG_PM guards, which
resulted in these functions being compiled in but never used when
CONFIG_PM_SLEEP was disabled.

Now, those functions are only compiled in when CONFIG_PM_SLEEP is
enabled.

Signed-off-by: Paul Cercueil <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>

---
Cc: Vladimir Zapolskiy <[email protected]>
Cc: [email protected]
---
drivers/i2c/busses/i2c-lpc2k.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/i2c/busses/i2c-lpc2k.c b/drivers/i2c/busses/i2c-lpc2k.c
index 5c6d96554753..c61157f1409b 100644
--- a/drivers/i2c/busses/i2c-lpc2k.c
+++ b/drivers/i2c/busses/i2c-lpc2k.c
@@ -431,7 +431,6 @@ static void i2c_lpc2k_remove(struct platform_device *dev)
i2c_del_adapter(&i2c->adap);
}

-#ifdef CONFIG_PM
static int i2c_lpc2k_suspend(struct device *dev)
{
struct lpc2k_i2c *i2c = dev_get_drvdata(dev);
@@ -456,11 +455,6 @@ static const struct dev_pm_ops i2c_lpc2k_dev_pm_ops = {
.resume_noirq = i2c_lpc2k_resume,
};

-#define I2C_LPC2K_DEV_PM_OPS (&i2c_lpc2k_dev_pm_ops)
-#else
-#define I2C_LPC2K_DEV_PM_OPS NULL
-#endif
-
static const struct of_device_id lpc2k_i2c_match[] = {
{ .compatible = "nxp,lpc1788-i2c" },
{},
@@ -472,7 +466,7 @@ static struct platform_driver i2c_lpc2k_driver = {
.remove_new = i2c_lpc2k_remove,
.driver = {
.name = "lpc2k-i2c",
- .pm = I2C_LPC2K_DEV_PM_OPS,
+ .pm = pm_sleep_ptr(&i2c_lpc2k_dev_pm_ops),
.of_match_table = lpc2k_i2c_match,
},
};
--
2.40.1


2023-07-22 12:43:22

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH v2 22/22] i2c: mux: pca954x: Remove #ifdef guards for PM related functions

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 <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Acked-by: Peter Rosin <[email protected]>
---
drivers/i2c/muxes/i2c-mux-pca954x.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c
index 0ccee2ae5720..6965bf4c2348 100644
--- a/drivers/i2c/muxes/i2c-mux-pca954x.c
+++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
@@ -530,7 +530,6 @@ static void pca954x_remove(struct i2c_client *client)
pca954x_cleanup(muxc);
}

-#ifdef CONFIG_PM_SLEEP
static int pca954x_resume(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
@@ -544,14 +543,13 @@ static int pca954x_resume(struct device *dev)

return ret;
}
-#endif

-static SIMPLE_DEV_PM_OPS(pca954x_pm, NULL, pca954x_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(pca954x_pm, NULL, pca954x_resume);

static struct i2c_driver pca954x_driver = {
.driver = {
.name = "pca954x",
- .pm = &pca954x_pm,
+ .pm = pm_sleep_ptr(&pca954x_pm),
.of_match_table = pca954x_of_match,
},
.probe = pca954x_probe,
--
2.40.1


2023-07-22 14:46:13

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v2 21/22] i2c: virtio: Remove #ifdef guards for PM related functions

Hi Paul,

kernel test robot noticed the following build errors:

[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on brgl/gpio/for-next krzk/for-next linus/master v6.5-rc2 next-20230721]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Paul-Cercueil/i2c-au1550-Remove-ifdef-guards-for-PM-related-functions/20230722-200209
base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link: https://lore.kernel.org/r/20230722115310.27681-5-paul%40crapouillou.net
patch subject: [PATCH v2 21/22] i2c: virtio: Remove #ifdef guards for PM related functions
config: nios2-randconfig-r005-20230722 (https://download.01.org/0day-ci/archive/20230722/[email protected]/config)
compiler: nios2-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230722/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/i2c/busses/i2c-virtio.c:270:10: error: 'struct virtio_driver' has no member named 'freeze'
270 | .freeze = pm_sleep_ptr(virtio_i2c_freeze),
| ^~~~~~
In file included from include/linux/cpumask.h:10,
from include/linux/smp.h:13,
from include/linux/lockdep.h:14,
from include/linux/spinlock.h:63,
from include/linux/mmzone.h:8,
from include/linux/gfp.h:7,
from include/linux/slab.h:16,
from include/linux/resource_ext.h:11,
from include/linux/acpi.h:13,
from drivers/i2c/busses/i2c-virtio.c:11:
>> include/linux/kernel.h:58:33: error: initialization of 'const struct virtio_device_id *' from incompatible pointer type 'int (*)(struct virtio_device *)' [-Werror=incompatible-pointer-types]
58 | #define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL)
| ^
include/linux/pm.h:452:28: note: in expansion of macro 'PTR_IF'
452 | #define pm_sleep_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM_SLEEP), (_ptr))
| ^~~~~~
drivers/i2c/busses/i2c-virtio.c:270:35: note: in expansion of macro 'pm_sleep_ptr'
270 | .freeze = pm_sleep_ptr(virtio_i2c_freeze),
| ^~~~~~~~~~~~
include/linux/kernel.h:58:33: note: (near initialization for 'virtio_i2c_driver.id_table')
58 | #define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL)
| ^
include/linux/pm.h:452:28: note: in expansion of macro 'PTR_IF'
452 | #define pm_sleep_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM_SLEEP), (_ptr))
| ^~~~~~
drivers/i2c/busses/i2c-virtio.c:270:35: note: in expansion of macro 'pm_sleep_ptr'
270 | .freeze = pm_sleep_ptr(virtio_i2c_freeze),
| ^~~~~~~~~~~~
include/linux/kernel.h:58:33: warning: initialized field overwritten [-Woverride-init]
58 | #define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL)
| ^
include/linux/pm.h:452:28: note: in expansion of macro 'PTR_IF'
452 | #define pm_sleep_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM_SLEEP), (_ptr))
| ^~~~~~
drivers/i2c/busses/i2c-virtio.c:270:35: note: in expansion of macro 'pm_sleep_ptr'
270 | .freeze = pm_sleep_ptr(virtio_i2c_freeze),
| ^~~~~~~~~~~~
include/linux/kernel.h:58:33: note: (near initialization for 'virtio_i2c_driver.id_table')
58 | #define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL)
| ^
include/linux/pm.h:452:28: note: in expansion of macro 'PTR_IF'
452 | #define pm_sleep_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM_SLEEP), (_ptr))
| ^~~~~~
drivers/i2c/busses/i2c-virtio.c:270:35: note: in expansion of macro 'pm_sleep_ptr'
270 | .freeze = pm_sleep_ptr(virtio_i2c_freeze),
| ^~~~~~~~~~~~
>> drivers/i2c/busses/i2c-virtio.c:271:10: error: 'struct virtio_driver' has no member named 'restore'
271 | .restore = pm_sleep_ptr(virtio_i2c_restore),
| ^~~~~~~
>> include/linux/kernel.h:58:33: error: initialization of 'const unsigned int *' from incompatible pointer type 'int (*)(struct virtio_device *)' [-Werror=incompatible-pointer-types]
58 | #define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL)
| ^
include/linux/pm.h:452:28: note: in expansion of macro 'PTR_IF'
452 | #define pm_sleep_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM_SLEEP), (_ptr))
| ^~~~~~
drivers/i2c/busses/i2c-virtio.c:271:35: note: in expansion of macro 'pm_sleep_ptr'
271 | .restore = pm_sleep_ptr(virtio_i2c_restore),
| ^~~~~~~~~~~~
include/linux/kernel.h:58:33: note: (near initialization for 'virtio_i2c_driver.feature_table')
58 | #define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL)
| ^
include/linux/pm.h:452:28: note: in expansion of macro 'PTR_IF'
452 | #define pm_sleep_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM_SLEEP), (_ptr))
| ^~~~~~
drivers/i2c/busses/i2c-virtio.c:271:35: note: in expansion of macro 'pm_sleep_ptr'
271 | .restore = pm_sleep_ptr(virtio_i2c_restore),
| ^~~~~~~~~~~~
include/linux/kernel.h:58:33: warning: initialized field overwritten [-Woverride-init]
58 | #define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL)
| ^
include/linux/pm.h:452:28: note: in expansion of macro 'PTR_IF'
452 | #define pm_sleep_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM_SLEEP), (_ptr))
| ^~~~~~
drivers/i2c/busses/i2c-virtio.c:271:35: note: in expansion of macro 'pm_sleep_ptr'
271 | .restore = pm_sleep_ptr(virtio_i2c_restore),
| ^~~~~~~~~~~~
include/linux/kernel.h:58:33: note: (near initialization for 'virtio_i2c_driver.feature_table')
58 | #define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL)
| ^
include/linux/pm.h:452:28: note: in expansion of macro 'PTR_IF'
452 | #define pm_sleep_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM_SLEEP), (_ptr))
| ^~~~~~
drivers/i2c/busses/i2c-virtio.c:271:35: note: in expansion of macro 'pm_sleep_ptr'
271 | .restore = pm_sleep_ptr(virtio_i2c_restore),
| ^~~~~~~~~~~~
cc1: some warnings being treated as errors


vim +270 drivers/i2c/busses/i2c-virtio.c

260
261 static struct virtio_driver virtio_i2c_driver = {
262 .feature_table = features,
263 .feature_table_size = ARRAY_SIZE(features),
264 .id_table = id_table,
265 .probe = virtio_i2c_probe,
266 .remove = virtio_i2c_remove,
267 .driver = {
268 .name = "i2c_virtio",
269 },
> 270 .freeze = pm_sleep_ptr(virtio_i2c_freeze),
> 271 .restore = pm_sleep_ptr(virtio_i2c_restore),
272 };
273 module_virtio_driver(virtio_i2c_driver);
274

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2023-07-22 16:01:38

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v2 21/22] i2c: virtio: Remove #ifdef guards for PM related functions

Hi Paul,

kernel test robot noticed the following build errors:

[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on brgl/gpio/for-next krzk/for-next linus/master v6.5-rc2 next-20230721]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Paul-Cercueil/i2c-au1550-Remove-ifdef-guards-for-PM-related-functions/20230722-200209
base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link: https://lore.kernel.org/r/20230722115310.27681-5-paul%40crapouillou.net
patch subject: [PATCH v2 21/22] i2c: virtio: Remove #ifdef guards for PM related functions
config: i386-randconfig-r015-20230722 (https://download.01.org/0day-ci/archive/20230722/[email protected]/config)
compiler: clang version 15.0.7 (https://github.com/llvm/llvm-project.git 8dfdcc7b7bf66834a761bd8de445840ef68e4d1a)
reproduce: (https://download.01.org/0day-ci/archive/20230722/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/i2c/busses/i2c-virtio.c:270:3: error: field designator 'freeze' does not refer to any field in type 'struct virtio_driver'
.freeze = pm_sleep_ptr(virtio_i2c_freeze),
^
>> drivers/i2c/busses/i2c-virtio.c:271:3: error: field designator 'restore' does not refer to any field in type 'struct virtio_driver'
.restore = pm_sleep_ptr(virtio_i2c_restore),
^
2 errors generated.


vim +270 drivers/i2c/busses/i2c-virtio.c

260
261 static struct virtio_driver virtio_i2c_driver = {
262 .feature_table = features,
263 .feature_table_size = ARRAY_SIZE(features),
264 .id_table = id_table,
265 .probe = virtio_i2c_probe,
266 .remove = virtio_i2c_remove,
267 .driver = {
268 .name = "i2c_virtio",
269 },
> 270 .freeze = pm_sleep_ptr(virtio_i2c_freeze),
> 271 .restore = pm_sleep_ptr(virtio_i2c_restore),
272 };
273 module_virtio_driver(virtio_i2c_driver);
274

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2023-07-22 16:16:10

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH v2 03/22] i2c: brcmstb: Remove #ifdef guards for PM related functions



On 7/22/2023 4:50 AM, Paul Cercueil 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 <[email protected]>
> Reviewed-by: Jonathan Cameron <[email protected]>

Reviewed-by: Florian Fainelli <[email protected]>
--
Florian


Attachments:
smime.p7s (4.12 kB)
S/MIME Cryptographic Signature

2023-07-22 19:08:44

by Paul Cercueil

[permalink] [raw]
Subject: Re: [PATCH v2 21/22] i2c: virtio: Remove #ifdef guards for PM related functions

As the build bot noticed - this patch is invalid as the
virtio_driver.{freeze,restore} callbacks are guarded by #ifdefs.

Feel free to apply the rest (if everybody is happy with them) and I'll
respin this one.

Cheers,
-Paul

Le samedi 22 juillet 2023 à 13:53 +0200, Paul Cercueil a écrit :
> 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 <[email protected]>
> Reviewed-by: Jonathan Cameron <[email protected]>
> Acked-by: Viresh Kumar <[email protected]>
>
> ---
> Cc: Conghui Chen <[email protected]>
> Cc: Viresh Kumar <[email protected]>
> Cc: [email protected]
> ---
>  drivers/i2c/busses/i2c-virtio.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-virtio.c
> b/drivers/i2c/busses/i2c-virtio.c
> index 4b9536f50800..c60ae531ba57 100644
> --- a/drivers/i2c/busses/i2c-virtio.c
> +++ b/drivers/i2c/busses/i2c-virtio.c
> @@ -243,7 +243,6 @@ static struct virtio_device_id id_table[] = {
>  };
>  MODULE_DEVICE_TABLE(virtio, id_table);
>  
> -#ifdef CONFIG_PM_SLEEP
>  static int virtio_i2c_freeze(struct virtio_device *vdev)
>  {
>         virtio_i2c_del_vqs(vdev);
> @@ -254,7 +253,6 @@ static int virtio_i2c_restore(struct
> virtio_device *vdev)
>  {
>         return virtio_i2c_setup_vqs(vdev->priv);
>  }
> -#endif
>  
>  static const unsigned int features[] = {
>         VIRTIO_I2C_F_ZERO_LENGTH_REQUEST,
> @@ -269,10 +267,8 @@ static struct virtio_driver virtio_i2c_driver =
> {
>         .driver                 = {
>                 .name   = "i2c_virtio",
>         },
> -#ifdef CONFIG_PM_SLEEP
> -       .freeze = virtio_i2c_freeze,
> -       .restore = virtio_i2c_restore,
> -#endif
> +       .freeze                 = pm_sleep_ptr(virtio_i2c_freeze),
> +       .restore                = pm_sleep_ptr(virtio_i2c_restore),
>  };
>  module_virtio_driver(virtio_i2c_driver);
>  


2023-07-28 13:27:46

by Andi Shyti

[permalink] [raw]
Subject: Re: [PATCH v2 09/22] i2c: img-scb: Remove #ifdef guards for PM related functions

Hi Paul,

On Sat, Jul 22, 2023 at 01:50:33PM +0200, Paul Cercueil 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 <[email protected]>

Acked-by: Andi Shyti <[email protected]>

Andi

2023-08-02 20:57:09

by Andi Shyti

[permalink] [raw]
Subject: Re: [PATCH v2 00/22] i2c: Use new PM macros

Hi

On Sat, 22 Jul 2023 13:50:24 +0200, Paul Cercueil wrote:
> Here is a revised version of my patchset that converts the I2C drivers
> to use the new PM macros.
>
> Changes since V1 include:
> - Previous patch [01/23] that updated the amd-mp2 driver has been
> dropped per Jonathan's request.
> - [09/22]: Unfold _DEV_PM_OPS() macro
> - [10/22]: Convert to use regular device PM instead of using
> platform_driver.{suspend,resume}. I figured it was OK to also change
> it to use the new PM macros and keep it in one single patch.
> - [13/22]: Rewrap runtime PM line
>
> [...]

Applied to i2c/andi-for-next on

https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git

Please note that this patch may still undergo further evaluation
and the final decision will be made in collaboration with
Wolfram.

Thank you,
Andi

Patches applied
===============
[01/22] i2c: au1550: Remove #ifdef guards for PM related functions
commit: 45a21c833d23848487963cb5d7eab27d748d2491
[02/22] i2c: iproc: Remove #ifdef guards for PM related functions
commit: 679e955c54d83743184c06ffdfae62fcd406825b
[03/22] i2c: brcmstb: Remove #ifdef guards for PM related functions
commit: 6079d3054ba1ffdd3b85fd0b006a7130762ef2b0
[04/22] i2c: davinci: Remove #ifdef guards for PM related functions
commit: d81a91c4bbeac742284cf34edd6ccf121cd15ddb
[05/22] i2c: designware: Remove #ifdef guards for PM related functions
commit: a6ca696a40af0f652dc79b480dbd54096672d2b5
[06/22] i2c: exynos5: Remove #ifdef guards for PM related functions
commit: af65727a77cc3c90e6d01bad387c7c8f337af2ad
[07/22] i2c: hix5hd2: Remove #ifdef guards for PM related functions
commit: 38373903059c7e82d141007fe311cba237a00e86
[08/22] i2c: i801: Remove #ifdef guards for PM related functions
commit: 02d1b6a99b4c5b4f05343aea46da96a8f795836c
[09/22] i2c: img-scb: Remove #ifdef guards for PM related functions
commit: d2150e96646ddbd9a0f7f193107e7c310cbbe455
[10/22] i2c: kempld: Convert to use regular device PM
commit: abef155faf2bb13b7aca9c2df74d63bb81ebcd55
[11/22] i2c: lpc2k: Remove #ifdef guards for PM related functions
commit: a31425a6d93571433aa254b1eb4262ed378a08c2
[12/22] i2c: mt65xx: Remove #ifdef guards for PM related functions
commit: 910047e7741fbfe15a4fdb14de7a2c3d72284d9f
[13/22] i2c: nomadik: Remove #ifdef guards for PM related functions
commit: d55ee2c2f6fe629e6f8eb5b9c824b2545bc9b5d2
[14/22] i2c: ocores: Remove #ifdef guards for PM related functions
commit: f5e33fcc30fa1e4085d6381f50b4f35ca412d708
[15/22] i2c: pnx: Remove #ifdef guards for PM related functions
commit: 1670c7091b2aead73c21f3f27bbac44943d739ae
[16/22] i2c: pxa: Remove #ifdef guards for PM related functions
commit: 605b9efba5d6a290f7ea41bd23ee5a11c3bacfcf
[17/22] i2c: qup: Remove #ifdef guards for PM related functions
commit: aeb96820afefc02b8ac287685c9f6c75e2e56b31
[18/22] i2c: rcar: Remove #ifdef guards for PM related functions
commit: dd4e0c0b6f01cf1c42d8bbb4a29d657a44a64bc0
[19/22] i2c: s3c2410: Remove #ifdef guards for PM related functions
commit: 386d59093b247b258c6257525ff7c74b8ee9e6ca
[20/22] i2c: sh-mobile: Remove #ifdef guards for PM related functions
commit: 8a76e5af8731db81ab325e734c5acfc386d3139c
[21/22] i2c: virtio: Remove #ifdef guards for PM related functions
commit: 61999179835e23f4b245258087bfc20cf3c082ee
[22/22] i2c: mux: pca954x: Remove #ifdef guards for PM related functions
commit: 458405d7c5b85e60a1b68972d1432d20fa9dc557

2023-08-10 16:29:13

by Jean Delvare

[permalink] [raw]
Subject: Re: [PATCH v2 08/22] i2c: i801: Remove #ifdef guards for PM related functions

Hi Paul,

On Sat, 22 Jul 2023 13:50:32 +0200, Paul Cercueil 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 <[email protected]>
> Reviewed-by: Jonathan Cameron <[email protected]>
>
> ---
> Cc: Jean Delvare <[email protected]>
> ---
> drivers/i2c/busses/i2c-i801.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
> index 943b8e6d026d..73ae06432133 100644
> --- a/drivers/i2c/busses/i2c-i801.c
> +++ b/drivers/i2c/busses/i2c-i801.c
> @@ -1808,7 +1808,6 @@ static void i801_shutdown(struct pci_dev *dev)
> pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg);
> }
>
> -#ifdef CONFIG_PM_SLEEP
> static int i801_suspend(struct device *dev)
> {
> struct i801_priv *priv = dev_get_drvdata(dev);
> @@ -1827,9 +1826,8 @@ static int i801_resume(struct device *dev)
>
> return 0;
> }
> -#endif
>
> -static SIMPLE_DEV_PM_OPS(i801_pm_ops, i801_suspend, i801_resume);
> +static DEFINE_SIMPLE_DEV_PM_OPS(i801_pm_ops, i801_suspend, i801_resume);
>
> static struct pci_driver i801_driver = {
> .name = DRV_NAME,
> @@ -1838,7 +1836,7 @@ static struct pci_driver i801_driver = {
> .remove = i801_remove,
> .shutdown = i801_shutdown,
> .driver = {
> - .pm = &i801_pm_ops,
> + .pm = pm_sleep_ptr(&i801_pm_ops),
> .probe_type = PROBE_PREFER_ASYNCHRONOUS,
> },
> };

As far as I can see, this is the same as:

https://lore.kernel.org/linux-i2c/[email protected]/T/#mbd96bc42299e23f43ff1ebd56e61656882994afc

submitted by Heiner Kallweit back in March, review by myself in June,
but not applied yet. So:

Reviewed-by: Jean Delvare <[email protected]>

--
Jean Delvare
SUSE L3 Support

2023-08-14 15:14:33

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH v2 00/22] i2c: Use new PM macros

On Wed, Aug 02, 2023 at 10:10:34PM +0200, Andi Shyti wrote:
> Hi
>
> On Sat, 22 Jul 2023 13:50:24 +0200, Paul Cercueil wrote:
> > Here is a revised version of my patchset that converts the I2C drivers
> > to use the new PM macros.
> >
> > Changes since V1 include:
> > - Previous patch [01/23] that updated the amd-mp2 driver has been
> > dropped per Jonathan's request.
> > - [09/22]: Unfold _DEV_PM_OPS() macro
> > - [10/22]: Convert to use regular device PM instead of using
> > platform_driver.{suspend,resume}. I figured it was OK to also change
> > it to use the new PM macros and keep it in one single patch.
> > - [13/22]: Rewrap runtime PM line
> >
> > [...]

Applied to for-next (via Andi's branch), thanks!


Attachments:
(No filename) (748.00 B)
signature.asc (849.00 B)
Download all attachments