2023-07-05 21:18:37

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 22/23] 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]>

---
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-06 03:28:18

by Jonathan Cameron

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

On Wed, 5 Jul 2023 22:45:20 +0200
Paul Cercueil <[email protected]> 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]>

2023-07-06 04:53:51

by Viresh Kumar

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

On 05-07-23, 22:45, 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]>
>
> ---
> 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);
>

Acked-by: Viresh Kumar <[email protected]>

--
viresh