linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: core: return -EINVAL when no ioctl handler has been run
@ 2020-11-17  9:51 Alexandru Ardelean
  2020-11-21 16:49 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Alexandru Ardelean @ 2020-11-17  9:51 UTC (permalink / raw)
  To: linux-iio, linux-kernel; +Cc: jic23, Alexandru Ardelean

It seems that when this was tested the happy case was more tested. A few of
the userspace apps rely on this returning negative error codes in case an
ioctl() is not available.

When running multiple ioctl() handlers or when calling an ioctl() that
doesn't exist, IIO_IOCTL_UNHANDLED is returned. In that case -EINVAL should
be returned.

Fixes: 8dedcc3eee3a ("iio: core: centralize ioctl() calls to the main chardev")
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---

Apologies for not noticing this earlier.
This came up when trying to write more IIO buffer code.

From my side either is fine: whether it be applied as a fix or whether
it's squashed into the original patch.

 drivers/iio/industrialio-core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index e53c771d66eb..419d6f8acc13 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1743,6 +1743,9 @@ static long iio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 			break;
 	}
 
+	if (ret == IIO_IOCTL_UNHANDLED)
+		ret = -EINVAL;
+
 out_unlock:
 	mutex_unlock(&indio_dev->info_exist_lock);
 
-- 
2.17.1


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

* Re: [PATCH] iio: core: return -EINVAL when no ioctl handler has been run
  2020-11-17  9:51 [PATCH] iio: core: return -EINVAL when no ioctl handler has been run Alexandru Ardelean
@ 2020-11-21 16:49 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2020-11-21 16:49 UTC (permalink / raw)
  To: Alexandru Ardelean; +Cc: linux-iio, linux-kernel

On Tue, 17 Nov 2020 11:51:54 +0200
Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:

> It seems that when this was tested the happy case was more tested. A few of
> the userspace apps rely on this returning negative error codes in case an
> ioctl() is not available.
> 
> When running multiple ioctl() handlers or when calling an ioctl() that
> doesn't exist, IIO_IOCTL_UNHANDLED is returned. In that case -EINVAL should
> be returned.
> 
> Fixes: 8dedcc3eee3a ("iio: core: centralize ioctl() calls to the main chardev")
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Applied.

Thanks,

Jonathan

> ---
> 
> Apologies for not noticing this earlier.
> This came up when trying to write more IIO buffer code.
> 
> From my side either is fine: whether it be applied as a fix or whether
> it's squashed into the original patch.
> 
>  drivers/iio/industrialio-core.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index e53c771d66eb..419d6f8acc13 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -1743,6 +1743,9 @@ static long iio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>  			break;
>  	}
>  
> +	if (ret == IIO_IOCTL_UNHANDLED)
> +		ret = -EINVAL;
> +
>  out_unlock:
>  	mutex_unlock(&indio_dev->info_exist_lock);
>  


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

end of thread, other threads:[~2020-11-21 16:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-17  9:51 [PATCH] iio: core: return -EINVAL when no ioctl handler has been run Alexandru Ardelean
2020-11-21 16:49 ` Jonathan Cameron

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).