iio: adc: ad7606: use EXPORT_NS_GPL_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
Subsystems (2)
PATCH v2 1/1 iio: adc: ad7606: use EXPORT_NS_GPL_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
Replace SIMPLE_DEV_PM_OPS() with EXPORT_NS_GPL_SIMPLE_DEV_PM_OPS() and use pm_sleep_ptr() to wire up the power management operations.
This allows dropping the #ifdef CONFIG_PM_SLEEP guards, simplifying the code and improving compile test coverage of the suspend/resume callbacks while still allowing the compiler to optimize them out when CONFIG_PM_SLEEP is disabled.
---
Changes in v2:
- Put EXPORT_NS_GPL_SIMPLE_DEV_PM_OPS() on a single line.
drivers/iio/adc/ad7606.c | 8 ++------ drivers/iio/adc/ad7606.h | 5 ----- drivers/iio/adc/ad7606_par.c | 3 ++- drivers/iio/adc/ad7606_spi.c | 3 ++- 4 files changed, 6 insertions(+), 13 deletions(-)
drivers/iio/adc/ad7606.c +2 -6
@@ -14,6 +14,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/mutex.h> +#include <linux/pm.h> #include <linux/property.h> #include <linux/pwm.h> #include <linux/regulator/consumer.h>
@@ -1673,8 +1674,6 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address, }EXPORT_SYMBOL_NS_GPL (ad7606_probe,"IIO_AD7606" ); -#ifdef CONFIG_PM_SLEEP -static int ad7606_suspend (struct device *dev) {struct iio_dev *indio_dev =dev_get_drvdata (dev);
@@ -1702,10 +1701,7 @@ static int ad7606_resume(struct device *dev)return 0 ; } -SIMPLE_DEV_PM_OPS (ad7606_pm_ops, ad7606_suspend, ad7606_resume); -EXPORT_SYMBOL_NS_GPL (ad7606_pm_ops,"IIO_AD7606" ); - -#endif +EXPORT_NS_GPL_SIMPLE_DEV_PM_OPS (ad7606_pm_ops, ad7606_suspend, ad7606_resume,IIO_AD7606 );MODULE_AUTHOR ("Michael Hennerich <[email protected]>" );MODULE_DESCRIPTION ("Analog Devices AD7606 ADC" );
drivers/iio/adc/ad7606.h +0 -5
@@ -241,11 +241,6 @@ extern const struct ad7606_chip_info ad7608_info;extern const struct ad7606_chip_info ad7609_info;extern const struct ad7606_chip_info ad7616_info; -#ifdef CONFIG_PM_SLEEP extern const struct dev_pm_ops ad7606_pm_ops; -#define AD7606_PM_OPS (&ad7606_pm_ops) -#else -#define AD7606_PM_OPS NULL -#endif #endif /* IIO_ADC_AD7606_H_ */
drivers/iio/adc/ad7606_par.c +2 -1
@@ -11,6 +11,7 @@#include <linux/io.h> #include <linux/module.h> #include <linux/platform_device.h> +#include <linux/pm.h> #include <linux/property.h> #include <linux/types.h>
@@ -251,7 +252,7 @@ static struct platform_driver ad7606_driver = { .id_table = ad7606_driver_ids, .driver = { .name = "ad7606", - .pm = AD7606_PM_OPS, + .pm = pm_sleep_ptr(&ad7606_pm_ops), .of_match_table = ad7606_of_match, }, };
drivers/iio/adc/ad7606_spi.c +2 -1
@@ -9,6 +9,7 @@#include <linux/err.h> #include <linux/math.h> #include <linux/module.h> +#include <linux/pm.h> #include <linux/pwm.h> #include <linux/spi/offload/consumer.h> #include <linux/spi/offload/provider.h>
@@ -502,7 +503,7 @@ static struct spi_driver ad7606_driver = { .driver = { .name = "ad7606", .of_match_table = ad7606_of_match, - .pm = AD7606_PM_OPS, + .pm = pm_sleep_ptr(&ad7606_pm_ops), }, .probe = ad7606_spi_probe, .id_table = ad7606_id_table,
Signature · 1 line
2.54.0
Quoted 11 lines · On Fri, 16 Oct 2026 16:13:34 +0300 Abdelnasser Hussein…
Replace
SIMPLE_DEV_PM_OPS()withEXPORT_NS_GPL_SIMPLE_DEV_PM_OPS()and usepm_sleep_ptr()to wire up the power management operations.This allows dropping the #ifdef
CONFIG_PM_SLEEPguards, simplifying the code and improving compile test coverage of the suspend/resume callbacks while still allowing the compiler to optimize them out whenCONFIG_PM_SLEEPis disabled.Reviewed-by Andy Shevchenko <[email protected]>Reviewed-by Nuno Sá <[email protected]>Signed-off-by Abdelnasser Hussein <[email protected]>
Nice.
Applied.
Thanks,
Jonathan