lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240725122811.00004769@Huawei.com>
Date: Thu, 25 Jul 2024 12:28:11 +0100
From: Jonathan Cameron <Jonathan.Cameron@...wei.com>
To: Denis Benato <benato.denis96@...il.com>
CC: Jonathan Cameron <jic23@...nel.org>, Lars-Peter Clausen <lars@...afoo.de>,
	Jagath Jog J <jagathjog1996@...il.com>, <linux-iio@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>, "Luke D . Jones" <luke@...nes.dev>, Jonathan
 LoBue <jlobue10@...il.com>
Subject: Re: [PATCH 2/2] iio: bmi323: suspend and resume triggering on
 relevant pm operations

On Thu, 25 Jul 2024 02:26:41 +0200
Denis Benato <benato.denis96@...il.com> wrote:

> Prevent triggers from stop working after the device has entered sleep:
> use iio_device_suspend_triggering and iio_device_resume_triggering helpers.
> 
> Signed-off-by: Denis Benato <benato.denis96@...il.com>
> ---
>  drivers/iio/imu/bmi323/bmi323.h      |  1 +
>  drivers/iio/imu/bmi323/bmi323_core.c | 29 ++++++++++++++++++++++++++++
>  drivers/iio/imu/bmi323/bmi323_i2c.c  |  1 +
>  drivers/iio/imu/bmi323/bmi323_spi.c  |  1 +
>  4 files changed, 32 insertions(+)
> 
> diff --git a/drivers/iio/imu/bmi323/bmi323.h b/drivers/iio/imu/bmi323/bmi323.h
> index dff126d41658..209bccb1f335 100644
> --- a/drivers/iio/imu/bmi323/bmi323.h
> +++ b/drivers/iio/imu/bmi323/bmi323.h
> @@ -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
> diff --git a/drivers/iio/imu/bmi323/bmi323_core.c b/drivers/iio/imu/bmi323/bmi323_core.c
> index d708d1fe3e42..b318544957de 100644
> --- a/drivers/iio/imu/bmi323/bmi323_core.c
> +++ b/drivers/iio/imu/bmi323/bmi323_core.c
> @@ -2121,6 +2121,35 @@ int bmi323_core_probe(struct device *dev)
>  }
>  EXPORT_SYMBOL_NS_GPL(bmi323_core_probe, IIO_BMI323);
>  
> +#if defined(CONFIG_PM)
> +static int bmi323_core_runtime_suspend(struct device *dev)
> +{
> +	struct iio_dev *indio_dev = dev_get_drvdata(dev);
> +

I want to think about patch 1 for a few days. In meantime.

> +	int ret = iio_device_suspend_triggering(indio_dev);

	return iio_device_suspend_triggering(indio_dev);

> +
> +	return ret;
> +}
> +
> +static int bmi323_core_runtime_resume(struct device *dev)
> +{
> +	struct iio_dev *indio_dev = dev_get_drvdata(dev);
> +
> +	int ret = iio_device_resume_triggering(indio_dev);
> +
> +	return ret;

	return iio_device_resume_triggering(indio_dev);

> +}
> +
> +#endif
> +
> +const struct dev_pm_ops bmi323_core_pm_ops = {
> +#if defined(CONFIG_PM)

SET_RUNTIME_PM_OPS() is defined to nothing if CONFIG_PM is
not enabled so these protections aren't needed.


> +	SET_RUNTIME_PM_OPS(bmi323_core_runtime_suspend,
> +			   bmi323_core_runtime_resume, NULL)
> +#endif
> +};
> +EXPORT_SYMBOL_NS_GPL(bmi323_core_pm_ops, IIO_BMI323);
> +
>  MODULE_DESCRIPTION("Bosch BMI323 IMU driver");
>  MODULE_AUTHOR("Jagath Jog J <jagathjog1996@...il.com>");
>  MODULE_LICENSE("GPL");
> diff --git a/drivers/iio/imu/bmi323/bmi323_i2c.c b/drivers/iio/imu/bmi323/bmi323_i2c.c
> index 52140bf05765..79c9b029a209 100644
> --- a/drivers/iio/imu/bmi323/bmi323_i2c.c
> +++ b/drivers/iio/imu/bmi323/bmi323_i2c.c
> @@ -128,6 +128,7 @@ MODULE_DEVICE_TABLE(of, bmi323_of_i2c_match);
>  static struct i2c_driver bmi323_i2c_driver = {
>  	.driver = {
>  		.name = "bmi323",
> +		.pm = &bmi323_core_pm_ops,

pm_ptr() to let the compiler drop bmi323_core_pm_ops if
!CONFIG_PM

>  		.of_match_table = bmi323_of_i2c_match,
>  		.acpi_match_table = bmi323_acpi_match,
>  	},
> diff --git a/drivers/iio/imu/bmi323/bmi323_spi.c b/drivers/iio/imu/bmi323/bmi323_spi.c
> index 7b1e8127d0dd..ec3238d93862 100644
> --- a/drivers/iio/imu/bmi323/bmi323_spi.c
> +++ b/drivers/iio/imu/bmi323/bmi323_spi.c
> @@ -79,6 +79,7 @@ MODULE_DEVICE_TABLE(of, bmi323_of_spi_match);
>  static struct spi_driver bmi323_spi_driver = {
>  	.driver = {
>  		.name = "bmi323",
> +		.pm = &bmi323_core_pm_ops,
>  		.of_match_table = bmi323_of_spi_match,
>  	},
>  	.probe = bmi323_spi_probe,


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