* [PATCH v2 0/2] iio: fix suspend and resume triggering for bmi160 and bmi270
@ 2025-05-25 14:25 Denis Benato
2025-05-25 14:25 ` [PATCH v2 1/2] iio: bmi270: suspend and resume triggering on relevant pm operations Denis Benato
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Denis Benato @ 2025-05-25 14:25 UTC (permalink / raw)
To: Jonathan Cameron
Cc: David Lechner, Nuno Sá, Alex Lanzano, Andy Shevchenko,
Uwe Kleine-König, Peter Zijlstra, Danila Tikhonov, Greg KH,
Derek J . Clark, Philip Müller, linux-iio, linux-kernel,
Denis Benato
Two imu devices bmi160 and bmi270 are similar to bmi323, with the same bug and
a common usecase: fix the aforementioned bug about triggering not resuming
after sleep in the same way it was solved for the bmi323 device driver.
The bmi270 patch has been tested on a device where the device irq pin
is connected to the CPU ensuring it doesn't cause harm to devices that
do not use hrtimer or other external triggers.
Changelog from v1 [1]
- include linux/pm.h where needed
- used "Closed" to reference the solved issue for each driver
- merged two lines into one (on both drivers)
[1] https://lore.kernel.org/all/20250509171526.7842-1-benato.denis96@gmail.com
Denis Benato (2):
iio: bmi270: suspend and resume triggering on relevant pm operations
iio: bmi160: suspend and resume triggering on relevant pm operations
drivers/iio/imu/bmi160/bmi160.h | 2 ++
drivers/iio/imu/bmi160/bmi160_core.c | 19 +++++++++++++++++++
drivers/iio/imu/bmi160/bmi160_i2c.c | 2 ++
drivers/iio/imu/bmi160/bmi160_spi.c | 2 ++
drivers/iio/imu/bmi270/bmi270.h | 2 ++
drivers/iio/imu/bmi270/bmi270_core.c | 20 ++++++++++++++++++++
drivers/iio/imu/bmi270/bmi270_i2c.c | 2 ++
drivers/iio/imu/bmi270/bmi270_spi.c | 2 ++
8 files changed, 51 insertions(+)
--
2.49.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/2] iio: bmi270: suspend and resume triggering on relevant pm operations
2025-05-25 14:25 [PATCH v2 0/2] iio: fix suspend and resume triggering for bmi160 and bmi270 Denis Benato
@ 2025-05-25 14:25 ` Denis Benato
2025-05-31 16:59 ` Jonathan Cameron
2025-05-25 14:25 ` [PATCH v2 2/2] iio: bmi160: " Denis Benato
2025-05-26 19:58 ` [PATCH v2 0/2] iio: fix suspend and resume triggering for bmi160 and bmi270 Andy Shevchenko
2 siblings, 1 reply; 8+ messages in thread
From: Denis Benato @ 2025-05-25 14:25 UTC (permalink / raw)
To: Jonathan Cameron
Cc: David Lechner, Nuno Sá, Alex Lanzano, Andy Shevchenko,
Uwe Kleine-König, Peter Zijlstra, Danila Tikhonov, Greg KH,
Derek J . Clark, Philip Müller, linux-iio, linux-kernel,
Denis Benato, Justin Weiss
Prevent triggers from stop working after the device has entered sleep:
use iio_device_suspend_triggering and iio_device_resume_triggering helpers.
Closes: https://lore.kernel.org/all/31d7f7aa-e834-4fd0-a66a-e0ff528425dc@gmail.com
Signed-off-by: Denis Benato <benato.denis96@gmail.com>
Tested-by: Justin Weiss <justin@justinweiss.com>
---
drivers/iio/imu/bmi270/bmi270.h | 2 ++
drivers/iio/imu/bmi270/bmi270_core.c | 20 ++++++++++++++++++++
drivers/iio/imu/bmi270/bmi270_i2c.c | 2 ++
drivers/iio/imu/bmi270/bmi270_spi.c | 2 ++
4 files changed, 26 insertions(+)
diff --git a/drivers/iio/imu/bmi270/bmi270.h b/drivers/iio/imu/bmi270/bmi270.h
index d94525f6aee8..a6c4204032fc 100644
--- a/drivers/iio/imu/bmi270/bmi270.h
+++ b/drivers/iio/imu/bmi270/bmi270.h
@@ -20,4 +20,6 @@ struct device;
int bmi270_core_probe(struct device *dev, struct regmap *regmap,
const struct bmi270_chip_info *chip_info);
+extern const struct dev_pm_ops bmi270_core_pm_ops;
+
#endif /* BMI270_H_ */
diff --git a/drivers/iio/imu/bmi270/bmi270_core.c b/drivers/iio/imu/bmi270/bmi270_core.c
index 2e4469f30d53..b54658f972ad 100644
--- a/drivers/iio/imu/bmi270/bmi270_core.c
+++ b/drivers/iio/imu/bmi270/bmi270_core.c
@@ -982,6 +982,7 @@ int bmi270_core_probe(struct device *dev, struct regmap *regmap,
indio_dev->available_scan_masks = bmi270_avail_scan_masks;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &bmi270_info;
+ dev_set_drvdata(data->dev, indio_dev);
ret = bmi270_trigger_probe(data, indio_dev);
if (ret)
@@ -997,6 +998,25 @@ int bmi270_core_probe(struct device *dev, struct regmap *regmap,
}
EXPORT_SYMBOL_NS_GPL(bmi270_core_probe, "IIO_BMI270");
+static int bmi270_core_runtime_suspend(struct device *dev)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+
+ return iio_device_suspend_triggering(indio_dev);
+}
+
+static int bmi270_core_runtime_resume(struct device *dev)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+
+ return iio_device_resume_triggering(indio_dev);
+}
+
+const struct dev_pm_ops bmi270_core_pm_ops = {
+ RUNTIME_PM_OPS(bmi270_core_runtime_suspend, bmi270_core_runtime_resume, NULL)
+};
+EXPORT_SYMBOL_NS_GPL(bmi270_core_pm_ops, "IIO_BMI270");
+
MODULE_AUTHOR("Alex Lanzano");
MODULE_DESCRIPTION("BMI270 driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/iio/imu/bmi270/bmi270_i2c.c b/drivers/iio/imu/bmi270/bmi270_i2c.c
index 44699ab58909..c77839b03a96 100644
--- a/drivers/iio/imu/bmi270/bmi270_i2c.c
+++ b/drivers/iio/imu/bmi270/bmi270_i2c.c
@@ -4,6 +4,7 @@
#include <linux/iio/iio.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
+#include <linux/pm.h>
#include <linux/regmap.h>
#include "bmi270.h"
@@ -52,6 +53,7 @@ static const struct of_device_id bmi270_of_match[] = {
static struct i2c_driver bmi270_i2c_driver = {
.driver = {
.name = "bmi270_i2c",
+ .pm = pm_ptr(&bmi270_core_pm_ops),
.acpi_match_table = bmi270_acpi_match,
.of_match_table = bmi270_of_match,
},
diff --git a/drivers/iio/imu/bmi270/bmi270_spi.c b/drivers/iio/imu/bmi270/bmi270_spi.c
index 88a77aba5e4f..19dd7734f9d0 100644
--- a/drivers/iio/imu/bmi270/bmi270_spi.c
+++ b/drivers/iio/imu/bmi270/bmi270_spi.c
@@ -3,6 +3,7 @@
#include <linux/iio/iio.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
+#include <linux/pm.h>
#include <linux/regmap.h>
#include <linux/spi/spi.h>
@@ -79,6 +80,7 @@ static const struct of_device_id bmi270_of_match[] = {
static struct spi_driver bmi270_spi_driver = {
.driver = {
.name = "bmi270",
+ .pm = pm_ptr(&bmi270_core_pm_ops),
.of_match_table = bmi270_of_match,
},
.probe = bmi270_spi_probe,
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/2] iio: bmi160: suspend and resume triggering on relevant pm operations
2025-05-25 14:25 [PATCH v2 0/2] iio: fix suspend and resume triggering for bmi160 and bmi270 Denis Benato
2025-05-25 14:25 ` [PATCH v2 1/2] iio: bmi270: suspend and resume triggering on relevant pm operations Denis Benato
@ 2025-05-25 14:25 ` Denis Benato
2025-05-26 19:58 ` [PATCH v2 0/2] iio: fix suspend and resume triggering for bmi160 and bmi270 Andy Shevchenko
2 siblings, 0 replies; 8+ messages in thread
From: Denis Benato @ 2025-05-25 14:25 UTC (permalink / raw)
To: Jonathan Cameron
Cc: David Lechner, Nuno Sá, Alex Lanzano, Andy Shevchenko,
Uwe Kleine-König, Peter Zijlstra, Danila Tikhonov, Greg KH,
Derek J . Clark, Philip Müller, linux-iio, linux-kernel,
Denis Benato
Prevent triggers from stop working after the device has entered sleep:
use iio_device_suspend_triggering and iio_device_resume_triggering helpers.
Closes: https://lore.kernel.org/all/31d7f7aa-e834-4fd0-a66a-e0ff528425dc@gmail.com
Signed-off-by: Denis Benato <benato.denis96@gmail.com>
---
drivers/iio/imu/bmi160/bmi160.h | 2 ++
drivers/iio/imu/bmi160/bmi160_core.c | 19 +++++++++++++++++++
drivers/iio/imu/bmi160/bmi160_i2c.c | 2 ++
drivers/iio/imu/bmi160/bmi160_spi.c | 2 ++
4 files changed, 25 insertions(+)
diff --git a/drivers/iio/imu/bmi160/bmi160.h b/drivers/iio/imu/bmi160/bmi160.h
index 32c2ea2d7112..ffbe8205e703 100644
--- a/drivers/iio/imu/bmi160/bmi160.h
+++ b/drivers/iio/imu/bmi160/bmi160.h
@@ -28,4 +28,6 @@ int bmi160_enable_irq(struct regmap *regmap, bool enable);
int bmi160_probe_trigger(struct iio_dev *indio_dev, int irq, u32 irq_type);
+extern const struct dev_pm_ops bmi160_core_pm_ops;
+
#endif /* BMI160_H_ */
diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c
index 0423ef6f9571..9aa54b95b89f 100644
--- a/drivers/iio/imu/bmi160/bmi160_core.c
+++ b/drivers/iio/imu/bmi160/bmi160_core.c
@@ -890,6 +890,25 @@ int bmi160_core_probe(struct device *dev, struct regmap *regmap,
}
EXPORT_SYMBOL_NS_GPL(bmi160_core_probe, "IIO_BMI160");
+static int bmi160_core_runtime_suspend(struct device *dev)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+
+ return iio_device_suspend_triggering(indio_dev);
+}
+
+static int bmi160_core_runtime_resume(struct device *dev)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+
+ return iio_device_resume_triggering(indio_dev);
+}
+
+const struct dev_pm_ops bmi160_core_pm_ops = {
+ RUNTIME_PM_OPS(bmi160_core_runtime_suspend, bmi160_core_runtime_resume, NULL)
+};
+EXPORT_SYMBOL_NS_GPL(bmi160_core_pm_ops, "IIO_BMI160");
+
MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com>");
MODULE_DESCRIPTION("Bosch BMI160 driver");
MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/imu/bmi160/bmi160_i2c.c b/drivers/iio/imu/bmi160/bmi160_i2c.c
index 9fa3a19a8977..3e2758f4e0d3 100644
--- a/drivers/iio/imu/bmi160/bmi160_i2c.c
+++ b/drivers/iio/imu/bmi160/bmi160_i2c.c
@@ -11,6 +11,7 @@
#include <linux/i2c.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
+#include <linux/pm.h>
#include <linux/regmap.h>
#include "bmi160.h"
@@ -69,6 +70,7 @@ MODULE_DEVICE_TABLE(of, bmi160_of_match);
static struct i2c_driver bmi160_i2c_driver = {
.driver = {
.name = "bmi160_i2c",
+ .pm = pm_ptr(&bmi160_core_pm_ops),
.acpi_match_table = bmi160_acpi_match,
.of_match_table = bmi160_of_match,
},
diff --git a/drivers/iio/imu/bmi160/bmi160_spi.c b/drivers/iio/imu/bmi160/bmi160_spi.c
index ebb586904215..3581bd788483 100644
--- a/drivers/iio/imu/bmi160/bmi160_spi.c
+++ b/drivers/iio/imu/bmi160/bmi160_spi.c
@@ -7,6 +7,7 @@
*/
#include <linux/mod_devicetable.h>
#include <linux/module.h>
+#include <linux/pm.h>
#include <linux/regmap.h>
#include <linux/spi/spi.h>
@@ -61,6 +62,7 @@ static struct spi_driver bmi160_spi_driver = {
.acpi_match_table = bmi160_acpi_match,
.of_match_table = bmi160_of_match,
.name = "bmi160_spi",
+ .pm = pm_ptr(&bmi160_core_pm_ops),
},
};
module_spi_driver(bmi160_spi_driver);
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/2] iio: fix suspend and resume triggering for bmi160 and bmi270
2025-05-25 14:25 [PATCH v2 0/2] iio: fix suspend and resume triggering for bmi160 and bmi270 Denis Benato
2025-05-25 14:25 ` [PATCH v2 1/2] iio: bmi270: suspend and resume triggering on relevant pm operations Denis Benato
2025-05-25 14:25 ` [PATCH v2 2/2] iio: bmi160: " Denis Benato
@ 2025-05-26 19:58 ` Andy Shevchenko
2025-05-26 20:13 ` Denis Benato
2 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2025-05-26 19:58 UTC (permalink / raw)
To: Denis Benato
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Alex Lanzano,
Uwe Kleine-König, Peter Zijlstra, Danila Tikhonov, Greg KH,
Derek J . Clark, Philip Müller, linux-iio, linux-kernel
On Sun, May 25, 2025 at 04:25:28PM +0200, Denis Benato wrote:
> Two imu devices bmi160 and bmi270 are similar to bmi323, with the same bug and
> a common usecase: fix the aforementioned bug about triggering not resuming
> after sleep in the same way it was solved for the bmi323 device driver.
>
> The bmi270 patch has been tested on a device where the device irq pin
> is connected to the CPU ensuring it doesn't cause harm to devices that
> do not use hrtimer or other external triggers.
>
> Changelog from v1 [1]
> - include linux/pm.h where needed
> - used "Closed" to reference the solved issue for each driver
> - merged two lines into one (on both drivers)
I got this series twice without any (?) difference in the versions. Care to
explain what's going on?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/2] iio: fix suspend and resume triggering for bmi160 and bmi270
2025-05-26 19:58 ` [PATCH v2 0/2] iio: fix suspend and resume triggering for bmi160 and bmi270 Andy Shevchenko
@ 2025-05-26 20:13 ` Denis Benato
2025-05-26 20:18 ` Andy Shevchenko
0 siblings, 1 reply; 8+ messages in thread
From: Denis Benato @ 2025-05-26 20:13 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Alex Lanzano,
Uwe Kleine-König, Peter Zijlstra, Danila Tikhonov, Greg KH,
Derek J . Clark, Philip Müller, linux-iio, linux-kernel
On 5/26/25 21:58, Andy Shevchenko wrote:
> On Sun, May 25, 2025 at 04:25:28PM +0200, Denis Benato wrote:
>> Two imu devices bmi160 and bmi270 are similar to bmi323, with the same bug and
>> a common usecase: fix the aforementioned bug about triggering not resuming
>> after sleep in the same way it was solved for the bmi323 device driver.
>>
>> The bmi270 patch has been tested on a device where the device irq pin
>> is connected to the CPU ensuring it doesn't cause harm to devices that
>> do not use hrtimer or other external triggers.
>>
>> Changelog from v1 [1]
>> - include linux/pm.h where needed
>> - used "Closed" to reference the solved issue for each driver
>> - merged two lines into one (on both drivers)
> I got this series twice without any (?) difference in the versions. Care to
> explain what's going on?
>
>
I am sorry: mails were not being sent to the main lkml nor the iio mailing list and so
I resent to everybody, otherwise doing "answer to all" would have created a mess
where discussions would get lost.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/2] iio: fix suspend and resume triggering for bmi160 and bmi270
2025-05-26 20:13 ` Denis Benato
@ 2025-05-26 20:18 ` Andy Shevchenko
2025-05-26 23:37 ` Denis Benato
0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2025-05-26 20:18 UTC (permalink / raw)
To: Denis Benato
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Alex Lanzano,
Uwe Kleine-König, Peter Zijlstra, Danila Tikhonov, Greg KH,
Derek J . Clark, Philip Müller, linux-iio, linux-kernel
On Mon, May 26, 2025 at 10:13:00PM +0200, Denis Benato wrote:
> On 5/26/25 21:58, Andy Shevchenko wrote:
> > On Sun, May 25, 2025 at 04:25:28PM +0200, Denis Benato wrote:
> >> Two imu devices bmi160 and bmi270 are similar to bmi323, with the same bug and
> >> a common usecase: fix the aforementioned bug about triggering not resuming
> >> after sleep in the same way it was solved for the bmi323 device driver.
> >>
> >> The bmi270 patch has been tested on a device where the device irq pin
> >> is connected to the CPU ensuring it doesn't cause harm to devices that
> >> do not use hrtimer or other external triggers.
> >>
> >> Changelog from v1 [1]
> >> - include linux/pm.h where needed
> >> - used "Closed" to reference the solved issue for each driver
> >> - merged two lines into one (on both drivers)
> > I got this series twice without any (?) difference in the versions. Care to
> > explain what's going on?
> >
> I am sorry: mails were not being sent to the main lkml nor the iio mailing list and so
> I resent to everybody, otherwise doing "answer to all" would have created a mess
> where discussions would get lost.
Always mention this kind of things in a cover letter when resending and
ideally add a word 'resend' to the Subject.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/2] iio: fix suspend and resume triggering for bmi160 and bmi270
2025-05-26 20:18 ` Andy Shevchenko
@ 2025-05-26 23:37 ` Denis Benato
0 siblings, 0 replies; 8+ messages in thread
From: Denis Benato @ 2025-05-26 23:37 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Alex Lanzano,
Uwe Kleine-König, Peter Zijlstra, Danila Tikhonov, Greg KH,
Derek J . Clark, Philip Müller, linux-iio, linux-kernel
On 5/26/25 22:18, Andy Shevchenko wrote:
> On Mon, May 26, 2025 at 10:13:00PM +0200, Denis Benato wrote:
>> On 5/26/25 21:58, Andy Shevchenko wrote:
>>> On Sun, May 25, 2025 at 04:25:28PM +0200, Denis Benato wrote:
>>>> Two imu devices bmi160 and bmi270 are similar to bmi323, with the same bug and
>>>> a common usecase: fix the aforementioned bug about triggering not resuming
>>>> after sleep in the same way it was solved for the bmi323 device driver.
>>>>
>>>> The bmi270 patch has been tested on a device where the device irq pin
>>>> is connected to the CPU ensuring it doesn't cause harm to devices that
>>>> do not use hrtimer or other external triggers.
>>>>
>>>> Changelog from v1 [1]
>>>> - include linux/pm.h where needed
>>>> - used "Closed" to reference the solved issue for each driver
>>>> - merged two lines into one (on both drivers)
>>> I got this series twice without any (?) difference in the versions. Care to
>>> explain what's going on?
>>>
>> I am sorry: mails were not being sent to the main lkml nor the iio mailing list and so
>> I resent to everybody, otherwise doing "answer to all" would have created a mess
>> where discussions would get lost.
> Always mention this kind of things in a cover letter when resending and
> ideally add a word 'resend' to the Subject.
>
Thank you. I wasn't sure if using RESEND was a good idea because I have only read about it being mentioned in
the context of the original being lost and was thinking about the mailing list receiving a RESEND without the original one.
I will keep this in mind for the future, hoping I won't do this silly mistake again.
Thanks for you patience.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/2] iio: bmi270: suspend and resume triggering on relevant pm operations
2025-05-25 14:25 ` [PATCH v2 1/2] iio: bmi270: suspend and resume triggering on relevant pm operations Denis Benato
@ 2025-05-31 16:59 ` Jonathan Cameron
0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2025-05-31 16:59 UTC (permalink / raw)
To: Denis Benato
Cc: David Lechner, Nuno Sá, Alex Lanzano, Andy Shevchenko,
Uwe Kleine-König, Peter Zijlstra, Danila Tikhonov, Greg KH,
Derek J . Clark, Philip Müller, linux-iio, linux-kernel,
Justin Weiss
On Sun, 25 May 2025 16:25:29 +0200
Denis Benato <benato.denis96@gmail.com> wrote:
> Prevent triggers from stop working after the device has entered sleep:
> use iio_device_suspend_triggering and iio_device_resume_triggering helpers.
>
> Closes: https://lore.kernel.org/all/31d7f7aa-e834-4fd0-a66a-e0ff528425dc@gmail.com
This is a tag, so no blank line here.
I've fixed this in both patches and applied them to the to testing branch of iio.
Currently I'm not planning to rush these in but I could treat them as fixes if
general view is that I should.
>
> Signed-off-by: Denis Benato <benato.denis96@gmail.com>
> Tested-by: Justin Weiss <justin@justinweiss.com>
> ---
> drivers/iio/imu/bmi270/bmi270.h | 2 ++
> drivers/iio/imu/bmi270/bmi270_core.c | 20 ++++++++++++++++++++
> drivers/iio/imu/bmi270/bmi270_i2c.c | 2 ++
> drivers/iio/imu/bmi270/bmi270_spi.c | 2 ++
> 4 files changed, 26 insertions(+)
>
> diff --git a/drivers/iio/imu/bmi270/bmi270.h b/drivers/iio/imu/bmi270/bmi270.h
> index d94525f6aee8..a6c4204032fc 100644
> --- a/drivers/iio/imu/bmi270/bmi270.h
> +++ b/drivers/iio/imu/bmi270/bmi270.h
> @@ -20,4 +20,6 @@ struct device;
> int bmi270_core_probe(struct device *dev, struct regmap *regmap,
> const struct bmi270_chip_info *chip_info);
>
> +extern const struct dev_pm_ops bmi270_core_pm_ops;
> +
> #endif /* BMI270_H_ */
> diff --git a/drivers/iio/imu/bmi270/bmi270_core.c b/drivers/iio/imu/bmi270/bmi270_core.c
> index 2e4469f30d53..b54658f972ad 100644
> --- a/drivers/iio/imu/bmi270/bmi270_core.c
> +++ b/drivers/iio/imu/bmi270/bmi270_core.c
> @@ -982,6 +982,7 @@ int bmi270_core_probe(struct device *dev, struct regmap *regmap,
> indio_dev->available_scan_masks = bmi270_avail_scan_masks;
> indio_dev->modes = INDIO_DIRECT_MODE;
> indio_dev->info = &bmi270_info;
> + dev_set_drvdata(data->dev, indio_dev);
>
> ret = bmi270_trigger_probe(data, indio_dev);
> if (ret)
> @@ -997,6 +998,25 @@ int bmi270_core_probe(struct device *dev, struct regmap *regmap,
> }
> EXPORT_SYMBOL_NS_GPL(bmi270_core_probe, "IIO_BMI270");
>
> +static int bmi270_core_runtime_suspend(struct device *dev)
> +{
> + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> +
> + return iio_device_suspend_triggering(indio_dev);
> +}
> +
> +static int bmi270_core_runtime_resume(struct device *dev)
> +{
> + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> +
> + return iio_device_resume_triggering(indio_dev);
> +}
> +
> +const struct dev_pm_ops bmi270_core_pm_ops = {
> + RUNTIME_PM_OPS(bmi270_core_runtime_suspend, bmi270_core_runtime_resume, NULL)
> +};
> +EXPORT_SYMBOL_NS_GPL(bmi270_core_pm_ops, "IIO_BMI270");
> +
> MODULE_AUTHOR("Alex Lanzano");
> MODULE_DESCRIPTION("BMI270 driver");
> MODULE_LICENSE("GPL");
> diff --git a/drivers/iio/imu/bmi270/bmi270_i2c.c b/drivers/iio/imu/bmi270/bmi270_i2c.c
> index 44699ab58909..c77839b03a96 100644
> --- a/drivers/iio/imu/bmi270/bmi270_i2c.c
> +++ b/drivers/iio/imu/bmi270/bmi270_i2c.c
> @@ -4,6 +4,7 @@
> #include <linux/iio/iio.h>
> #include <linux/module.h>
> #include <linux/mod_devicetable.h>
> +#include <linux/pm.h>
> #include <linux/regmap.h>
>
> #include "bmi270.h"
> @@ -52,6 +53,7 @@ static const struct of_device_id bmi270_of_match[] = {
> static struct i2c_driver bmi270_i2c_driver = {
> .driver = {
> .name = "bmi270_i2c",
> + .pm = pm_ptr(&bmi270_core_pm_ops),
> .acpi_match_table = bmi270_acpi_match,
> .of_match_table = bmi270_of_match,
> },
> diff --git a/drivers/iio/imu/bmi270/bmi270_spi.c b/drivers/iio/imu/bmi270/bmi270_spi.c
> index 88a77aba5e4f..19dd7734f9d0 100644
> --- a/drivers/iio/imu/bmi270/bmi270_spi.c
> +++ b/drivers/iio/imu/bmi270/bmi270_spi.c
> @@ -3,6 +3,7 @@
> #include <linux/iio/iio.h>
> #include <linux/mod_devicetable.h>
> #include <linux/module.h>
> +#include <linux/pm.h>
> #include <linux/regmap.h>
> #include <linux/spi/spi.h>
>
> @@ -79,6 +80,7 @@ static const struct of_device_id bmi270_of_match[] = {
> static struct spi_driver bmi270_spi_driver = {
> .driver = {
> .name = "bmi270",
> + .pm = pm_ptr(&bmi270_core_pm_ops),
> .of_match_table = bmi270_of_match,
> },
> .probe = bmi270_spi_probe,
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-05-31 16:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-25 14:25 [PATCH v2 0/2] iio: fix suspend and resume triggering for bmi160 and bmi270 Denis Benato
2025-05-25 14:25 ` [PATCH v2 1/2] iio: bmi270: suspend and resume triggering on relevant pm operations Denis Benato
2025-05-31 16:59 ` Jonathan Cameron
2025-05-25 14:25 ` [PATCH v2 2/2] iio: bmi160: " Denis Benato
2025-05-26 19:58 ` [PATCH v2 0/2] iio: fix suspend and resume triggering for bmi160 and bmi270 Andy Shevchenko
2025-05-26 20:13 ` Denis Benato
2025-05-26 20:18 ` Andy Shevchenko
2025-05-26 23:37 ` Denis Benato
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).