From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from saturn.retrosnub.co.uk ([178.18.118.26]:47703 "EHLO saturn.retrosnub.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751542AbbHOPWm (ORCPT ); Sat, 15 Aug 2015 11:22:42 -0400 Subject: Re: [PATCH] iio: percolate error if event fd fails To: Daniel Baluta , Linus Walleij References: <1439287000-31506-1-git-send-email-linus.walleij@linaro.org> Cc: "linux-iio@vger.kernel.org" From: Jonathan Cameron Message-ID: <55CF5940.9000607@kernel.org> Date: Sat, 15 Aug 2015 16:22:40 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Sender: linux-iio-owner@vger.kernel.org List-Id: linux-iio@vger.kernel.org On 11/08/15 11:52, Daniel Baluta wrote: > On Tue, Aug 11, 2015 at 12:56 PM, Linus Walleij > wrote: >> 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. > > Good catch. s/evens/events > >> >> Signed-off-by: Linus Walleij > > Acked-by: Daniel Baluta Applied to the togreg branch of iio.git. Initially pushed out as testing. I'm not sending this as a fix as the error that resulted was downright missleading, but unlikely to have caused any nasty crashes or similar. If you think if should be going in faster/ for stable then let me know. Jonathan > >> --- >> 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 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-iio" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > -- > To unsubscribe from this list: send the line "unsubscribe linux-iio" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >