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
  2026-11-27  9:36 ` Nuno Sá
  0 siblings, 2 replies; 3+ 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] 3+ messages in thread

* Re: [PATCH v1 1/1] iio: core: Use an API instead of relying on a specific error code
  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
  2026-11-27  9:36 ` Nuno Sá
  1 sibling, 0 replies; 3+ messages in thread
From: Joshua Crofts @ 2026-11-24 12:58 UTC (permalink / raw)
  To: Andy Shevchenko, Jonathan Cameron, linux-iio
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko

On 24-Nov-26 11:38, Andy Shevchenko wrote:
> 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>
> ---
Reviewed-by: Joshua Crofts <crofts@kernel.org>

-- 
Kind regards,
Joshua Crofts

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

* Re: [PATCH v1 1/1] iio: core: Use an API instead of relying on a specific error code
  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
@ 2026-11-27  9:36 ` Nuno Sá
  1 sibling, 0 replies; 3+ messages in thread
From: Nuno Sá @ 2026-11-27  9:36 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Jonathan Cameron, linux-iio, Jonathan Cameron, David Lechner,
	Andy Shevchenko

On Tue, Nov 24, 2026 at 11:38:41AM +0100, Andy Shevchenko wrote:
> 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>
> ---

Reviewed-by: Nuno Sá <nuno.sa@analog.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	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-27  9:37 UTC | newest]

Thread overview: 3+ 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
2026-11-27  9:36 ` Nuno Sá

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