linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools/iio: iio_event_monitor: Fix ioctl error check
@ 2021-04-28 15:08 Paul Cercueil
  2021-04-28 15:30 ` Sa, Nuno
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Cercueil @ 2021-04-28 15:08 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler
  Cc: linux-iio, linux-kernel, Paul Cercueil

The ioctrl() call will return errno=EINVAL if the device does not
support the events interface, and not ENODEV.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 tools/iio/iio_event_monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
index bb03859db89d..cdd9a84f18fa 100644
--- a/tools/iio/iio_event_monitor.c
+++ b/tools/iio/iio_event_monitor.c
@@ -323,7 +323,7 @@ int main(int argc, char **argv)
 	ret = ioctl(fd, IIO_GET_EVENT_FD_IOCTL, &event_fd);
 	if (ret == -1 || event_fd == -1) {
 		ret = -errno;
-		if (ret == -ENODEV)
+		if (ret == -EINVAL)
 			fprintf(stderr,
 				"This device does not support events\n");
 		else
-- 
2.30.2


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

* RE: [PATCH] tools/iio: iio_event_monitor: Fix ioctl error check
  2021-04-28 15:08 [PATCH] tools/iio: iio_event_monitor: Fix ioctl error check Paul Cercueil
@ 2021-04-28 15:30 ` Sa, Nuno
  2021-04-28 15:33   ` Sa, Nuno
  0 siblings, 1 reply; 7+ messages in thread
From: Sa, Nuno @ 2021-04-28 15:30 UTC (permalink / raw)
  To: Paul Cercueil, Jonathan Cameron, Lars-Peter Clausen,
	Peter Meerwald-Stadler
  Cc: linux-iio, linux-kernel

> From: Paul Cercueil <paul@crapouillou.net>
> Sent: Wednesday, April 28, 2021 5:08 PM
> To: Jonathan Cameron <jic23@kernel.org>; Lars-Peter Clausen
> <lars@metafoo.de>; Peter Meerwald-Stadler
> <pmeerw@pmeerw.net>
> Cc: linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org; Paul
> Cercueil <paul@crapouillou.net>
> Subject: [PATCH] tools/iio: iio_event_monitor: Fix ioctl error check
> 
> 
> The ioctrl() call will return errno=EINVAL if the device does not
> support the events interface, and not ENODEV.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

Reviewed-by: Nuno Sa <nuno.sa@analog.com>

> ---
>  tools/iio/iio_event_monitor.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/iio/iio_event_monitor.c
> b/tools/iio/iio_event_monitor.c
> index bb03859db89d..cdd9a84f18fa 100644
> --- a/tools/iio/iio_event_monitor.c
> +++ b/tools/iio/iio_event_monitor.c
> @@ -323,7 +323,7 @@ int main(int argc, char **argv)
>  	ret = ioctl(fd, IIO_GET_EVENT_FD_IOCTL, &event_fd);
>  	if (ret == -1 || event_fd == -1) {
>  		ret = -errno;
> -		if (ret == -ENODEV)
> +		if (ret == -EINVAL)
>  			fprintf(stderr,
>  				"This device does not support
> events\n");
>  		else
> --
> 2.30.2


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

* RE: [PATCH] tools/iio: iio_event_monitor: Fix ioctl error check
  2021-04-28 15:30 ` Sa, Nuno
@ 2021-04-28 15:33   ` Sa, Nuno
  2021-05-03 11:06     ` Jonathan Cameron
  0 siblings, 1 reply; 7+ messages in thread
From: Sa, Nuno @ 2021-04-28 15:33 UTC (permalink / raw)
  To: Sa, Nuno, Paul Cercueil, Jonathan Cameron, Lars-Peter Clausen,
	Peter Meerwald-Stadler
  Cc: linux-iio, linux-kernel

> From: Sa, Nuno <Nuno.Sa@analog.com>
> Sent: Wednesday, April 28, 2021 5:31 PM
> To: Paul Cercueil <paul@crapouillou.net>; Jonathan Cameron
> <jic23@kernel.org>; Lars-Peter Clausen <lars@metafoo.de>; Peter
> Meerwald-Stadler <pmeerw@pmeerw.net>
> Cc: linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: RE: [PATCH] tools/iio: iio_event_monitor: Fix ioctl error check
> 
> 
> > From: Paul Cercueil <paul@crapouillou.net>
> > Sent: Wednesday, April 28, 2021 5:08 PM
> > To: Jonathan Cameron <jic23@kernel.org>; Lars-Peter Clausen
> > <lars@metafoo.de>; Peter Meerwald-Stadler
> > <pmeerw@pmeerw.net>
> > Cc: linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org; Paul
> > Cercueil <paul@crapouillou.net>
> > Subject: [PATCH] tools/iio: iio_event_monitor: Fix ioctl error check
> >
> >
> > The ioctrl() call will return errno=EINVAL if the device does not
> > support the events interface, and not ENODEV.
> >
> > Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> 
> Reviewed-by: Nuno Sa <nuno.sa@analog.com>
> 

