diff mbox series

[41/49] iio:pressure:bmp280: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused

Message ID 20211123211019.2271440-42-jic23@kernel.org (mailing list archive)
State Superseded
Headers show
Series iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc. | expand

Commit Message

Jonathan Cameron Nov. 23, 2021, 9:10 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM 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: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/iio/pressure/bmp280-core.c | 6 ++----
 drivers/iio/pressure/bmp280-i2c.c  | 2 +-
 drivers/iio/pressure/bmp280-spi.c  | 2 +-
 3 files changed, 4 insertions(+), 6 deletions(-)

Comments

Linus Walleij Nov. 25, 2021, 4:56 p.m. UTC | #1
On Tue, Nov 23, 2021 at 10:07 PM Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> Letting the compiler remove these functions when the kernel is built
> without CONFIG_PM 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: Linus Walleij <linus.walleij@linaro.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Jonathan Cameron Jan. 1, 2022, 5:50 p.m. UTC | #2
On Tue, 23 Nov 2021 21:10:11 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Letting the compiler remove these functions when the kernel is built
> without CONFIG_PM 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: Linus Walleij <linus.walleij@linaro.org>
Dropping this one for now because it has the same complexity around
EXPORT_SYMBOL() and multiple modules so the compiler can't remove the
functions automatically.

Will rethink if there is a way to handle these multi module cases
at a later date.

Thanks,

Jonathan

> ---
>  drivers/iio/pressure/bmp280-core.c | 6 ++----
>  drivers/iio/pressure/bmp280-i2c.c  | 2 +-
>  drivers/iio/pressure/bmp280-spi.c  | 2 +-
>  3 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
> index 6b7da40f99c8..0653e1ea88da 100644
> --- a/drivers/iio/pressure/bmp280-core.c
> +++ b/drivers/iio/pressure/bmp280-core.c
> @@ -1138,8 +1138,7 @@ int bmp280_common_probe(struct device *dev,
>  }
>  EXPORT_SYMBOL(bmp280_common_probe);
>  
> -#ifdef CONFIG_PM
> -static int bmp280_runtime_suspend(struct device *dev)
> +static __maybe_unused int bmp280_runtime_suspend(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>  	struct bmp280_data *data = iio_priv(indio_dev);
> @@ -1147,7 +1146,7 @@ static int bmp280_runtime_suspend(struct device *dev)
>  	return regulator_bulk_disable(BMP280_NUM_SUPPLIES, data->supplies);
>  }
>  
> -static int bmp280_runtime_resume(struct device *dev)
> +static __maybe_unused int bmp280_runtime_resume(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>  	struct bmp280_data *data = iio_priv(indio_dev);
> @@ -1159,7 +1158,6 @@ static int bmp280_runtime_resume(struct device *dev)
>  	usleep_range(data->start_up_time, data->start_up_time + 100);
>  	return data->chip_info->chip_config(data);
>  }
> -#endif /* CONFIG_PM */
>  
>  const struct dev_pm_ops bmp280_dev_pm_ops = {
>  	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
> diff --git a/drivers/iio/pressure/bmp280-i2c.c b/drivers/iio/pressure/bmp280-i2c.c
> index 8b03ea15c0d0..35045bd92846 100644
> --- a/drivers/iio/pressure/bmp280-i2c.c
> +++ b/drivers/iio/pressure/bmp280-i2c.c
> @@ -58,7 +58,7 @@ static struct i2c_driver bmp280_i2c_driver = {
>  	.driver = {
>  		.name	= "bmp280",
>  		.of_match_table = bmp280_of_i2c_match,
> -		.pm = &bmp280_dev_pm_ops,
> +		.pm = pm_ptr(&bmp280_dev_pm_ops),
>  	},
>  	.probe		= bmp280_i2c_probe,
>  	.id_table	= bmp280_i2c_id,
> diff --git a/drivers/iio/pressure/bmp280-spi.c b/drivers/iio/pressure/bmp280-spi.c
> index 625b86878ad8..41f6cc56d229 100644
> --- a/drivers/iio/pressure/bmp280-spi.c
> +++ b/drivers/iio/pressure/bmp280-spi.c
> @@ -109,7 +109,7 @@ static struct spi_driver bmp280_spi_driver = {
>  	.driver = {
>  		.name = "bmp280",
>  		.of_match_table = bmp280_of_spi_match,
> -		.pm = &bmp280_dev_pm_ops,
> +		.pm = pm_ptr(&bmp280_dev_pm_ops),
>  	},
>  	.id_table = bmp280_spi_id,
>  	.probe = bmp280_spi_probe,
diff mbox series

Patch

diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 6b7da40f99c8..0653e1ea88da 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -1138,8 +1138,7 @@  int bmp280_common_probe(struct device *dev,
 }
 EXPORT_SYMBOL(bmp280_common_probe);
 
-#ifdef CONFIG_PM
-static int bmp280_runtime_suspend(struct device *dev)
+static __maybe_unused int bmp280_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct bmp280_data *data = iio_priv(indio_dev);
@@ -1147,7 +1146,7 @@  static int bmp280_runtime_suspend(struct device *dev)
 	return regulator_bulk_disable(BMP280_NUM_SUPPLIES, data->supplies);
 }
 
-static int bmp280_runtime_resume(struct device *dev)
+static __maybe_unused int bmp280_runtime_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct bmp280_data *data = iio_priv(indio_dev);
@@ -1159,7 +1158,6 @@  static int bmp280_runtime_resume(struct device *dev)
 	usleep_range(data->start_up_time, data->start_up_time + 100);
 	return data->chip_info->chip_config(data);
 }
-#endif /* CONFIG_PM */
 
 const struct dev_pm_ops bmp280_dev_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
diff --git a/drivers/iio/pressure/bmp280-i2c.c b/drivers/iio/pressure/bmp280-i2c.c
index 8b03ea15c0d0..35045bd92846 100644
--- a/drivers/iio/pressure/bmp280-i2c.c
+++ b/drivers/iio/pressure/bmp280-i2c.c
@@ -58,7 +58,7 @@  static struct i2c_driver bmp280_i2c_driver = {
 	.driver = {
 		.name	= "bmp280",
 		.of_match_table = bmp280_of_i2c_match,
-		.pm = &bmp280_dev_pm_ops,
+		.pm = pm_ptr(&bmp280_dev_pm_ops),
 	},
 	.probe		= bmp280_i2c_probe,
 	.id_table	= bmp280_i2c_id,
diff --git a/drivers/iio/pressure/bmp280-spi.c b/drivers/iio/pressure/bmp280-spi.c
index 625b86878ad8..41f6cc56d229 100644
--- a/drivers/iio/pressure/bmp280-spi.c
+++ b/drivers/iio/pressure/bmp280-spi.c
@@ -109,7 +109,7 @@  static struct spi_driver bmp280_spi_driver = {
 	.driver = {
 		.name = "bmp280",
 		.of_match_table = bmp280_of_spi_match,
-		.pm = &bmp280_dev_pm_ops,
+		.pm = pm_ptr(&bmp280_dev_pm_ops),
 	},
 	.id_table = bmp280_spi_id,
 	.probe = bmp280_spi_probe,