On Tuesday 06 April 2010 00:58:54 Hans Verkuil wrote: > On Tuesday 06 April 2010 00:46:11 Laurent Pinchart wrote: > > On Sunday 04 April 2010 05:14:17 David Ellingsworth wrote: > > > After looking at the proposed solution, I personally find the > > > suggestion for a serialization flag to be quite ridiculous. As others > > > have mentioned, the mere presence of the flag means that driver > > > writers will gloss over any concurrency issues that might exist in > > > their driver on the mere assumption that specifying the serialization > > > flag will handle it all for them. > > > > I happen to agree with this. Proper locking is difficult, but that's not a > > reason to introduce such a workaround. I'd much rather see proper > > documentation for driver developers on how to implement locking properly. > > I've taken a different approach in another tree: > > http://linuxtv.org/hg/~hverkuil/v4l-dvb-ser2/ > > It adds two callbacks to ioctl_ops: pre_hook and post_hook. You can use these > to do things like prio checking and taking your own mutex to serialize the > ioctl call. > > This might be a good compromise between convenience and not hiding anything. I realized that something like this is needed anyway if we go ahead with the new control framework. That exposes controls in sysfs, but if you set a control from sysfs, then that bypasses the ioctl completely. So you need a way to hook into whatever serialization scheme you have (if any). It is trivial to get to the video_device struct in the control handler and from there you can access ioctl_ops. So calling the pre/post hooks for the sysfs actions is very simple. The prototype for the hooks needs to change, though, since accesses from sysfs do not provide you with a struct file pointer. Something like this should work: int pre_hook(struct video_device *vdev, enum v4l2_priority prio, int cmd); void post_hook(struct video_device *vdev, int cmd); The prio is there to make priority checking possible. It will be initially unused, but as soon as the events API with the new v4l2_fh struct is merged we can add centralized support for this. Regards, Hans > > Regards, > > Hans > > > -- Hans Verkuil - video4linux developer - sponsored by TANDBERG -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html