I guess this should have a Fixes: tag...

- Nuno Sá

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

* Re: [PATCH] tools/iio: iio_event_monitor: Fix ioctl error check
  2021-04-28 15:33   ` Sa, Nuno
@ 2021-05-03 11:06     ` Jonathan Cameron
  2021-05-03 11:07       ` Jonathan Cameron
  2021-05-03 13:56       ` Linus Walleij
  0 siblings, 2 replies; 7+ messages in thread
From: Jonathan Cameron @ 2021-05-03 11:06 UTC (permalink / raw)
  To: Sa, Nuno
  Cc: Paul Cercueil, Lars-Peter Clausen, Peter Meerwald-Stadler,
	linux-iio, linux-kernel, Linus Walleij

On Wed, 28 Apr 2021 15:33:21 +0000
"Sa, Nuno" <Nuno.Sa@analog.com> wrote:

> > From: Sa, Nuno <Nuno.Sa@analog.com>
> > Sent: Wednesday, April 28, 2021 5:31 PM
> > To: Paul Cercueil <paul@crapouillou.net>; Jonathan Cameron
> > <jic23@kernel.org>; Lars-Peter Clausen <lars@metafoo.de>; Peter
> > Meerwald-Stadler <pmeerw@pmeerw.net>
> > Cc: linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org
> > Subject: RE: [PATCH] tools/iio: iio_event_monitor: Fix ioctl error check
> > 
> >   
> > > From: Paul Cercueil <paul@crapouillou.net>
> > > Sent: Wednesday, April 28, 2021 5:08 PM
> > > To: Jonathan Cameron <jic23@kernel.org>; Lars-Peter Clausen
> > > <lars@metafoo.de>; Peter Meerwald-Stadler
> > > <pmeerw@pmeerw.net>
> > > Cc: linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org; Paul
> > > Cercueil <paul@crapouillou.net>
> > > Subject: [PATCH] tools/iio: iio_event_monitor: Fix ioctl error check
> > >
> > >
> > > The ioctrl() call will return errno=EINVAL if the device does not
> > > support the events interface, and not ENODEV.
> > >
> > > Signed-off-by: Paul Cercueil <paul@crapouillou.net>  
> > 
> > Reviewed-by: Nuno Sa <nuno.sa@analog.com>
> >   
> 
> I guess this should have a Fixes: tag...

So, I did a bit of detective work on this one.  Seems this change in error
code was actually introduced as a side effect of Alex's recent rework of
the IOCTLs.  Prior to that we returned -ENODEV for this case and now
we do indeed return EINVAL.   

So we may need to figure out how to fix that, or decide that such is life
and modify this code to give the right error message as done in this patch...

Linus / Alex, thoughts?  It's always been a bit messy because we also
return -ENODEV in the path where the ioctl hits a driver that is going away
so it hasn't uniquely identified a lack of support for a long time, even
if that is by far the most likely reason for this return code.

Jonathan


> 
> - Nuno Sá


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

* Re: [PATCH] tools/iio: iio_event_monitor: Fix ioctl error check
  2021-05-03 11:06     ` Jonathan Cameron
@ 2021-05-03 11:07       ` Jonathan Cameron
  2021-05-03 13:56       ` Linus Walleij
  1 sibling, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2021-05-03 11:07 UTC (permalink / raw)
  To: Sa, Nuno
  Cc: Paul Cercueil, Lars-Peter Clausen, Peter Meerwald-Stadler,
	linux-iio, linux-kernel, Linus Walleij, Alexandru Ardelean

+CC Alexandru Ardelean


On Mon, 3 May 2021 12:06:15 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> On Wed, 28 Apr 2021 15:33:21 +0000
> "Sa, Nuno" <Nuno.Sa@analog.com> wrote:
> 
> > > From: Sa, Nuno <Nuno.Sa@analog.com>
> > > Sent: Wednesday, April 28, 2021 5:31 PM
> > > To: Paul Cercueil <paul@crapouillou.net>; Jonathan Cameron
> > > <jic23@kernel.org>; Lars-Peter Clausen <lars@metafoo.de>; Peter
> > > Meerwald-Stadler <pmeerw@pmeerw.net>
> > > Cc: linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org
> > > Subject: RE: [PATCH] tools/iio: iio_event_monitor: Fix ioctl error check
> > > 
> > >     
> > > > From: Paul Cercueil <paul@crapouillou.net>
> > > > Sent: Wednesday, April 28, 2021 5:08 PM
> > > > To: Jonathan Cameron <jic23@kernel.org>; Lars-Peter Clausen
> > > > <lars@metafoo.de>; Peter Meerwald-Stadler
> > > > <pmeerw@pmeerw.net>
> > > > Cc: linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org; Paul
> > > > Cercueil <paul@crapouillou.net>
> > > > Subject: [PATCH] tools/iio: iio_event_monitor: Fix ioctl error check
> > > >
> > > >
> > > > The ioctrl() call will return errno=EINVAL if the device does not
> > > > support the events interface, and not ENODEV.
> > > >
> > > > Signed-off-by: Paul Cercueil <paul@crapouillou.net>    
> > > 
> > > Reviewed-by: Nuno Sa <nuno.sa@analog.com>
> > >     
> > 
> > I guess this should have a Fixes: tag...  
> 
> So, I did a bit of detective work on this one.  Seems this change in error
> code was actually introduced as a side effect of Alex's recent rework of
> the IOCTLs.  Prior to that we returned -ENODEV for this case and now
> we do indeed return EINVAL.   
> 
> So we may need to figure out how to fix that, or decide that such is life
> and modify this code to give the right error message as done in this patch...
> 
> Linus / Alex, thoughts?  It's always been a bit messy because we also
> return -ENODEV in the path where the ioctl hits a driver that is going away
> so it hasn't uniquely identified a lack of support for a long time, even
> if that is by far the most likely reason for this return code.
> 
> Jonathan
> 
> 
> > 
> > - Nuno Sá  
> 


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

* Re: [PATCH] tools/iio: iio_event_monitor: Fix ioctl error check
  2021-05-03 11:06     ` Jonathan Cameron
  2021-05-03 11:07       ` Jonathan Cameron
@ 2021-05-03 13:56       ` Linus Walleij
  2021-05-03 14:35         ` Alexandru Ardelean
  1 sibling, 1 reply; 7+ messages in thread
From: Linus Walleij @ 2021-05-03 13:56 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Sa, Nuno, Paul Cercueil, Lars-Peter Clausen,
	Peter Meerwald-Stadler, linux-iio, linux-kernel

On Mon, May 3, 2021 at 1:05 PM Jonathan Cameron <jic23@kernel.org> wrote:

> So, I did a bit of detective work on this one.  Seems this change in error
> code was actually introduced as a side effect of Alex's recent rework of
> the IOCTLs.  Prior to that we returned -ENODEV for this case and now
> we do indeed return EINVAL.
>
> So we may need to figure out how to fix that, or decide that such is life
> and modify this code to give the right error message as done in this patch...
>
> Linus / Alex, thoughts?  It's always been a bit messy because we also
> return -ENODEV in the path where the ioctl hits a driver that is going away
> so it hasn't uniquely identified a lack of support for a long time, even
> if that is by far the most likely reason for this return code.

Normally this would be ABI if any existing userspace can break because
of the wrong error code being returned. Linus (the other one) has
clearly stated that the ABI is a contract that cannot be broken.

So I would just try to fix the errorpath to go back to returning -ENODEV.

Yours,
Linus Walleij

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

* Re: [PATCH] tools/iio: iio_event_monitor: Fix ioctl error check
  2021-05-03 13:56       ` Linus Walleij
@ 2021-05-03 14:35         ` Alexandru Ardelean
  0 siblings, 0 replies; 7+ messages in thread
From: Alexandru Ardelean @ 2021-05-03 14:35 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Jonathan Cameron, Sa, Nuno, Paul Cercueil, Lars-Peter Clausen,
	Peter Meerwald-Stadler, linux-iio, linux-kernel

On Mon, May 3, 2021 at 5:31 PM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> On Mon, May 3, 2021 at 1:05 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> > So, I did a bit of detective work on this one.  Seems this change in error
> > code was actually introduced as a side effect of Alex's recent rework of
> > the IOCTLs.  Prior to that we returned -ENODEV for this case and now
> > we do indeed return EINVAL.
> >
> > So we may need to figure out how to fix that, or decide that such is life
> > and modify this code to give the right error message as done in this patch...
> >
> > Linus / Alex, thoughts?  It's always been a bit messy because we also
> > return -ENODEV in the path where the ioctl hits a driver that is going away
> > so it hasn't uniquely identified a lack of support for a long time, even
> > if that is by far the most likely reason for this return code.
>
> Normally this would be ABI if any existing userspace can break because
> of the wrong error code being returned. Linus (the other one) has
> clearly stated that the ABI is a contract that cannot be broken.
>
> So I would just try to fix the errorpath to go back to returning -ENODEV.

Same from my side.
I was just looking through the code now.

Will send a patch.
Sorry for the breakage.

>
> Yours,
> Linus Walleij

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

end of thread, other threads:[~2021-05-03 14:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-28 15:08 [PATCH] tools/iio: iio_event_monitor: Fix ioctl error check Paul Cercueil
2021-04-28 15:30 ` Sa, Nuno
2021-04-28 15:33   ` Sa, Nuno
2021-05-03 11:06     ` Jonathan Cameron
2021-05-03 11:07       ` Jonathan Cameron
2021-05-03 13:56       ` Linus Walleij
2021-05-03 14:35         ` Alexandru Ardelean

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).