Linux IIO development
 help / color / mirror / Atom feed
* [PATCH v1 1/1] iio: core: Use an API instead of relying on a specific error code
@ 2026-11-24 10:38 Andy Shevchenko
  2026-11-24 12:58 ` Joshua Crofts
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2026-11-24 10:38 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Andy Shevchenko

Use device_property_present() instead of relying on a specific error code
when parsing mount matrix to reliably detect absence of a property.

No functional changes intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/industrialio-core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 3b66d7b765d5..5f9d6e852286 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -567,6 +567,10 @@ int iio_read_mount_matrix(struct device *dev, struct iio_mount_matrix *matrix)
 	size_t len = ARRAY_SIZE(iio_mount_idmatrix.rotation);
 	int err;
 
+	if (!device_property_present(dev, "mount-matrix"))
+		/* Matrix was not declared at all: fallback to identity. */
+		return iio_setup_mount_idmatrix(dev, matrix);
+
 	err = device_property_read_string_array(dev, "mount-matrix", matrix->rotation, len);
 	if (err == len)
 		return 0;
@@ -575,12 +579,8 @@ int iio_read_mount_matrix(struct device *dev, struct iio_mount_matrix *matrix)
 		/* Invalid number of matrix entries. */
 		return -EINVAL;
 
-	if (err != -EINVAL)
-		/* Invalid matrix declaration format. */
-		return err;
-
-	/* Matrix was not declared at all: fallback to identity. */
-	return iio_setup_mount_idmatrix(dev, matrix);
+	/* Invalid matrix declaration format. */
+	return err;
 }
 EXPORT_SYMBOL(iio_read_mount_matrix);
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-24 12:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 10:38 [PATCH v1 1/1] iio: core: Use an API instead of relying on a specific error code Andy Shevchenko
2026-11-24 12:58 ` Joshua Crofts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox