Skip to content

Commit

Permalink
bmi323-imu: use iio_suspend_triggering and iio_resume_triggering to e…
Browse files Browse the repository at this point in the history
…nsure hrtimer is resumed after device sleep
  • Loading branch information
NeroReflex committed Jul 24, 2024
1 parent c4b2a54 commit 899d3c5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/iio/imu/bmi323/bmi323.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,6 @@
struct device;
int bmi323_core_probe(struct device *dev);
extern const struct regmap_config bmi323_regmap_config;
extern const struct dev_pm_ops bmi323_core_pm_ops;

#endif
44 changes: 44 additions & 0 deletions drivers/iio/imu/bmi323/bmi323_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2119,6 +2119,50 @@ int bmi323_core_probe(struct device *dev)
}
EXPORT_SYMBOL_NS_GPL(bmi323_core_probe, IIO_BMI323);

#if defined(CONFIG_PM_SLEEP)
static int bmi323_core_suspend(struct device *dev)
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct bmi323_data *data = iio_priv(indio_dev);

return 0;
}

static int bmi323_core_resume(struct device *dev)
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct bmi323_data *data = iio_priv(indio_dev);
int ret = iio_resume_triggering(indio_dev);

return ret;
}
#endif

#if defined(CONFIG_PM)
static int bmi323_core_runtime_suspend(struct device *dev)
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct bmi323_data *data = iio_priv(indio_dev);
int ret = iio_suspend_triggering(indio_dev);

return ret;
}

static int bmi323_core_runtime_resume(struct device *dev)
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);

return 0;
}
#endif

const struct dev_pm_ops bmi323_core_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(bmi323_core_suspend, bmi323_core_resume)
SET_RUNTIME_PM_OPS(bmi323_core_runtime_suspend,
bmi323_core_runtime_resume, NULL)
};
EXPORT_SYMBOL_NS_GPL(bmi323_core_pm_ops, IIO_BMI323);

MODULE_DESCRIPTION("Bosch BMI323 IMU driver");
MODULE_AUTHOR("Jagath Jog J <[email protected]>");
MODULE_LICENSE("GPL");
1 change: 1 addition & 0 deletions drivers/iio/imu/bmi323/bmi323_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ static struct i2c_driver bmi323_i2c_driver = {
.name = "bmi323",
.of_match_table = bmi323_of_i2c_match,
.acpi_match_table = bmi323_acpi_match,
.pm = &bmi323_core_pm_ops,
},
.probe = bmi323_i2c_probe,
.id_table = bmi323_i2c_ids,
Expand Down
1 change: 1 addition & 0 deletions drivers/iio/imu/bmi323/bmi323_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ static struct spi_driver bmi323_spi_driver = {
.driver = {
.name = "bmi323",
.of_match_table = bmi323_of_spi_match,
.pm = &bmi323_core_pm_ops,
},
.probe = bmi323_spi_probe,
.id_table = bmi323_spi_ids,
Expand Down

0 comments on commit 899d3c5

Please sign in to comment.