From patchwork Wed Oct 2 13:45:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 2974871 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9B45DBFF0B for ; Wed, 2 Oct 2013 13:45:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0993A203D9 for ; Wed, 2 Oct 2013 13:45:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 259D9203FD for ; Wed, 2 Oct 2013 13:45:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754450Ab3JBNow (ORCPT ); Wed, 2 Oct 2013 09:44:52 -0400 Received: from mga14.intel.com ([143.182.124.37]:35675 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754417Ab3JBNot (ORCPT ); Wed, 2 Oct 2013 09:44:49 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 02 Oct 2013 06:44:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.90,1019,1371106800"; d="scan'208";a="368742191" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by azsmga001.ch.intel.com with ESMTP; 02 Oct 2013 06:44:46 -0700 Received: from nauris.fi.intel.com (nauris.localdomain [192.168.240.2]) by paasikivi.fi.intel.com (Postfix) with ESMTP id 74B67205FA; Wed, 2 Oct 2013 16:44:45 +0300 (EEST) Received: by nauris.fi.intel.com (Postfix, from userid 1000) id CC94B2020A; Wed, 2 Oct 2013 16:45:35 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, teemux.tuominen@intel.com Subject: [RFC v2 4/4] v4l: events: Don't sleep in dequeue if none are subscribed Date: Wed, 2 Oct 2013 16:45:16 +0300 Message-Id: <1380721516-488-5-git-send-email-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1380721516-488-1-git-send-email-sakari.ailus@linux.intel.com> References: <1380721516-488-1-git-send-email-sakari.ailus@linux.intel.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Dequeueing events was is entirely possible even if none are subscribed, leading to sleeping indefinitely. Fix this by returning -ENOENT when no events are subscribed. Signed-off-by: Sakari Ailus --- drivers/media/v4l2-core/v4l2-event.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-event.c b/drivers/media/v4l2-core/v4l2-event.c index b53897e..553a800 100644 --- a/drivers/media/v4l2-core/v4l2-event.c +++ b/drivers/media/v4l2-core/v4l2-event.c @@ -77,10 +77,17 @@ int v4l2_event_dequeue(struct v4l2_fh *fh, struct v4l2_event *event, mutex_unlock(fh->vdev->lock); do { - ret = wait_event_interruptible(fh->wait, - fh->navailable != 0); + bool subscribed; + ret = wait_event_interruptible( + fh->wait, + fh->navailable != 0 || + !(subscribed = v4l2_event_has_subscribed(fh))); if (ret < 0) break; + if (!subscribed) { + ret = -EIO; + break; + } ret = __v4l2_event_dequeue(fh, event); } while (ret == -ENOENT);