[PATCH v3 3/3] iio: temperature: mlx90632 Change return value of sensor measurement channel

cmo@melexis.com posted 3 patches 3 years, 7 months ago
There is a newer version of this series
[PATCH v3 3/3] iio: temperature: mlx90632 Change return value of sensor measurement channel
Posted by cmo@melexis.com 3 years, 7 months ago
From: Crt Mori <cmo@melexis.com>

The current EINVAL value is more applicable to embedded library, where
user can actually put the fixed value to the sensor. In case of the
driver if the value of the channel is invalid it is better in inform
userspace that Channel was out of range as that implies more to internal
driver error than invalid input. It also makes for easier debugging of
where the error comes from during the development.

Signed-off-by: Crt Mori <cmo@melexis.com>
---
 drivers/iio/temperature/mlx90632.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/temperature/mlx90632.c b/drivers/iio/temperature/mlx90632.c
index 6b33284eb0b6..aee065a38772 100644
--- a/drivers/iio/temperature/mlx90632.c
+++ b/drivers/iio/temperature/mlx90632.c
@@ -436,7 +436,7 @@ static int mlx90632_channel_new_select(int perform_ret, uint8_t *channel_new,
 		*channel_old = 1;
 		break;
 	default:
-		return -EINVAL;
+		return -ECHRNG;
 	}
 
 	return 0;
-- 
2.34.1
Re: [PATCH v3 3/3] iio: temperature: mlx90632 Change return value of sensor measurement channel
Posted by Andy Shevchenko 3 years, 7 months ago
On Tue, Sep 6, 2022 at 12:05 PM <cmo@melexis.com> wrote:
>
> From: Crt Mori <cmo@melexis.com>
>
> The current EINVAL value is more applicable to embedded library, where

an embedded
  ...or...
libraries

> user can actually put the fixed value to the sensor. In case of the
> driver if the value of the channel is invalid it is better in inform
> userspace that Channel was out of range as that implies more to internal
> driver error than invalid input. It also makes for easier debugging of
> where the error comes from during the development.

As I said earlier I'm in favour of this change to at least make good
use of this error code since it is confirmed to help debugging.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: Crt Mori <cmo@melexis.com>
> ---
>  drivers/iio/temperature/mlx90632.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/temperature/mlx90632.c b/drivers/iio/temperature/mlx90632.c
> index 6b33284eb0b6..aee065a38772 100644
> --- a/drivers/iio/temperature/mlx90632.c
> +++ b/drivers/iio/temperature/mlx90632.c
> @@ -436,7 +436,7 @@ static int mlx90632_channel_new_select(int perform_ret, uint8_t *channel_new,
>                 *channel_old = 1;
>                 break;
>         default:
> -               return -EINVAL;
> +               return -ECHRNG;
>         }
>
>         return 0;
> --
> 2.34.1
>


-- 
With Best Regards,
Andy Shevchenko