* [PATCH 0/2] iio: Convert some drivers from deprecated UNIVERSAL_DEV_PM_OPS()
@ 2022-08-07 19:04 Jonathan Cameron
2022-08-07 19:04 ` [PATCH 1/2] iio: pressure: icp10100: Switch from UNIVERSAL to DEFINE_RUNTIME_DEV_PM_OPS() Jonathan Cameron
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Jonathan Cameron @ 2022-08-07 19:04 UTC (permalink / raw)
To: linux-iio
Cc: Paul Cercueil, Jean-Baptiste Maneyrol, Crt Mori, Jonathan Cameron
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
During discussions of the new PM macro definitions, it because clear that
UNIVERSAL_DEV_PM_OPS() generally doesn't make much sense as it can lead
to unnecessary work.
For the drivers in this set I've taken a look at how the ops are used
and believe we can just switch to DEFINE_RUNTIME_PM_OPS() which will only
do the suspend if the device is not already runtime suspended.
I'd like some review of these (more than for the straight forward NOP conversions).
Thanks,
Jonathan
Jonathan Cameron (2):
iio: pressure: icp10100: Switch from UNIVERSAL to
DEFINE_RUNTIME_DEV_PM_OPS().
iio: temp: mlx90632: Switch form UNVIVERSAL to
DEFINE_RUNTIME_DEV_PM_OPS()
drivers/iio/pressure/icp10100.c | 10 +++++-----
drivers/iio/temperature/mlx90632.c | 10 +++++-----
2 files changed, 10 insertions(+), 10 deletions(-)
--
2.37.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] iio: pressure: icp10100: Switch from UNIVERSAL to DEFINE_RUNTIME_DEV_PM_OPS().
2022-08-07 19:04 [PATCH 0/2] iio: Convert some drivers from deprecated UNIVERSAL_DEV_PM_OPS() Jonathan Cameron
@ 2022-08-07 19:04 ` Jonathan Cameron
2022-08-16 13:13 ` Jean-Baptiste Maneyrol
2022-08-07 19:04 ` [PATCH 2/2] iio: temp: mlx90632: Switch form UNVIVERSAL " Jonathan Cameron
2022-08-08 9:30 ` [PATCH 0/2] iio: Convert some drivers from deprecated UNIVERSAL_DEV_PM_OPS() Andy Shevchenko
2 siblings, 1 reply; 9+ messages in thread
From: Jonathan Cameron @ 2022-08-07 19:04 UTC (permalink / raw)
To: linux-iio
Cc: Paul Cercueil, Jean-Baptiste Maneyrol, Crt Mori, Jonathan Cameron
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
The suspend and resume callbacks in this driver appear to be safe
to call repeatedly, but why do so when we can use the
DEFINE_RUNTIME_DEV_PM_OPS() macro to supply callbacks that check if
we are already runtime suspended before doing unnecessary work.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
---
drivers/iio/pressure/icp10100.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/pressure/icp10100.c b/drivers/iio/pressure/icp10100.c
index af4621eaa6b5..b62f28585db5 100644
--- a/drivers/iio/pressure/icp10100.c
+++ b/drivers/iio/pressure/icp10100.c
@@ -595,7 +595,7 @@ static int icp10100_probe(struct i2c_client *client,
return devm_iio_device_register(&client->dev, indio_dev);
}
-static int __maybe_unused icp10100_suspend(struct device *dev)
+static int icp10100_suspend(struct device *dev)
{
struct icp10100_state *st = iio_priv(dev_get_drvdata(dev));
int ret;
@@ -607,7 +607,7 @@ static int __maybe_unused icp10100_suspend(struct device *dev)
return ret;
}
-static int __maybe_unused icp10100_resume(struct device *dev)
+static int icp10100_resume(struct device *dev)
{
struct icp10100_state *st = iio_priv(dev_get_drvdata(dev));
int ret;
@@ -626,8 +626,8 @@ static int __maybe_unused icp10100_resume(struct device *dev)
return ret;
}
-static UNIVERSAL_DEV_PM_OPS(icp10100_pm, icp10100_suspend, icp10100_resume,
- NULL);
+static DEFINE_RUNTIME_DEV_PM_OPS(icp10100_pm, icp10100_suspend, icp10100_resume,
+ NULL);
static const struct of_device_id icp10100_of_match[] = {
{
@@ -646,7 +646,7 @@ MODULE_DEVICE_TABLE(i2c, icp10100_id);
static struct i2c_driver icp10100_driver = {
.driver = {
.name = "icp10100",
- .pm = &icp10100_pm,
+ .pm = pm_ptr(&icp10100_pm),
.of_match_table = icp10100_of_match,
},
.probe = icp10100_probe,
--
2.37.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] iio: temp: mlx90632: Switch form UNVIVERSAL to DEFINE_RUNTIME_DEV_PM_OPS()
2022-08-07 19:04 [PATCH 0/2] iio: Convert some drivers from deprecated UNIVERSAL_DEV_PM_OPS() Jonathan Cameron
2022-08-07 19:04 ` [PATCH 1/2] iio: pressure: icp10100: Switch from UNIVERSAL to DEFINE_RUNTIME_DEV_PM_OPS() Jonathan Cameron
@ 2022-08-07 19:04 ` Jonathan Cameron
2022-08-08 11:26 ` Crt Mori
2022-08-08 9:30 ` [PATCH 0/2] iio: Convert some drivers from deprecated UNIVERSAL_DEV_PM_OPS() Andy Shevchenko
2 siblings, 1 reply; 9+ messages in thread
From: Jonathan Cameron @ 2022-08-07 19:04 UTC (permalink / raw)
To: linux-iio
Cc: Paul Cercueil, Jean-Baptiste Maneyrol, Crt Mori, Jonathan Cameron
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
The callbacks in this driver are simple and it doesn't matter if
they are unnecessarily called multiple times. However, we might as
well not repeat the effort if the device is already suspended.
The new DEFINE_RUNTIME_DEV_PM_OPS() has the advantage that we don't
need to mark the callbacks __maybe_unused. The compiler will still
remove them for us if CONFIG_PM is not set.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Crt Mori <cmo@melexis.com>
---
drivers/iio/temperature/mlx90632.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/temperature/mlx90632.c b/drivers/iio/temperature/mlx90632.c
index 7ee7ff8047a4..9fc69d099784 100644
--- a/drivers/iio/temperature/mlx90632.c
+++ b/drivers/iio/temperature/mlx90632.c
@@ -952,7 +952,7 @@ static const struct of_device_id mlx90632_of_match[] = {
};
MODULE_DEVICE_TABLE(of, mlx90632_of_match);
-static int __maybe_unused mlx90632_pm_suspend(struct device *dev)
+static int mlx90632_pm_suspend(struct device *dev)
{
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
struct mlx90632_data *data = iio_priv(indio_dev);
@@ -960,7 +960,7 @@ static int __maybe_unused mlx90632_pm_suspend(struct device *dev)
return mlx90632_sleep(data);
}
-static int __maybe_unused mlx90632_pm_resume(struct device *dev)
+static int mlx90632_pm_resume(struct device *dev)
{
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
struct mlx90632_data *data = iio_priv(indio_dev);
@@ -968,14 +968,14 @@ static int __maybe_unused mlx90632_pm_resume(struct device *dev)
return mlx90632_wakeup(data);
}
-static UNIVERSAL_DEV_PM_OPS(mlx90632_pm_ops, mlx90632_pm_suspend,
- mlx90632_pm_resume, NULL);
+static DEFINE_RUNTIME_DEV_PM_OPS(mlx90632_pm_ops, mlx90632_pm_suspend,
+ mlx90632_pm_resume, NULL);
static struct i2c_driver mlx90632_driver = {
.driver = {
.name = "mlx90632",
.of_match_table = mlx90632_of_match,
- .pm = &mlx90632_pm_ops,
+ .pm = pm_ptr(&mlx90632_pm_ops),
},
.probe = mlx90632_probe,
.remove = mlx90632_remove,
--
2.37.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] iio: Convert some drivers from deprecated UNIVERSAL_DEV_PM_OPS()
2022-08-07 19:04 [PATCH 0/2] iio: Convert some drivers from deprecated UNIVERSAL_DEV_PM_OPS() Jonathan Cameron
2022-08-07 19:04 ` [PATCH 1/2] iio: pressure: icp10100: Switch from UNIVERSAL to DEFINE_RUNTIME_DEV_PM_OPS() Jonathan Cameron
2022-08-07 19:04 ` [PATCH 2/2] iio: temp: mlx90632: Switch form UNVIVERSAL " Jonathan Cameron
@ 2022-08-08 9:30 ` Andy Shevchenko
2 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2022-08-08 9:30 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-iio, Paul Cercueil, Jean-Baptiste Maneyrol, Crt Mori,
Jonathan Cameron
On Sun, Aug 7, 2022 at 8:59 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> During discussions of the new PM macro definitions, it because clear that
> UNIVERSAL_DEV_PM_OPS() generally doesn't make much sense as it can lead
> to unnecessary work.
>
> For the drivers in this set I've taken a look at how the ops are used
> and believe we can just switch to DEFINE_RUNTIME_PM_OPS() which will only
> do the suspend if the device is not already runtime suspended.
>
> I'd like some review of these (more than for the straight forward NOP conversions).
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Thanks,
>
> Jonathan
>
>
> Jonathan Cameron (2):
> iio: pressure: icp10100: Switch from UNIVERSAL to
> DEFINE_RUNTIME_DEV_PM_OPS().
> iio: temp: mlx90632: Switch form UNVIVERSAL to
> DEFINE_RUNTIME_DEV_PM_OPS()
>
> drivers/iio/pressure/icp10100.c | 10 +++++-----
> drivers/iio/temperature/mlx90632.c | 10 +++++-----
> 2 files changed, 10 insertions(+), 10 deletions(-)
>
> --
> 2.37.1
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] iio: temp: mlx90632: Switch form UNVIVERSAL to DEFINE_RUNTIME_DEV_PM_OPS()
2022-08-07 19:04 ` [PATCH 2/2] iio: temp: mlx90632: Switch form UNVIVERSAL " Jonathan Cameron
@ 2022-08-08 11:26 ` Crt Mori
2022-08-11 14:18 ` Jonathan Cameron
0 siblings, 1 reply; 9+ messages in thread
From: Crt Mori @ 2022-08-08 11:26 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-iio, Paul Cercueil, Jean-Baptiste Maneyrol,
Jonathan Cameron
Not sure if I should apply both but:
Acked-by: Crt Mori <cmo@melexis.com>
Tested-by: Crt Mori <cmo@melexis.com>
On Sun, 7 Aug 2022 at 20:54, Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> The callbacks in this driver are simple and it doesn't matter if
> they are unnecessarily called multiple times. However, we might as
> well not repeat the effort if the device is already suspended.
> The new DEFINE_RUNTIME_DEV_PM_OPS() has the advantage that we don't
> need to mark the callbacks __maybe_unused. The compiler will still
> remove them for us if CONFIG_PM is not set.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Crt Mori <cmo@melexis.com>
> ---
> drivers/iio/temperature/mlx90632.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/temperature/mlx90632.c b/drivers/iio/temperature/mlx90632.c
> index 7ee7ff8047a4..9fc69d099784 100644
> --- a/drivers/iio/temperature/mlx90632.c
> +++ b/drivers/iio/temperature/mlx90632.c
> @@ -952,7 +952,7 @@ static const struct of_device_id mlx90632_of_match[] = {
> };
> MODULE_DEVICE_TABLE(of, mlx90632_of_match);
>
> -static int __maybe_unused mlx90632_pm_suspend(struct device *dev)
> +static int mlx90632_pm_suspend(struct device *dev)
> {
> struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> struct mlx90632_data *data = iio_priv(indio_dev);
> @@ -960,7 +960,7 @@ static int __maybe_unused mlx90632_pm_suspend(struct device *dev)
> return mlx90632_sleep(data);
> }
>
> -static int __maybe_unused mlx90632_pm_resume(struct device *dev)
> +static int mlx90632_pm_resume(struct device *dev)
> {
> struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> struct mlx90632_data *data = iio_priv(indio_dev);
> @@ -968,14 +968,14 @@ static int __maybe_unused mlx90632_pm_resume(struct device *dev)
> return mlx90632_wakeup(data);
> }
>
> -static UNIVERSAL_DEV_PM_OPS(mlx90632_pm_ops, mlx90632_pm_suspend,
> - mlx90632_pm_resume, NULL);
> +static DEFINE_RUNTIME_DEV_PM_OPS(mlx90632_pm_ops, mlx90632_pm_suspend,
> + mlx90632_pm_resume, NULL);
>
> static struct i2c_driver mlx90632_driver = {
> .driver = {
> .name = "mlx90632",
> .of_match_table = mlx90632_of_match,
> - .pm = &mlx90632_pm_ops,
> + .pm = pm_ptr(&mlx90632_pm_ops),
> },
> .probe = mlx90632_probe,
> .remove = mlx90632_remove,
> --
> 2.37.1
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] iio: temp: mlx90632: Switch form UNVIVERSAL to DEFINE_RUNTIME_DEV_PM_OPS()
2022-08-08 11:26 ` Crt Mori
@ 2022-08-11 14:18 ` Jonathan Cameron
2022-09-04 16:42 ` Jonathan Cameron
0 siblings, 1 reply; 9+ messages in thread
From: Jonathan Cameron @ 2022-08-11 14:18 UTC (permalink / raw)
To: Crt Mori; +Cc: Jonathan Cameron, linux-iio, Paul Cercueil,
Jean-Baptiste Maneyrol
On Mon, 8 Aug 2022 13:26:42 +0200
Crt Mori <cmo@melexis.com> wrote:
> Not sure if I should apply both but:
>
> Acked-by: Crt Mori <cmo@melexis.com>
> Tested-by: Crt Mori <cmo@melexis.com>
Absolutely. Both is perfect. Thanks!
>
>
> On Sun, 7 Aug 2022 at 20:54, Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > The callbacks in this driver are simple and it doesn't matter if
> > they are unnecessarily called multiple times. However, we might as
> > well not repeat the effort if the device is already suspended.
> > The new DEFINE_RUNTIME_DEV_PM_OPS() has the advantage that we don't
> > need to mark the callbacks __maybe_unused. The compiler will still
> > remove them for us if CONFIG_PM is not set.
> >
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Crt Mori <cmo@melexis.com>
> > ---
> > drivers/iio/temperature/mlx90632.c | 10 +++++-----
> > 1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/iio/temperature/mlx90632.c b/drivers/iio/temperature/mlx90632.c
> > index 7ee7ff8047a4..9fc69d099784 100644
> > --- a/drivers/iio/temperature/mlx90632.c
> > +++ b/drivers/iio/temperature/mlx90632.c
> > @@ -952,7 +952,7 @@ static const struct of_device_id mlx90632_of_match[] = {
> > };
> > MODULE_DEVICE_TABLE(of, mlx90632_of_match);
> >
> > -static int __maybe_unused mlx90632_pm_suspend(struct device *dev)
> > +static int mlx90632_pm_suspend(struct device *dev)
> > {
> > struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> > struct mlx90632_data *data = iio_priv(indio_dev);
> > @@ -960,7 +960,7 @@ static int __maybe_unused mlx90632_pm_suspend(struct device *dev)
> > return mlx90632_sleep(data);
> > }
> >
> > -static int __maybe_unused mlx90632_pm_resume(struct device *dev)
> > +static int mlx90632_pm_resume(struct device *dev)
> > {
> > struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> > struct mlx90632_data *data = iio_priv(indio_dev);
> > @@ -968,14 +968,14 @@ static int __maybe_unused mlx90632_pm_resume(struct device *dev)
> > return mlx90632_wakeup(data);
> > }
> >
> > -static UNIVERSAL_DEV_PM_OPS(mlx90632_pm_ops, mlx90632_pm_suspend,
> > - mlx90632_pm_resume, NULL);
> > +static DEFINE_RUNTIME_DEV_PM_OPS(mlx90632_pm_ops, mlx90632_pm_suspend,
> > + mlx90632_pm_resume, NULL);
> >
> > static struct i2c_driver mlx90632_driver = {
> > .driver = {
> > .name = "mlx90632",
> > .of_match_table = mlx90632_of_match,
> > - .pm = &mlx90632_pm_ops,
> > + .pm = pm_ptr(&mlx90632_pm_ops),
> > },
> > .probe = mlx90632_probe,
> > .remove = mlx90632_remove,
> > --
> > 2.37.1
> >
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] iio: pressure: icp10100: Switch from UNIVERSAL to DEFINE_RUNTIME_DEV_PM_OPS().
2022-08-07 19:04 ` [PATCH 1/2] iio: pressure: icp10100: Switch from UNIVERSAL to DEFINE_RUNTIME_DEV_PM_OPS() Jonathan Cameron
@ 2022-08-16 13:13 ` Jean-Baptiste Maneyrol
2022-09-04 16:43 ` Jonathan Cameron
0 siblings, 1 reply; 9+ messages in thread
From: Jean-Baptiste Maneyrol @ 2022-08-16 13:13 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio@vger.kernel.org
Cc: Paul Cercueil, Crt Mori, Jonathan Cameron
Hello,
looks good, thanks for the patch.
Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Thanks,
JB
From: Jonathan Cameron <jic23@kernel.org>
Sent: Sunday, August 7, 2022 21:04
To: linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>
Cc: Paul Cercueil <paul@crapouillou.net>; Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com>; Crt Mori <cmo@melexis.com>; Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: [PATCH 1/2] iio: pressure: icp10100: Switch from UNIVERSAL to DEFINE_RUNTIME_DEV_PM_OPS().
[CAUTION] This is EXTERNAL email. Do not click any links or open attachments unless you recognize the sender and know the content is safe.
======================================================================
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
The suspend and resume callbacks in this driver appear to be safe
to call repeatedly, but why do so when we can use the
DEFINE_RUNTIME_DEV_PM_OPS() macro to supply callbacks that check if
we are already runtime suspended before doing unnecessary work.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
---
drivers/iio/pressure/icp10100.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/pressure/icp10100.c b/drivers/iio/pressure/icp10100.c
index af4621eaa6b5..b62f28585db5 100644
--- a/drivers/iio/pressure/icp10100.c
+++ b/drivers/iio/pressure/icp10100.c
@@ -595,7 +595,7 @@ static int icp10100_probe(struct i2c_client *client,
return devm_iio_device_register(&client->dev, indio_dev);
}
-static int __maybe_unused icp10100_suspend(struct device *dev)
+static int icp10100_suspend(struct device *dev)
{
struct icp10100_state *st = iio_priv(dev_get_drvdata(dev));
int ret;
@@ -607,7 +607,7 @@ static int __maybe_unused icp10100_suspend(struct device *dev)
return ret;
}
-static int __maybe_unused icp10100_resume(struct device *dev)
+static int icp10100_resume(struct device *dev)
{
struct icp10100_state *st = iio_priv(dev_get_drvdata(dev));
int ret;
@@ -626,8 +626,8 @@ static int __maybe_unused icp10100_resume(struct device *dev)
return ret;
}
-static UNIVERSAL_DEV_PM_OPS(icp10100_pm, icp10100_suspend, icp10100_resume,
- NULL);
+static DEFINE_RUNTIME_DEV_PM_OPS(icp10100_pm, icp10100_suspend, icp10100_resume,
+ NULL);
static const struct of_device_id icp10100_of_match[] = {
{
@@ -646,7 +646,7 @@ MODULE_DEVICE_TABLE(i2c, icp10100_id);
static struct i2c_driver icp10100_driver = {
.driver = {
.name = "icp10100",
- .pm = &icp10100_pm,
+ .pm = pm_ptr(&icp10100_pm),
.of_match_table = icp10100_of_match,
},
.probe = icp10100_probe,
--
2.37.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] iio: temp: mlx90632: Switch form UNVIVERSAL to DEFINE_RUNTIME_DEV_PM_OPS()
2022-08-11 14:18 ` Jonathan Cameron
@ 2022-09-04 16:42 ` Jonathan Cameron
0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2022-09-04 16:42 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Crt Mori, linux-iio, Paul Cercueil, Jean-Baptiste Maneyrol
On Thu, 11 Aug 2022 15:18:34 +0100
Jonathan Cameron <Jonathan.Cameron@huawei.com> wrote:
> On Mon, 8 Aug 2022 13:26:42 +0200
> Crt Mori <cmo@melexis.com> wrote:
>
> > Not sure if I should apply both but:
> >
> > Acked-by: Crt Mori <cmo@melexis.com>
> > Tested-by: Crt Mori <cmo@melexis.com>
> Absolutely. Both is perfect. Thanks!
Given I forgot to pick this up and your set is moving towards being merged,
I'll not bother with this one.
Jonathan
> >
> >
> > On Sun, 7 Aug 2022 at 20:54, Jonathan Cameron <jic23@kernel.org> wrote:
> > >
> > > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > >
> > > The callbacks in this driver are simple and it doesn't matter if
> > > they are unnecessarily called multiple times. However, we might as
> > > well not repeat the effort if the device is already suspended.
> > > The new DEFINE_RUNTIME_DEV_PM_OPS() has the advantage that we don't
> > > need to mark the callbacks __maybe_unused. The compiler will still
> > > remove them for us if CONFIG_PM is not set.
> > >
> > > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > > Cc: Crt Mori <cmo@melexis.com>
> > > ---
> > > drivers/iio/temperature/mlx90632.c | 10 +++++-----
> > > 1 file changed, 5 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/iio/temperature/mlx90632.c b/drivers/iio/temperature/mlx90632.c
> > > index 7ee7ff8047a4..9fc69d099784 100644
> > > --- a/drivers/iio/temperature/mlx90632.c
> > > +++ b/drivers/iio/temperature/mlx90632.c
> > > @@ -952,7 +952,7 @@ static const struct of_device_id mlx90632_of_match[] = {
> > > };
> > > MODULE_DEVICE_TABLE(of, mlx90632_of_match);
> > >
> > > -static int __maybe_unused mlx90632_pm_suspend(struct device *dev)
> > > +static int mlx90632_pm_suspend(struct device *dev)
> > > {
> > > struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> > > struct mlx90632_data *data = iio_priv(indio_dev);
> > > @@ -960,7 +960,7 @@ static int __maybe_unused mlx90632_pm_suspend(struct device *dev)
> > > return mlx90632_sleep(data);
> > > }
> > >
> > > -static int __maybe_unused mlx90632_pm_resume(struct device *dev)
> > > +static int mlx90632_pm_resume(struct device *dev)
> > > {
> > > struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> > > struct mlx90632_data *data = iio_priv(indio_dev);
> > > @@ -968,14 +968,14 @@ static int __maybe_unused mlx90632_pm_resume(struct device *dev)
> > > return mlx90632_wakeup(data);
> > > }
> > >
> > > -static UNIVERSAL_DEV_PM_OPS(mlx90632_pm_ops, mlx90632_pm_suspend,
> > > - mlx90632_pm_resume, NULL);
> > > +static DEFINE_RUNTIME_DEV_PM_OPS(mlx90632_pm_ops, mlx90632_pm_suspend,
> > > + mlx90632_pm_resume, NULL);
> > >
> > > static struct i2c_driver mlx90632_driver = {
> > > .driver = {
> > > .name = "mlx90632",
> > > .of_match_table = mlx90632_of_match,
> > > - .pm = &mlx90632_pm_ops,
> > > + .pm = pm_ptr(&mlx90632_pm_ops),
> > > },
> > > .probe = mlx90632_probe,
> > > .remove = mlx90632_remove,
> > > --
> > > 2.37.1
> > >
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] iio: pressure: icp10100: Switch from UNIVERSAL to DEFINE_RUNTIME_DEV_PM_OPS().
2022-08-16 13:13 ` Jean-Baptiste Maneyrol
@ 2022-09-04 16:43 ` Jonathan Cameron
0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2022-09-04 16:43 UTC (permalink / raw)
To: Jean-Baptiste Maneyrol
Cc: linux-iio@vger.kernel.org, Paul Cercueil, Crt Mori,
Jonathan Cameron
On Tue, 16 Aug 2022 13:13:52 +0000
Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com> wrote:
> Hello,
>
> looks good, thanks for the patch.
>
> Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Applied
>
> Thanks,
> JB
>
>
> From: Jonathan Cameron <jic23@kernel.org>
> Sent: Sunday, August 7, 2022 21:04
> To: linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>
> Cc: Paul Cercueil <paul@crapouillou.net>; Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com>; Crt Mori <cmo@melexis.com>; Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Subject: [PATCH 1/2] iio: pressure: icp10100: Switch from UNIVERSAL to DEFINE_RUNTIME_DEV_PM_OPS().
> _
> [CAUTION] This is EXTERNAL email. Do not click any links or open attachments unless you recognize the sender and know the content is safe.
>
> ======================================================================
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> The suspend and resume callbacks in this driver appear to be safe
> to call repeatedly, but why do so when we can use the
> DEFINE_RUNTIME_DEV_PM_OPS() macro to supply callbacks that check if
> we are already runtime suspended before doing unnecessary work.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
> ---
> _drivers/iio/pressure/icp10100.c | 10 +++++-----
> _1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/pressure/icp10100.c b/drivers/iio/pressure/icp10100.c
> index af4621eaa6b5..b62f28585db5 100644
> --- a/drivers/iio/pressure/icp10100.c
> +++ b/drivers/iio/pressure/icp10100.c
> @@ -595,7 +595,7 @@ static int icp10100_probe(struct i2c_client *client,
> ________ return devm_iio_device_register(&client->dev, indio_dev);
> _}
> _
> -static int __maybe_unused icp10100_suspend(struct device *dev)
> +static int icp10100_suspend(struct device *dev)
> _{
> ________ struct icp10100_state *st = iio_priv(dev_get_drvdata(dev));
> ________ int ret;
> @@ -607,7 +607,7 @@ static int __maybe_unused icp10100_suspend(struct device *dev)
> ________ return ret;
> _}
> _
> -static int __maybe_unused icp10100_resume(struct device *dev)
> +static int icp10100_resume(struct device *dev)
> _{
> ________ struct icp10100_state *st = iio_priv(dev_get_drvdata(dev));
> ________ int ret;
> @@ -626,8 +626,8 @@ static int __maybe_unused icp10100_resume(struct device *dev)
> ________ return ret;
> _}
> _
> -static UNIVERSAL_DEV_PM_OPS(icp10100_pm, icp10100_suspend, icp10100_resume,
> -__________________________ NULL);
> +static DEFINE_RUNTIME_DEV_PM_OPS(icp10100_pm, icp10100_suspend, icp10100_resume,
> +_______________________________ NULL);
> _
> _static const struct of_device_id icp10100_of_match[] = {
> ________ {
> @@ -646,7 +646,7 @@ MODULE_DEVICE_TABLE(i2c, icp10100_id);
> _static struct i2c_driver icp10100_driver = {
> ________ .driver = {
> ________________ .name = "icp10100",
> -______________ .pm = &icp10100_pm,
> +______________ .pm = pm_ptr(&icp10100_pm),
> ________________ .of_match_table = icp10100_of_match,
> ________ },
> ________ .probe = icp10100_probe,
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-09-04 17:17 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-07 19:04 [PATCH 0/2] iio: Convert some drivers from deprecated UNIVERSAL_DEV_PM_OPS() Jonathan Cameron
2022-08-07 19:04 ` [PATCH 1/2] iio: pressure: icp10100: Switch from UNIVERSAL to DEFINE_RUNTIME_DEV_PM_OPS() Jonathan Cameron
2022-08-16 13:13 ` Jean-Baptiste Maneyrol
2022-09-04 16:43 ` Jonathan Cameron
2022-08-07 19:04 ` [PATCH 2/2] iio: temp: mlx90632: Switch form UNVIVERSAL " Jonathan Cameron
2022-08-08 11:26 ` Crt Mori
2022-08-11 14:18 ` Jonathan Cameron
2022-09-04 16:42 ` Jonathan Cameron
2022-08-08 9:30 ` [PATCH 0/2] iio: Convert some drivers from deprecated UNIVERSAL_DEV_PM_OPS() Andy Shevchenko
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).