From patchwork Tue Dec 22 16:43:11 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 2350 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Tue, 22 Dec 2009 16:43:53 +0000 Received: from bombadil.infradead.org [18.85.46.34] by gaivota.chehab.org with IMAP (fetchmail-6.3.11) for (single-drop); Tue, 22 Dec 2009 14:48:04 -0200 (BRST) Received: from vger.kernel.org ([209.132.180.67]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NN7px-0004Qc-8G; Tue, 22 Dec 2009 16:43:53 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754007AbZLVQnf (ORCPT + 1 other); Tue, 22 Dec 2009 11:43:35 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753985AbZLVQne (ORCPT ); Tue, 22 Dec 2009 11:43:34 -0500 Received: from smtp.nokia.com ([192.100.122.233]:49195 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751037AbZLVQnb (ORCPT ); Tue, 22 Dec 2009 11:43:31 -0500 Received: from vaebh105.NOE.Nokia.com (vaebh105.europe.nokia.com [10.160.244.31]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nBMGhJfF006135; Tue, 22 Dec 2009 18:43:28 +0200 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by vaebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 22 Dec 2009 18:43:15 +0200 Received: from mgw-da01.ext.nokia.com ([147.243.128.24]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Tue, 22 Dec 2009 18:43:15 +0200 Received: from maxwell.research.nokia.com (maxwell.research.nokia.com [172.21.50.162]) by mgw-da01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nBMGhCiX002134; Tue, 22 Dec 2009 18:43:13 +0200 Received: from lanttu (lanttu.localdomain [192.168.239.4]) by maxwell.research.nokia.com (Postfix) with ESMTPS id 6B8167010C; Tue, 22 Dec 2009 18:43:12 +0200 (EET) Received: from sakke by lanttu with local (Exim 4.69) (envelope-from ) id 1NN7pI-0002T2-4l; Tue, 22 Dec 2009 18:43:12 +0200 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, iivanov@mm-sol.com, hverkuil@xs4all.nl, gururaj.nagendra@intel.com Subject: [RFC v2 7/7] V4L: Events: Support all events Date: Tue, 22 Dec 2009 18:43:11 +0200 Message-Id: <1261500191-9441-7-git-send-email-sakari.ailus@maxwell.research.nokia.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1261500191-9441-6-git-send-email-sakari.ailus@maxwell.research.nokia.com> References: <4B30F713.8070004@maxwell.research.nokia.com> <1261500191-9441-1-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1261500191-9441-2-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1261500191-9441-3-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1261500191-9441-4-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1261500191-9441-5-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1261500191-9441-6-git-send-email-sakari.ailus@maxwell.research.nokia.com> X-OriginalArrivalTime: 22 Dec 2009 16:43:16.0221 (UTC) FILETIME=[DC0AE2D0:01CA8325] X-Nokia-AV: Clean Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add support for subscribing V4L2_EVENT_ALL. After V4L2_EVENT_ALL is subscribed, unsubscribing any event leads to unsubscription of all events. Signed-off-by: Sakari Ailus --- drivers/media/video/v4l2-event.c | 34 ++++++++++++++++++++++++---------- 1 files changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/media/video/v4l2-event.c b/drivers/media/video/v4l2-event.c index cc2bf57..95b3917 100644 --- a/drivers/media/video/v4l2-event.c +++ b/drivers/media/video/v4l2-event.c @@ -62,6 +62,22 @@ void v4l2_event_init_fh(struct v4l2_fh *fh) } EXPORT_SYMBOL_GPL(v4l2_event_init_fh); +static void __v4l2_event_unsubscribe_all(struct v4l2_fh *fh) +{ + struct v4l2_events *events = &fh->events; + + while (!list_empty(&events->subscribed)) { + struct v4l2_subscribed_event *sub; + + sub = list_entry(events->subscribed.next, + struct v4l2_subscribed_event, list); + + list_del(&sub->list); + + kfree(sub); + } +} + void v4l2_event_exit_fh(struct v4l2_fh *fh) { struct v4l2_events *events = &fh->events; @@ -77,16 +93,7 @@ void v4l2_event_exit_fh(struct v4l2_fh *fh) kmem_cache_free(event_kmem, ev); } - while (!list_empty(&events->subscribed)) { - struct v4l2_subscribed_event *sub; - - sub = list_entry(events->subscribed.next, - struct v4l2_subscribed_event, list); - - list_del(&sub->list); - - kfree(sub); - } + __v4l2_event_unsubscribe_all(fh); } EXPORT_SYMBOL_GPL(v4l2_event_exit_fh); @@ -125,6 +132,11 @@ static struct v4l2_subscribed_event *__v4l2_event_subscribed( struct v4l2_events *events = &fh->events; struct v4l2_subscribed_event *ev; + ev = container_of(events->subscribed.next, + struct v4l2_subscribed_event, list); + if (ev->type == V4L2_EVENT_ALL) + return ev; + list_for_each_entry(ev, &events->subscribed, list) { if (ev->type == type) return ev; @@ -237,6 +249,8 @@ int v4l2_event_subscribe(struct v4l2_fh *fh, INIT_LIST_HEAD(&ev->list); ev->type = sub->type; + if (ev->type == V4L2_EVENT_ALL) + __v4l2_event_unsubscribe_all(fh); list_add(&ev->list, &events->subscribed); out: