All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 3/3] iio: temperature: mlx90632 Change return value of sensor measurement channel
@ 2022-09-03 22:24 cmo
  2022-09-04 14:49 ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: cmo @ 2022-09-03 22:24 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, linux-kernel, Andy Shevchenko, Crt Mori

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 37edd324d6a1..d511d36942d3 100644
--- a/drivers/iio/temperature/mlx90632.c
+++ b/drivers/iio/temperature/mlx90632.c
@@ -435,7 +435,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


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

* Re: [PATCH v2 3/3] iio: temperature: mlx90632 Change return value of sensor measurement channel
  2022-09-03 22:24 [PATCH v2 3/3] iio: temperature: mlx90632 Change return value of sensor measurement channel cmo
@ 2022-09-04 14:49 ` Jonathan Cameron
  2022-09-04 15:27   ` Crt Mori
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2022-09-04 14:49 UTC (permalink / raw)
  To: cmo; +Cc: linux-iio, linux-kernel, Andy Shevchenko

On Sun,  4 Sep 2022 00:24:22 +0200
cmo@melexis.com wrote:

> 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>
Hmm. That's an obscure return value - I think it's mostly going to confuse
anyone who ever gets it.  So not sure this change is wise even though the
descriptive text for that one does seem very much suited to this usecase.

> ---
>  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 37edd324d6a1..d511d36942d3 100644
> --- a/drivers/iio/temperature/mlx90632.c
> +++ b/drivers/iio/temperature/mlx90632.c
> @@ -435,7 +435,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;


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

* Re: [PATCH v2 3/3] iio: temperature: mlx90632 Change return value of sensor measurement channel
  2022-09-04 14:49 ` Jonathan Cameron
@ 2022-09-04 15:27   ` Crt Mori
  2022-09-04 15:56     ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Crt Mori @ 2022-09-04 15:27 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, linux-kernel, Andy Shevchenko

On Sun, 4 Sept 2022 at 17:23, Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Sun,  4 Sep 2022 00:24:22 +0200
> cmo@melexis.com wrote:
>
> > 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>
> Hmm. That's an obscure return value - I think it's mostly going to confuse
> anyone who ever gets it.  So not sure this change is wise even though the
> descriptive text for that one does seem very much suited to this usecase.
>
I did get it few times during the development due to read when sensor
is not busy, but the measurement data not yet updated correctly due to
powermode switch. I think I added enough delays all around to avoid
hitting it and with proper power mode switching, but there might be a
case, so it will be easier to spot in the source code in future. I
would not remove it, if that is what you are proposing.

> > ---
> >  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 37edd324d6a1..d511d36942d3 100644
> > --- a/drivers/iio/temperature/mlx90632.c
> > +++ b/drivers/iio/temperature/mlx90632.c
> > @@ -435,7 +435,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;
>

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

* Re: [PATCH v2 3/3] iio: temperature: mlx90632 Change return value of sensor measurement channel
  2022-09-04 15:27   ` Crt Mori
@ 2022-09-04 15:56     ` Jonathan Cameron
  2022-09-04 19:19       ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2022-09-04 15:56 UTC (permalink / raw)
  To: Crt Mori; +Cc: linux-iio, linux-kernel, Andy Shevchenko

On Sun, 4 Sep 2022 17:27:28 +0200
Crt Mori <cmo@melexis.com> wrote:

> On Sun, 4 Sept 2022 at 17:23, Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > On Sun,  4 Sep 2022 00:24:22 +0200
> > cmo@melexis.com wrote:
> >  
> > > 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>  
> > Hmm. That's an obscure return value - I think it's mostly going to confuse
> > anyone who ever gets it.  So not sure this change is wise even though the
> > descriptive text for that one does seem very much suited to this usecase.
> >  
> I did get it few times during the development due to read when sensor
> is not busy, but the measurement data not yet updated correctly due to
> powermode switch. I think I added enough delays all around to avoid
> hitting it and with proper power mode switching, but there might be a
> case, so it will be easier to spot in the source code in future. I
> would not remove it, if that is what you are proposing.

I meant leave it as EINVAL. The users of ECHRNG are very very
few in number, so I don't have a good understanding of it's expected
uses.. 
> 
> > > ---
> > >  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 37edd324d6a1..d511d36942d3 100644
> > > --- a/drivers/iio/temperature/mlx90632.c
> > > +++ b/drivers/iio/temperature/mlx90632.c
> > > @@ -435,7 +435,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;  
> >  


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

* Re: [PATCH v2 3/3] iio: temperature: mlx90632 Change return value of sensor measurement channel
  2022-09-04 15:56     ` Jonathan Cameron
@ 2022-09-04 19:19       ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-09-04 19:19 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: Crt Mori, linux-iio, Linux Kernel Mailing List

On Sun, Sep 4, 2022 at 7:30 PM Jonathan Cameron <jic23@kernel.org> wrote:
> On Sun, 4 Sep 2022 17:27:28 +0200
> Crt Mori <cmo@melexis.com> wrote:
> > On Sun, 4 Sept 2022 at 17:23, Jonathan Cameron <jic23@kernel.org> wrote:
> > > On Sun,  4 Sep 2022 00:24:22 +0200
> > > cmo@melexis.com wrote:
> > >
> > > > 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>
> > > Hmm. That's an obscure return value - I think it's mostly going to confuse
> > > anyone who ever gets it.  So not sure this change is wise even though the
> > > descriptive text for that one does seem very much suited to this usecase.
> > >
> > I did get it few times during the development due to read when sensor
> > is not busy, but the measurement data not yet updated correctly due to
> > powermode switch. I think I added enough delays all around to avoid
> > hitting it and with proper power mode switching, but there might be a
> > case, so it will be easier to spot in the source code in future. I
> > would not remove it, if that is what you are proposing.
>
> I meant leave it as EINVAL. The users of ECHRNG are very very
> few in number, so I don't have a good understanding of it's expected
> uses..

The problem with EINVAL is that it happens in 95% of error cases and
you really need to rebuild the module to get it where it occurs. I
kinda tend to acknowledge the patch, because we still miss the JSON
error reporting in the kernel which would fix most annoying problems
with debugging kernel code.

-- 
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2022-09-04 19:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-03 22:24 [PATCH v2 3/3] iio: temperature: mlx90632 Change return value of sensor measurement channel cmo
2022-09-04 14:49 ` Jonathan Cameron
2022-09-04 15:27   ` Crt Mori
2022-09-04 15:56     ` Jonathan Cameron
2022-09-04 19:19       ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.