@@ -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: