linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: percolate error if event fd fails
@ 2015-08-11  9:56 Linus Walleij
  2015-08-11 10:52 ` Daniel Baluta
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2015-08-11  9:56 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio; +Cc: Linus Walleij

This makes the error from iio_event_getfd() percolate up
to userspace properly so we can know for sure there is no
events on this device (-ENODEV returned). Before this patch
we would bail out looking for the unsupported evens on the
erroneous (negative) file descriptor.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/iio/industrialio-core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 3524b0de8721..9492aa443a26 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1130,6 +1130,8 @@ static long iio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 
 	if (cmd == IIO_GET_EVENT_FD_IOCTL) {
 		fd = iio_event_getfd(indio_dev);
+		if (fd < 0)
+			return fd;
 		if (copy_to_user(ip, &fd, sizeof(fd)))
 			return -EFAULT;
 		return 0;
-- 
2.4.3


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

end of thread, other threads:[~2015-08-17  8:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-11  9:56 [PATCH] iio: percolate error if event fd fails Linus Walleij
2015-08-11 10:52 ` Daniel Baluta
2015-08-15 15:22   ` Jonathan Cameron
2015-08-17  8:22     ` Linus Walleij

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