diff mbox series

[13/13] iio: imu: inv_mpu6050: temperature only work with accel/gyro

Message ID 20200212174048.1034-14-jmaneyrol@invensense.com (mailing list archive)
State New, archived
Headers show
Series Rework sensors engines and power management | expand

Commit Message

Jean-Baptiste Maneyrol Feb. 12, 2020, 5:40 p.m. UTC
Temperature sensor works correctly only when accel and/or gyro
is turned on. Prevent polling value if they are not running.
Anyway it doesn't make sense to use it without sensor engines
on.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
---
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Jonathan Cameron Feb. 15, 2020, 6:23 p.m. UTC | #1
On Wed, 12 Feb 2020 18:40:48 +0100
Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> wrote:

> Temperature sensor works correctly only when accel and/or gyro
> is turned on. Prevent polling value if they are not running.
> Anyway it doesn't make sense to use it without sensor engines
> on.
> 
> Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
> ---
>  drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index f698d2aa61f4..3212030cc083 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -597,6 +597,11 @@ static int inv_mpu6050_read_channel_data(struct iio_dev *indio_dev,
>  					      chan->channel2, val);
>  		break;
>  	case IIO_TEMP:
> +		/* temperature sensor work only with accel and/or gyro */
> +		if (!st->chip_config.accl_en && !st->chip_config.gyro_en) {
> +			result = -ENOTSUPP;

I'd suggest -EBUSY to indicate that it might work sometime in the future.

> +			goto error_power_off;
> +		}
>  		if (!st->chip_config.temp_en) {
>  			result = inv_mpu6050_switch_engine(st, true,
>  					INV_MPU6050_SENSOR_TEMP);
Jean-Baptiste Maneyrol Feb. 18, 2020, 4:46 p.m. UTC | #2
Hello,

OK it makes sense. I will use -EBUSY in v2

JB


From: linux-iio-owner@vger.kernel.org <linux-iio-owner@vger.kernel.org> on behalf of Jonathan Cameron <jic23@kernel.org>

Sent: Saturday, February 15, 2020 19:23

To: Jean-Baptiste Maneyrol <JManeyrol@invensense.com>

Cc: linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>

Subject: Re: [PATCH 13/13] iio: imu: inv_mpu6050: temperature only work with accel/gyro

 


 CAUTION: This email originated from outside of the organization. Please make sure the sender is who they say they are and do not click links or open attachments unless you recognize the sender and know the content is safe.



On Wed, 12 Feb 2020 18:40:48 +0100

Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> wrote:



> Temperature sensor works correctly only when accel and/or gyro

> is turned on. Prevent polling value if they are not running.

> Anyway it doesn't make sense to use it without sensor engines

> on.

> 

> Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

> ---

>  drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 5 +++++

>  1 file changed, 5 insertions(+)

> 

> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c

> index f698d2aa61f4..3212030cc083 100644

> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c

> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c

> @@ -597,6 +597,11 @@ static int inv_mpu6050_read_channel_data(struct iio_dev *indio_dev,

>                                              chan->channel2, val);

>                break;

>        case IIO_TEMP:

> +             /* temperature sensor work only with accel and/or gyro */

> +             if (!st->chip_config.accl_en && !st->chip_config.gyro_en) {

> +                     result = -ENOTSUPP;



I'd suggest -EBUSY to indicate that it might work sometime in the future.



> +                     goto error_power_off;

> +             }

>                if (!st->chip_config.temp_en) {

>                        result = inv_mpu6050_switch_engine(st, true,

>                                        INV_MPU6050_SENSOR_TEMP);
diff mbox series

Patch

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index f698d2aa61f4..3212030cc083 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -597,6 +597,11 @@  static int inv_mpu6050_read_channel_data(struct iio_dev *indio_dev,
 					      chan->channel2, val);
 		break;
 	case IIO_TEMP:
+		/* temperature sensor work only with accel and/or gyro */
+		if (!st->chip_config.accl_en && !st->chip_config.gyro_en) {
+			result = -ENOTSUPP;
+			goto error_power_off;
+		}
 		if (!st->chip_config.temp_en) {
 			result = inv_mpu6050_switch_engine(st, true,
 					INV_MPU6050_SENSOR_TEMP);