diff mbox series

[RESEND,v2] iio: imu: lsm6dsx: Fix mount matrix retrieval

Message ID 4847336.31r3eYUQgx@alexbook (mailing list archive)
State Superseded
Headers show
Series [RESEND,v2] iio: imu: lsm6dsx: Fix mount matrix retrieval | expand

Commit Message

Alejandro Tafalla July 13, 2023, 5:35 a.m. UTC
The function lsm6dsx_get_acpi_mount_matrix should return an error when ACPI
support is not enabled to allow executing iio_read_mount_matrix in the
probe function.

Fixes: dc3d25f22b88 ("iio: imu: lsm6dsx: Add ACPI mount matrix retrieval")

Signed-off-by: Alejandro Tafalla <atafalla@dnyon.com>
---
Changes in v2:
- Use of error codes instead of true/false

 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Lorenzo Bianconi July 13, 2023, 6:45 a.m. UTC | #1
On Jul 13, Alejandro Tafalla wrote:
> The function lsm6dsx_get_acpi_mount_matrix should return an error when ACPI
> support is not enabled to allow executing iio_read_mount_matrix in the
> probe function.
> 
> Fixes: dc3d25f22b88 ("iio: imu: lsm6dsx: Add ACPI mount matrix retrieval")
> 
> Signed-off-by: Alejandro Tafalla <atafalla@dnyon.com>
> ---
> Changes in v2:
> - Use of error codes instead of true/false
> 
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 6a18b363cf73..1a4752c95601 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -2687,7 +2687,7 @@ static int lsm6dsx_get_acpi_mount_matrix(struct device *dev,
>  static int lsm6dsx_get_acpi_mount_matrix(struct device *dev,
>  					  struct iio_mount_matrix *orientation)
>  {
> -	return false;
> +	return -EOPNOTSUPP;
>  }
>  
>  #endif
> @@ -2767,11 +2767,11 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
>  	}
>  
>  	err = lsm6dsx_get_acpi_mount_matrix(hw->dev, &hw->orientation);
> -	if (err) {
> +	if (err == -EOPNOTSUPP)

why do you need this extra check? According to the previous codebase, even if
lsm6dsx_get_acpi_mount_matrix() fails we want to fallback to
iio_read_mount_matrix(), right?

Regards,
Lorenzo

>  		err = iio_read_mount_matrix(hw->dev, &hw->orientation);
> -		if (err)
> -			return err;
> -	}
> +
> +	if (err)
> +		return err;
>  
>  	for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {
>  		if (!hw->iio_devs[i])
> -- 
> 2.41.0
> 
> 
> 
> 
> 
> 
>
diff mbox series

Patch

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index 6a18b363cf73..1a4752c95601 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -2687,7 +2687,7 @@  static int lsm6dsx_get_acpi_mount_matrix(struct device *dev,
 static int lsm6dsx_get_acpi_mount_matrix(struct device *dev,
 					  struct iio_mount_matrix *orientation)
 {
-	return false;
+	return -EOPNOTSUPP;
 }
 
 #endif
@@ -2767,11 +2767,11 @@  int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
 	}
 
 	err = lsm6dsx_get_acpi_mount_matrix(hw->dev, &hw->orientation);
-	if (err) {
+	if (err == -EOPNOTSUPP)
 		err = iio_read_mount_matrix(hw->dev, &hw->orientation);
-		if (err)
-			return err;
-	}
+
+	if (err)
+		return err;
 
 	for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {
 		if (!hw->iio_devs[i])