diff mbox series

[v2,44/51] iio:temperature:tmp007: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc

Message ID 20220102125617.1259804-45-jic23@kernel.org (mailing list archive)
State Changes Requested
Headers show
Series iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc. | expand

Commit Message

Jonathan Cameron Jan. 2, 2022, 12:56 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP support is simpler and less error prone than the
use of #ifdef based config guards.

Removing instances of this approach from IIO also stops them being
copied into new drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Manivannan Sadhasivam <mani@kernel.org>
---
 drivers/iio/temperature/tmp007.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Manivannan Sadhasivam Jan. 3, 2022, 6:03 a.m. UTC | #1
On Sun, Jan 02, 2022 at 12:56:10PM +0000, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Letting the compiler remove these functions when the kernel is built
> without CONFIG_PM_SLEEP support is simpler and less error prone than the
> use of #ifdef based config guards.
> 
> Removing instances of this approach from IIO also stops them being
> copied into new drivers.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Acked-by: Manivannan Sadhasivam <mani@kernel.org>

Thanks,
Mani

> Cc: Manivannan Sadhasivam <mani@kernel.org>
> ---
>  drivers/iio/temperature/tmp007.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/temperature/tmp007.c b/drivers/iio/temperature/tmp007.c
> index b422371a4674..f7a040f0ee4c 100644
> --- a/drivers/iio/temperature/tmp007.c
> +++ b/drivers/iio/temperature/tmp007.c
> @@ -537,7 +537,6 @@ static int tmp007_probe(struct i2c_client *client,
>  	return devm_iio_device_register(&client->dev, indio_dev);
>  }
>  
> -#ifdef CONFIG_PM_SLEEP
>  static int tmp007_suspend(struct device *dev)
>  {
>  	struct tmp007_data *data = iio_priv(i2c_get_clientdata(
> @@ -554,9 +553,8 @@ static int tmp007_resume(struct device *dev)
>  	return i2c_smbus_write_word_swapped(data->client, TMP007_CONFIG,
>  			data->config | TMP007_CONFIG_CONV_EN);
>  }
> -#endif
>  
> -static SIMPLE_DEV_PM_OPS(tmp007_pm_ops, tmp007_suspend, tmp007_resume);
> +DEFINE_SIMPLE_DEV_PM_OPS(tmp007_pm_ops, tmp007_suspend, tmp007_resume);
>  
>  static const struct of_device_id tmp007_of_match[] = {
>  	{ .compatible = "ti,tmp007", },
> @@ -574,7 +572,7 @@ static struct i2c_driver tmp007_driver = {
>  	.driver = {
>  		.name	= "tmp007",
>  		.of_match_table = tmp007_of_match,
> -		.pm	= &tmp007_pm_ops,
> +		.pm	= pm_sleep_ptr(&tmp007_pm_ops),
>  	},
>  	.probe		= tmp007_probe,
>  	.id_table	= tmp007_id,
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/iio/temperature/tmp007.c b/drivers/iio/temperature/tmp007.c
index b422371a4674..f7a040f0ee4c 100644
--- a/drivers/iio/temperature/tmp007.c
+++ b/drivers/iio/temperature/tmp007.c
@@ -537,7 +537,6 @@  static int tmp007_probe(struct i2c_client *client,
 	return devm_iio_device_register(&client->dev, indio_dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int tmp007_suspend(struct device *dev)
 {
 	struct tmp007_data *data = iio_priv(i2c_get_clientdata(
@@ -554,9 +553,8 @@  static int tmp007_resume(struct device *dev)
 	return i2c_smbus_write_word_swapped(data->client, TMP007_CONFIG,
 			data->config | TMP007_CONFIG_CONV_EN);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(tmp007_pm_ops, tmp007_suspend, tmp007_resume);
+DEFINE_SIMPLE_DEV_PM_OPS(tmp007_pm_ops, tmp007_suspend, tmp007_resume);
 
 static const struct of_device_id tmp007_of_match[] = {
 	{ .compatible = "ti,tmp007", },
@@ -574,7 +572,7 @@  static struct i2c_driver tmp007_driver = {
 	.driver = {
 		.name	= "tmp007",
 		.of_match_table = tmp007_of_match,
-		.pm	= &tmp007_pm_ops,
+		.pm	= pm_sleep_ptr(&tmp007_pm_ops),
 	},
 	.probe		= tmp007_probe,
 	.id_table	= tmp007_id,