Skip to contentSkip to conversation

iio: imu: lsm6dsx: Fix mount matrix retrieval

PATCH RESEND Superseded Alejandro Tafalla 2 participants 2 messages Jul 13, 2023

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND v2 1/1 iio: imu: lsm6dsx: Fix mount matrix retrieval

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")

---
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(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +5 -5
index 6a18b363cf73..1a4752c95601 100644
@@ -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])
Signature · 1 line
2.41.0
maintainer
#1 lore raw
Quoted 28 lines · Alejandro Tafalla

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")

---
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(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +1 -1
index 6a18b363cf73..1a4752c95601 100644
@@ -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

drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, · line 2770

Quoted 5 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +1 -1
@@ -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

Quoted 19 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +3 -3
 		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])
Signature · 1 line
2.41.0