From: Abdelnasser Hussein <abdelnasserhussein11@gmail.com>
To: jic23@kernel.org, linux-iio@vger.kernel.org
Cc: nuno.sa@analog.com, Michael.Hennerich@analog.com,
dlechner@baylibre.com, andy@kernel.org, linux@analog.com,
linux-kernel@vger.kernel.org,
Abdelnasser Hussein <abdelnasserhussein11@gmail.com>
Subject: [PATCH] iio: adc: ad7606: use EXPORT_NS_GPL_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()
Date: Thu, 15 Oct 2026 18:19:03 +0300 [thread overview]
Message-ID: <20261015151903.13613-1-abdelnasserhussein11@gmail.com> (raw)
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.
Signed-off-by: Abdelnasser Hussein <abdelnasserhussein11@gmail.com>
---
drivers/iio/adc/ad7606.c | 9 +++------
drivers/iio/adc/ad7606.h | 5 -----
drivers/iio/adc/ad7606_par.c | 3 ++-
drivers/iio/adc/ad7606_spi.c | 3 ++-
4 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index cebb8ed8dcb1..e71ff8d38e4c 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -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,8 @@ 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 <michael.hennerich@analog.com>");
MODULE_DESCRIPTION("Analog Devices AD7606 ADC");
diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h
index 2951bb731354..c60f71a38883 100644
--- a/drivers/iio/adc/ad7606.h
+++ b/drivers/iio/adc/ad7606.h
@@ -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_ */
diff --git a/drivers/iio/adc/ad7606_par.c b/drivers/iio/adc/ad7606_par.c
index 5b137e947f0b..986c15db90c7 100644
--- a/drivers/iio/adc/ad7606_par.c
+++ b/drivers/iio/adc/ad7606_par.c
@@ -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,
},
};
diff --git a/drivers/iio/adc/ad7606_spi.c b/drivers/iio/adc/ad7606_spi.c
index 8c479fa50a23..10df12311561 100644
--- a/drivers/iio/adc/ad7606_spi.c
+++ b/drivers/iio/adc/ad7606_spi.c
@@ -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,
--
2.54.0
next reply other threads:[~2026-10-15 15:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 15:19 Abdelnasser Hussein [this message]
2026-10-15 18:44 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261015151903.13613-1-abdelnasserhussein11@gmail.com \
--to=abdelnasserhussein11@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@analog.com \
--cc=nuno.sa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®