Re: [PATCH 37/49] iio:magn:hmc5843: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 23 Nov 2021 21:10:07 +0000
Jonathan Cameron <jic23@xxxxxxxxxx> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
> 
> 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.
> 
> The pm_ptr() macro only removes the reference if CONFIG_PM is not
> set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
> will not always remove the pm_ops structure.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
This one needs some more thought before any conversion to the new
pm_sleep_ptr() etc as use of
DEFINE_SIMPLE_DEV_PM_OPS() leads to an unused warning for the _core.c
module - which explains the original __maybe_unused under the ifdef.

I'll drop it for now.

Jonathan


> ---
>  drivers/iio/magnetometer/hmc5843.h     | 5 -----
>  drivers/iio/magnetometer/hmc5843_i2c.c | 2 +-
>  drivers/iio/magnetometer/hmc5843_spi.c | 2 +-
>  3 files changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/magnetometer/hmc5843.h b/drivers/iio/magnetometer/hmc5843.h
> index 9120c8bbf3dd..c3444f3ab1dc 100644
> --- a/drivers/iio/magnetometer/hmc5843.h
> +++ b/drivers/iio/magnetometer/hmc5843.h
> @@ -55,13 +55,8 @@ void hmc5843_common_remove(struct device *dev);
>  int hmc5843_common_suspend(struct device *dev);
>  int hmc5843_common_resume(struct device *dev);
>  
> -#ifdef CONFIG_PM_SLEEP
>  static __maybe_unused SIMPLE_DEV_PM_OPS(hmc5843_pm_ops,
>  					hmc5843_common_suspend,
>  					hmc5843_common_resume);
> -#define HMC5843_PM_OPS (&hmc5843_pm_ops)
> -#else
> -#define HMC5843_PM_OPS NULL
> -#endif
>  
>  #endif /* HMC5843_CORE_H */
> diff --git a/drivers/iio/magnetometer/hmc5843_i2c.c b/drivers/iio/magnetometer/hmc5843_i2c.c
> index bc6e12f1d521..a7359f439f10 100644
> --- a/drivers/iio/magnetometer/hmc5843_i2c.c
> +++ b/drivers/iio/magnetometer/hmc5843_i2c.c
> @@ -93,7 +93,7 @@ MODULE_DEVICE_TABLE(of, hmc5843_of_match);
>  static struct i2c_driver hmc5843_driver = {
>  	.driver = {
>  		.name	= "hmc5843",
> -		.pm	= HMC5843_PM_OPS,
> +		.pm	= pm_ptr(&hmc5843_pm_ops),
>  		.of_match_table = hmc5843_of_match,
>  	},
>  	.id_table	= hmc5843_id,
> diff --git a/drivers/iio/magnetometer/hmc5843_spi.c b/drivers/iio/magnetometer/hmc5843_spi.c
> index 89cf59a62c28..c1bd2ff3c64a 100644
> --- a/drivers/iio/magnetometer/hmc5843_spi.c
> +++ b/drivers/iio/magnetometer/hmc5843_spi.c
> @@ -90,7 +90,7 @@ MODULE_DEVICE_TABLE(spi, hmc5843_id);
>  static struct spi_driver hmc5843_driver = {
>  		.driver = {
>  				.name = "hmc5843",
> -				.pm = HMC5843_PM_OPS,
> +				.pm = pm_ptr(&hmc5843_pm_ops),
>  		},
>  		.id_table = hmc5843_id,
>  		.probe = hmc5843_spi_probe,




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux