From: Hans Verkuil Date: Sun, 26 Sep 2010 11:16:56 +0000 (-0300) Subject: V4L/DVB: v4l2-dev: after a disconnect any ioctl call will be blocked X-Git-Tag: v2.6.37-rc1~64^2~347 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-kernel.git;a=commitdiff_plain;h=d69f27186c16008540166c8017e9d4db2b477588 V4L/DVB: v4l2-dev: after a disconnect any ioctl call will be blocked Until now all fops except release and (unlocked_)ioctl returned an error after the device node was unregistered. Extend this as well to the ioctl fops. There is nothing useful that an application can do here and it complicates the driver code unnecessarily. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt index 8fb9de4f4875..9b1d81c26b7d 100644 --- a/Documentation/video4linux/v4l2-framework.txt +++ b/Documentation/video4linux/v4l2-framework.txt @@ -551,9 +551,8 @@ from /dev). After video_unregister_device() returns no new opens can be done. However, in the case of USB devices some application might still have one of these -device nodes open. So after the unregister all file operations will return -an error as well, except for the ioctl and unlocked_ioctl file operations: -those will still be passed on since some buffer ioctls may still be needed. +device nodes open. So after the unregister all file operations (except +release, of course) will return an error as well. When the last user of the video device node exits, then the vdev->release() callback is called and you can do the final cleanup there. diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index d4a353260c1e..f069c61cdf68 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c @@ -221,8 +221,8 @@ static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) struct video_device *vdev = video_devdata(filp); int ret; - /* Allow ioctl to continue even if the device was unregistered. - Things like dequeueing buffers might still be useful. */ + if (!vdev->fops->ioctl) + return -ENOTTY; if (vdev->fops->unlocked_ioctl) { ret = vdev->fops->unlocked_ioctl(filp, cmd, arg); } else if (vdev->fops->ioctl) {