v4l2-event: Add v4l2_subscribed_event_ops
Hi,
Quoted 19 lines · hverkuil
Quoted 7 lines
Review
Quoted 7 lines
(quoted diff) +7
-0+ if (sev->ops && sev->ops->add) { + int ret = sev->ops->add(sev); + if (ret) { + sev->ops = NULL; + v4l2_event_unsubscribe(fh, sub); + return ret; + }The problem here is that the event is basically available for use after the
spin_unlock_irqrestore(), but before thesev->ops->add()call. In the past I just 'knew' that the event would never be generated by the control framework until afterv4l2_ctrl_add_eventwas called, but this should be formalized now that these ops are added.I see two options:
1) Have some method to mark the sev as being 'invalid' so functions sending events can skip it (needed as well for your patch 4/6).
Quoted 8 lines
2) Document that drivers should never be able to send an event until after the
add()callback has succeeded.I am leaning towards option 1 myself.
How about leaving
sev->elemsat 0 until after theadd()op succeeds?That's easy to test against and easy to implement.
I agree that option 1 is the best and that leaving sev->elems 0 is a good way to do this. This will be in my next revision of this patch set.
Thanks & Regards,
Hans