aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-05-10 03:57:22 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-05-14 08:19:38 -0400
commit5126f2590bee412e3053de851cb07f531e4be36a (patch)
tree6afbccb73c4eea0ee4dd660537fff2c51322157a /drivers
parent4b902fec7cd838d2376517455acb03a83898e262 (diff)
[media] v4l2-dev: add flag to have the core lock all file operations
This used to be the default if the lock pointer was set, but now that lock is by default only used for ioctl serialization. Those drivers that already used core locking have this flag set explicitly, except for some drivers where it was obvious that there was no need to serialize any file operations other than ioctl. The drivers that didn't need this flag were: drivers/media/radio/dsbr100.c drivers/media/radio/radio-isa.c drivers/media/radio/radio-keene.c drivers/media/radio/radio-miropcm20.c drivers/media/radio/radio-mr800.c drivers/media/radio/radio-tea5764.c drivers/media/radio/radio-timb.c drivers/media/video/vivi.c sound/i2c/other/tea575x-tuner.c The other drivers that use core locking and where it was not immediately obvious that this flag wasn't needed were changed so that the flag is set together with a comment that that driver needs work to avoid having to set that flag. This will often involve taking the core lock in the fops themselves. Eventually this flag should go and it should not be used in new drivers. There are a few reasons why we want to avoid core locking of non-ioctl fops: in the case of mmap this can lead to a deadlock in rare situations since when mmap is called the mmap_sem is held and it is possible for other parts of the code to take that lock as well (copy_from_user()/copy_to_user() perform a down_read(&mm->mmap_sem) when a page fault occurs). It is very unlikely that that happens since the core lock serializes all fops, but the kernel warns about it if lock validation is turned on. For poll it is also undesirable to take the core lock as that can introduce increased latency. The same is true for read/write. While it was possible to make flags or something to turn on/off taking the core lock for each file operation, in practice it is much simpler to just not take it at all except for ioctl and leave it to the driver to take the lock. There are only a handful fops compared to the zillion ioctls we have. I also wanted to make it obvious which drivers still take the lock for all fops, so that's why I chose to have drivers set it explicitly. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/common/saa7146_fops.c4
-rw-r--r--drivers/media/radio/wl128x/fmdrv_v4l2.c4
-rw-r--r--drivers/media/video/blackfin/bfin_capture.c4
-rw-r--r--drivers/media/video/cpia2/cpia2_v4l.c4
-rw-r--r--drivers/media/video/cx231xx/cx231xx-video.c4
-rw-r--r--drivers/media/video/davinci/vpbe_display.c4
-rw-r--r--drivers/media/video/davinci/vpif_capture.c4
-rw-r--r--drivers/media/video/davinci/vpif_display.c4
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c4
-rw-r--r--drivers/media/video/fsl-viu.c4
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.c4
-rw-r--r--drivers/media/video/mem2mem_testdev.c4
-rw-r--r--drivers/media/video/mx2_emmaprp.c4
-rw-r--r--drivers/media/video/s2255drv.c4
-rw-r--r--drivers/media/video/s5p-fimc/fimc-capture.c4
-rw-r--r--drivers/media/video/s5p-fimc/fimc-core.c4
-rw-r--r--drivers/media/video/s5p-g2d/g2d.c4
-rw-r--r--drivers/media/video/s5p-jpeg/jpeg-core.c8
-rw-r--r--drivers/media/video/s5p-mfc/s5p_mfc.c6
-rw-r--r--drivers/media/video/s5p-tv/mixer_video.c4
-rw-r--r--drivers/media/video/sh_vou.c4
-rw-r--r--drivers/media/video/soc_camera.c4
-rw-r--r--drivers/media/video/tm6000/tm6000-video.c4
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c4
-rw-r--r--drivers/media/video/v4l2-dev.c32
-rw-r--r--drivers/staging/media/dt3155v4l/dt3155v4l.c4
26 files changed, 126 insertions, 12 deletions
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index 71f8e018e564..8d7df1a0bcd0 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -511,6 +511,10 @@ int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev,
511 vfd->fops = &video_fops; 511 vfd->fops = &video_fops;
512 vfd->ioctl_ops = &dev->ext_vv_data->ops; 512 vfd->ioctl_ops = &dev->ext_vv_data->ops;
513 vfd->release = video_device_release; 513 vfd->release = video_device_release;
514 /* Locking in file operations other than ioctl should be done by
515 the driver, not the V4L2 core.
516 This driver needs auditing so that this flag can be removed. */
517 set_bit(V4L2_FL_LOCK_ALL_FOPS, &vfd->flags);
514 vfd->lock = &dev->v4l2_lock; 518 vfd->lock = &dev->v4l2_lock;
515 vfd->tvnorms = 0; 519 vfd->tvnorms = 0;
516 for (i = 0; i < dev->ext_vv_data->num_stds; i++) 520 for (i = 0; i < dev->ext_vv_data->num_stds; i++)
diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c b/drivers/media/radio/wl128x/fmdrv_v4l2.c
index 077d369a0173..080b96a61f1a 100644
--- a/drivers/media/radio/wl128x/fmdrv_v4l2.c
+++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c
@@ -518,6 +518,10 @@ int fm_v4l2_init_video_device(struct fmdev *fmdev, int radio_nr)
518 video_set_drvdata(gradio_dev, fmdev); 518 video_set_drvdata(gradio_dev, fmdev);
519 519
520 gradio_dev->lock = &fmdev->mutex; 520 gradio_dev->lock = &fmdev->mutex;
521 /* Locking in file operations other than ioctl should be done
522 by the driver, not the V4L2 core.
523 This driver needs auditing so that this flag can be removed. */
524 set_bit(V4L2_FL_LOCK_ALL_FOPS, &gradio_dev->flags);
521 525
522 /* Register with V4L2 subsystem as RADIO device */ 526 /* Register with V4L2 subsystem as RADIO device */
523 if (video_register_device(gradio_dev, VFL_TYPE_RADIO, radio_nr)) { 527 if (video_register_device(gradio_dev, VFL_TYPE_RADIO, radio_nr)) {
diff --git a/drivers/media/video/blackfin/bfin_capture.c b/drivers/media/video/blackfin/bfin_capture.c
index 514fcf742f5a..0aba45e34f70 100644
--- a/drivers/media/video/blackfin/bfin_capture.c
+++ b/drivers/media/video/blackfin/bfin_capture.c
@@ -942,6 +942,10 @@ static int __devinit bcap_probe(struct platform_device *pdev)
942 INIT_LIST_HEAD(&bcap_dev->dma_queue); 942 INIT_LIST_HEAD(&bcap_dev->dma_queue);
943 943
944 vfd->lock = &bcap_dev->mutex; 944 vfd->lock = &bcap_dev->mutex;
945 /* Locking in file operations other than ioctl should be done
946 by the driver, not the V4L2 core.
947 This driver needs auditing so that this flag can be removed. */
948 set_bit(V4L2_FL_LOCK_ALL_FOPS, &vfd->flags);
945 949
946 /* register video device */ 950 /* register video device */
947 ret = video_register_device(bcap_dev->video_dev, VFL_TYPE_GRABBER, -1); 951 ret = video_register_device(bcap_dev->video_dev, VFL_TYPE_GRABBER, -1);
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c
index bb4f1d0de829..55e92902a76c 100644
--- a/drivers/media/video/cpia2/cpia2_v4l.c
+++ b/drivers/media/video/cpia2/cpia2_v4l.c
@@ -1147,6 +1147,10 @@ int cpia2_register_camera(struct camera_data *cam)
1147 cam->vdev.ctrl_handler = hdl; 1147 cam->vdev.ctrl_handler = hdl;
1148 cam->vdev.v4l2_dev = &cam->v4l2_dev; 1148 cam->vdev.v4l2_dev = &cam->v4l2_dev;
1149 set_bit(V4L2_FL_USE_FH_PRIO, &cam->vdev.flags); 1149 set_bit(V4L2_FL_USE_FH_PRIO, &cam->vdev.flags);
1150 /* Locking in file operations other than ioctl should be done
1151 by the driver, not the V4L2 core.
1152 This driver needs auditing so that this flag can be removed. */
1153 set_bit(V4L2_FL_LOCK_ALL_FOPS, &cam->vdev.flags);
1150 1154
1151 reset_camera_struct_v4l(cam); 1155 reset_camera_struct_v4l(cam);
1152 1156
diff --git a/drivers/media/video/cx231xx/cx231xx-video.c b/drivers/media/video/cx231xx/cx231xx-video.c
index 7f916f0685e9..2a04558699f8 100644
--- a/drivers/media/video/cx231xx/cx231xx-video.c
+++ b/drivers/media/video/cx231xx/cx231xx-video.c
@@ -2561,6 +2561,10 @@ static struct video_device *cx231xx_vdev_init(struct cx231xx *dev,
2561 vfd->release = video_device_release; 2561 vfd->release = video_device_release;
2562 vfd->debug = video_debug; 2562 vfd->debug = video_debug;
2563 vfd->lock = &dev->lock; 2563 vfd->lock = &dev->lock;
2564 /* Locking in file operations other than ioctl should be done
2565 by the driver, not the V4L2 core.
2566 This driver needs auditing so that this flag can be removed. */
2567 set_bit(V4L2_FL_LOCK_ALL_FOPS, &vfd->flags);
2564 2568
2565 snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name); 2569 snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name);
2566 2570
diff --git a/drivers/media/video/davinci/vpbe_display.c b/drivers/media/video/davinci/vpbe_display.c
index 1f3b1c729252..e106b72810a9 100644
--- a/drivers/media/video/davinci/vpbe_display.c
+++ b/drivers/media/video/davinci/vpbe_display.c
@@ -1618,6 +1618,10 @@ static __devinit int init_vpbe_layer(int i, struct vpbe_display *disp_dev,
1618 vbd->ioctl_ops = &vpbe_ioctl_ops; 1618 vbd->ioctl_ops = &vpbe_ioctl_ops;
1619 vbd->minor = -1; 1619 vbd->minor = -1;
1620 vbd->v4l2_dev = &disp_dev->vpbe_dev->v4l2_dev; 1620 vbd->v4l2_dev = &disp_dev->vpbe_dev->v4l2_dev;
1621 /* Locking in file operations other than ioctl should be done
1622 by the driver, not the V4L2 core.
1623 This driver needs auditing so that this flag can be removed. */
1624 set_bit(V4L2_FL_LOCK_ALL_FOPS, &vbd->flags);
1621 vbd->lock = &vpbe_display_layer->opslock; 1625 vbd->lock = &vpbe_display_layer->opslock;
1622 1626
1623 if (disp_dev->vpbe_dev->current_timings.timings_type & 1627 if (disp_dev->vpbe_dev->current_timings.timings_type &
diff --git a/drivers/media/video/davinci/vpif_capture.c b/drivers/media/video/davinci/vpif_capture.c
index 6504e40a31dd..96046957bf21 100644
--- a/drivers/media/video/davinci/vpif_capture.c
+++ b/drivers/media/video/davinci/vpif_capture.c
@@ -2228,6 +2228,10 @@ static __init int vpif_probe(struct platform_device *pdev)
2228 common = &(ch->common[VPIF_VIDEO_INDEX]); 2228 common = &(ch->common[VPIF_VIDEO_INDEX]);
2229 spin_lock_init(&common->irqlock); 2229 spin_lock_init(&common->irqlock);
2230 mutex_init(&common->lock); 2230 mutex_init(&common->lock);
2231 /* Locking in file operations other than ioctl should be done
2232 by the driver, not the V4L2 core.
2233 This driver needs auditing so that this flag can be removed. */
2234 set_bit(V4L2_FL_LOCK_ALL_FOPS, &ch->video_dev->flags);
2231 ch->video_dev->lock = &common->lock; 2235 ch->video_dev->lock = &common->lock;
2232 /* Initialize prio member of channel object */ 2236 /* Initialize prio member of channel object */
2233 v4l2_prio_init(&ch->prio); 2237 v4l2_prio_init(&ch->prio);
diff --git a/drivers/media/video/davinci/vpif_display.c b/drivers/media/video/davinci/vpif_display.c
index 7fa34b4fae26..e6488ee7db18 100644
--- a/drivers/media/video/davinci/vpif_display.c
+++ b/drivers/media/video/davinci/vpif_display.c
@@ -1778,6 +1778,10 @@ static __init int vpif_probe(struct platform_device *pdev)
1778 v4l2_prio_init(&ch->prio); 1778 v4l2_prio_init(&ch->prio);
1779 ch->common[VPIF_VIDEO_INDEX].fmt.type = 1779 ch->common[VPIF_VIDEO_INDEX].fmt.type =
1780 V4L2_BUF_TYPE_VIDEO_OUTPUT; 1780 V4L2_BUF_TYPE_VIDEO_OUTPUT;
1781 /* Locking in file operations other than ioctl should be done
1782 by the driver, not the V4L2 core.
1783 This driver needs auditing so that this flag can be removed. */
1784 set_bit(V4L2_FL_LOCK_ALL_FOPS, &ch->video_dev->flags);
1781 ch->video_dev->lock = &common->lock; 1785 ch->video_dev->lock = &common->lock;
1782 1786
1783 /* register video device */ 1787 /* register video device */
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index bcc41603c193..308a1dd08cfb 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -2495,6 +2495,10 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev,
2495 vfd->release = video_device_release; 2495 vfd->release = video_device_release;
2496 vfd->debug = video_debug; 2496 vfd->debug = video_debug;
2497 vfd->lock = &dev->lock; 2497 vfd->lock = &dev->lock;
2498 /* Locking in file operations other than ioctl should be done
2499 by the driver, not the V4L2 core.
2500 This driver needs auditing so that this flag can be removed. */
2501 set_bit(V4L2_FL_LOCK_ALL_FOPS, &vfd->flags);
2498 2502
2499 snprintf(vfd->name, sizeof(vfd->name), "%s %s", 2503 snprintf(vfd->name, sizeof(vfd->name), "%s %s",
2500 dev->name, type_name); 2504 dev->name, type_name);
diff --git a/drivers/media/video/fsl-viu.c b/drivers/media/video/fsl-viu.c
index 27e3e0c0b219..777486f7cadb 100644
--- a/drivers/media/video/fsl-viu.c
+++ b/drivers/media/video/fsl-viu.c
@@ -1544,6 +1544,10 @@ static int __devinit viu_of_probe(struct platform_device *op)
1544 1544
1545 /* initialize locks */ 1545 /* initialize locks */
1546 mutex_init(&viu_dev->lock); 1546 mutex_init(&viu_dev->lock);
1547 /* Locking in file operations other than ioctl should be done
1548 by the driver, not the V4L2 core.
1549 This driver needs auditing so that this flag can be removed. */
1550 set_bit(V4L2_FL_LOCK_ALL_FOPS, &viu_dev->vdev->flags);
1547 viu_dev->vdev->lock = &viu_dev->lock; 1551 viu_dev->vdev->lock = &viu_dev->lock;
1548 spin_lock_init(&viu_dev->slock); 1552 spin_lock_init(&viu_dev->slock);
1549 1553
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c
index 7ea5ca7f012b..6738592aa35d 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -228,6 +228,10 @@ static int ivtv_prep_dev(struct ivtv *itv, int type)
228 s->vdev->release = video_device_release; 228 s->vdev->release = video_device_release;
229 s->vdev->tvnorms = V4L2_STD_ALL; 229 s->vdev->tvnorms = V4L2_STD_ALL;
230 s->vdev->lock = &itv->serialize_lock; 230 s->vdev->lock = &itv->serialize_lock;
231 /* Locking in file operations other than ioctl should be done
232 by the driver, not the V4L2 core.
233 This driver needs auditing so that this flag can be removed. */
234 set_bit(V4L2_FL_LOCK_ALL_FOPS, &s->vdev->flags);
231 set_bit(V4L2_FL_USE_FH_PRIO, &s->vdev->flags); 235 set_bit(V4L2_FL_USE_FH_PRIO, &s->vdev->flags);
232 ivtv_set_funcs(s->vdev); 236 ivtv_set_funcs(s->vdev);
233 return 0; 237 return 0;
diff --git a/drivers/media/video/mem2mem_testdev.c b/drivers/media/video/mem2mem_testdev.c
index 12897e8a3314..ee3efbd83bdb 100644
--- a/drivers/media/video/mem2mem_testdev.c
+++ b/drivers/media/video/mem2mem_testdev.c
@@ -958,6 +958,10 @@ static int m2mtest_probe(struct platform_device *pdev)
958 } 958 }
959 959
960 *vfd = m2mtest_videodev; 960 *vfd = m2mtest_videodev;
961 /* Locking in file operations other than ioctl should be done
962 by the driver, not the V4L2 core.
963 This driver needs auditing so that this flag can be removed. */
964 set_bit(V4L2_FL_LOCK_ALL_FOPS, &vfd->flags);
961 vfd->lock = &dev->dev_mutex; 965 vfd->lock = &dev->dev_mutex;
962 966
963 ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); 967 ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
diff --git a/drivers/media/video/mx2_emmaprp.c b/drivers/media/video/mx2_emmaprp.c
index 55ac1735e85b..0bd5815de369 100644
--- a/drivers/media/video/mx2_emmaprp.c
+++ b/drivers/media/video/mx2_emmaprp.c
@@ -904,6 +904,10 @@ static int emmaprp_probe(struct platform_device *pdev)
904 } 904 }
905 905
906 *vfd = emmaprp_videodev; 906 *vfd = emmaprp_videodev;
907 /* Locking in file operations other than ioctl should be done
908 by the driver, not the V4L2 core.
909 This driver needs auditing so that this flag can be removed. */
910 set_bit(V4L2_FL_LOCK_ALL_FOPS, &vfd->flags);
907 vfd->lock = &pcdev->dev_mutex; 911 vfd->lock = &pcdev->dev_mutex;
908 912
909 video_set_drvdata(vfd, pcdev); 913 video_set_drvdata(vfd, pcdev);
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index 37845def41c5..ea974fadb5e2 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -1948,6 +1948,10 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
1948 /* register 4 video devices */ 1948 /* register 4 video devices */
1949 channel->vdev = template; 1949 channel->vdev = template;
1950 channel->vdev.lock = &dev->lock; 1950 channel->vdev.lock = &dev->lock;
1951 /* Locking in file operations other than ioctl should be done
1952 by the driver, not the V4L2 core.
1953 This driver needs auditing so that this flag can be removed. */
1954 set_bit(V4L2_FL_LOCK_ALL_FOPS, &channel->vdev.flags);
1951 channel->vdev.v4l2_dev = &dev->v4l2_dev; 1955 channel->vdev.v4l2_dev = &dev->v4l2_dev;
1952 video_set_drvdata(&channel->vdev, channel); 1956 video_set_drvdata(&channel->vdev, channel);
1953 if (video_nr == -1) 1957 if (video_nr == -1)
diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c
index dc18ba510986..72d51504ed21 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -1516,6 +1516,10 @@ int fimc_register_capture_device(struct fimc_dev *fimc,
1516 vfd->minor = -1; 1516 vfd->minor = -1;
1517 vfd->release = video_device_release; 1517 vfd->release = video_device_release;
1518 vfd->lock = &fimc->lock; 1518 vfd->lock = &fimc->lock;
1519 /* Locking in file operations other than ioctl should be done
1520 by the driver, not the V4L2 core.
1521 This driver needs auditing so that this flag can be removed. */
1522 set_bit(V4L2_FL_LOCK_ALL_FOPS, &vfd->flags);
1519 video_set_drvdata(vfd, fimc); 1523 video_set_drvdata(vfd, fimc);
1520 1524
1521 vid_cap = &fimc->vid_cap; 1525 vid_cap = &fimc->vid_cap;
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c
index 7b90a897beeb..c58dd9f8ce67 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -1520,6 +1520,10 @@ int fimc_register_m2m_device(struct fimc_dev *fimc,
1520 vfd->minor = -1; 1520 vfd->minor = -1;
1521 vfd->release = video_device_release; 1521 vfd->release = video_device_release;
1522 vfd->lock = &fimc->lock; 1522 vfd->lock = &fimc->lock;
1523 /* Locking in file operations other than ioctl should be done
1524 by the driver, not the V4L2 core.
1525 This driver needs auditing so that this flag can be removed. */
1526 set_bit(V4L2_FL_LOCK_ALL_FOPS, &vfd->flags);
1523 1527
1524 snprintf(vfd->name, sizeof(vfd->name), "%s.m2m", dev_name(&pdev->dev)); 1528 snprintf(vfd->name, sizeof(vfd->name), "%s.m2m", dev_name(&pdev->dev));
1525 video_set_drvdata(vfd, fimc); 1529 video_set_drvdata(vfd, fimc);
diff --git a/drivers/media/video/s5p-g2d/g2d.c b/drivers/media/video/s5p-g2d/g2d.c
index 789de74014e5..02605cecfd65 100644
--- a/drivers/media/video/s5p-g2d/g2d.c
+++ b/drivers/media/video/s5p-g2d/g2d.c
@@ -762,6 +762,10 @@ static int g2d_probe(struct platform_device *pdev)
762 goto unreg_v4l2_dev; 762 goto unreg_v4l2_dev;
763 } 763 }
764 *vfd = g2d_videodev; 764 *vfd = g2d_videodev;
765 /* Locking in file operations other than ioctl should be done
766 by the driver, not the V4L2 core.
767 This driver needs auditing so that this flag can be removed. */
768 set_bit(V4L2_FL_LOCK_ALL_FOPS, &vfd->flags);
765 vfd->lock = &dev->mutex; 769 vfd->lock = &dev->mutex;
766 ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); 770 ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
767 if (ret) { 771 if (ret) {
diff --git a/drivers/media/video/s5p-jpeg/jpeg-core.c b/drivers/media/video/s5p-jpeg/jpeg-core.c
index 5a49c307f9c1..ecf7b0b04c78 100644
--- a/drivers/media/video/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/video/s5p-jpeg/jpeg-core.c
@@ -1386,6 +1386,10 @@ static int s5p_jpeg_probe(struct platform_device *pdev)
1386 jpeg->vfd_encoder->release = video_device_release; 1386 jpeg->vfd_encoder->release = video_device_release;
1387 jpeg->vfd_encoder->lock = &jpeg->lock; 1387 jpeg->vfd_encoder->lock = &jpeg->lock;
1388 jpeg->vfd_encoder->v4l2_dev = &jpeg->v4l2_dev; 1388 jpeg->vfd_encoder->v4l2_dev = &jpeg->v4l2_dev;
1389 /* Locking in file operations other than ioctl should be done
1390 by the driver, not the V4L2 core.
1391 This driver needs auditing so that this flag can be removed. */
1392 set_bit(V4L2_FL_LOCK_ALL_FOPS, &jpeg->vfd_encoder->flags);
1389 1393
1390 ret = video_register_device(jpeg->vfd_encoder, VFL_TYPE_GRABBER, -1); 1394 ret = video_register_device(jpeg->vfd_encoder, VFL_TYPE_GRABBER, -1);
1391 if (ret) { 1395 if (ret) {
@@ -1413,6 +1417,10 @@ static int s5p_jpeg_probe(struct platform_device *pdev)
1413 jpeg->vfd_decoder->release = video_device_release; 1417 jpeg->vfd_decoder->release = video_device_release;
1414 jpeg->vfd_decoder->lock = &jpeg->lock; 1418 jpeg->vfd_decoder->lock = &jpeg->lock;
1415 jpeg->vfd_decoder->v4l2_dev = &jpeg->v4l2_dev; 1419 jpeg->vfd_decoder->v4l2_dev = &jpeg->v4l2_dev;
1420 /* Locking in file operations other than ioctl should be done by the driver,
1421 not the V4L2 core.
1422 This driver needs auditing so that this flag can be removed. */
1423 set_bit(V4L2_FL_LOCK_ALL_FOPS, &jpeg->vfd_decoder->flags);
1416 1424
1417 ret = video_register_device(jpeg->vfd_decoder, VFL_TYPE_GRABBER, -1); 1425 ret = video_register_device(jpeg->vfd_decoder, VFL_TYPE_GRABBER, -1);
1418 if (ret) { 1426 if (ret) {
diff --git a/drivers/media/video/s5p-mfc/s5p_mfc.c b/drivers/media/video/s5p-mfc/s5p_mfc.c
index 83fe461af263..76008549b3f1 100644
--- a/drivers/media/video/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/video/s5p-mfc/s5p_mfc.c
@@ -1048,6 +1048,10 @@ static int s5p_mfc_probe(struct platform_device *pdev)
1048 vfd->ioctl_ops = get_dec_v4l2_ioctl_ops(); 1048 vfd->ioctl_ops = get_dec_v4l2_ioctl_ops();
1049 vfd->release = video_device_release, 1049 vfd->release = video_device_release,
1050 vfd->lock = &dev->mfc_mutex; 1050 vfd->lock = &dev->mfc_mutex;
1051 /* Locking in file operations other than ioctl should be done
1052 by the driver, not the V4L2 core.
1053 This driver needs auditing so that this flag can be removed. */
1054 set_bit(V4L2_FL_LOCK_ALL_FOPS, &vfd->flags);
1051 vfd->v4l2_dev = &dev->v4l2_dev; 1055 vfd->v4l2_dev = &dev->v4l2_dev;
1052 snprintf(vfd->name, sizeof(vfd->name), "%s", S5P_MFC_DEC_NAME); 1056 snprintf(vfd->name, sizeof(vfd->name), "%s", S5P_MFC_DEC_NAME);
1053 dev->vfd_dec = vfd; 1057 dev->vfd_dec = vfd;
@@ -1072,6 +1076,8 @@ static int s5p_mfc_probe(struct platform_device *pdev)
1072 vfd->ioctl_ops = get_enc_v4l2_ioctl_ops(); 1076 vfd->ioctl_ops = get_enc_v4l2_ioctl_ops();
1073 vfd->release = video_device_release, 1077 vfd->release = video_device_release,
1074 vfd->lock = &dev->mfc_mutex; 1078 vfd->lock = &dev->mfc_mutex;
1079 /* This should not be necessary */
1080 set_bit(V4L2_FL_LOCK_ALL_FOPS, &vfd->flags);
1075 vfd->v4l2_dev = &dev->v4l2_dev; 1081 vfd->v4l2_dev = &dev->v4l2_dev;
1076 snprintf(vfd->name, sizeof(vfd->name), "%s", S5P_MFC_ENC_NAME); 1082 snprintf(vfd->name, sizeof(vfd->name), "%s", S5P_MFC_ENC_NAME);
1077 dev->vfd_enc = vfd; 1083 dev->vfd_enc = vfd;
diff --git a/drivers/media/video/s5p-tv/mixer_video.c b/drivers/media/video/s5p-tv/mixer_video.c
index f7ca5cc143c6..c0eadd75c9ac 100644
--- a/drivers/media/video/s5p-tv/mixer_video.c
+++ b/drivers/media/video/s5p-tv/mixer_video.c
@@ -1069,6 +1069,10 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
1069 set_bit(V4L2_FL_USE_FH_PRIO, &layer->vfd.flags); 1069 set_bit(V4L2_FL_USE_FH_PRIO, &layer->vfd.flags);
1070 1070
1071 video_set_drvdata(&layer->vfd, layer); 1071 video_set_drvdata(&layer->vfd, layer);
1072 /* Locking in file operations other than ioctl should be done
1073 by the driver, not the V4L2 core.
1074 This driver needs auditing so that this flag can be removed. */
1075 set_bit(V4L2_FL_LOCK_ALL_FOPS, &layer->vfd.flags);
1072 layer->vfd.lock = &layer->mutex; 1076 layer->vfd.lock = &layer->mutex;
1073 layer->vfd.v4l2_dev = &mdev->v4l2_dev; 1077 layer->vfd.v4l2_dev = &mdev->v4l2_dev;
1074 1078
diff --git a/drivers/media/video/sh_vou.c b/drivers/media/video/sh_vou.c
index 9644bd861abc..8fd1874382c6 100644
--- a/drivers/media/video/sh_vou.c
+++ b/drivers/media/video/sh_vou.c
@@ -1390,6 +1390,10 @@ static int __devinit sh_vou_probe(struct platform_device *pdev)
1390 vdev->v4l2_dev = &vou_dev->v4l2_dev; 1390 vdev->v4l2_dev = &vou_dev->v4l2_dev;
1391 vdev->release = video_device_release; 1391 vdev->release = video_device_release;
1392 vdev->lock = &vou_dev->fop_lock; 1392 vdev->lock = &vou_dev->fop_lock;
1393 /* Locking in file operations other than ioctl should be done
1394 by the driver, not the V4L2 core.
1395 This driver needs auditing so that this flag can be removed. */
1396 set_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags);
1393 1397
1394 vou_dev->vdev = vdev; 1398 vou_dev->vdev = vdev;
1395 video_set_drvdata(vdev, vou_dev); 1399 video_set_drvdata(vdev, vou_dev);
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index eb25756a07af..c27bb6d0a136 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -1425,6 +1425,10 @@ static int video_dev_create(struct soc_camera_device *icd)
1425 vdev->tvnorms = V4L2_STD_UNKNOWN; 1425 vdev->tvnorms = V4L2_STD_UNKNOWN;
1426 vdev->ctrl_handler = &icd->ctrl_handler; 1426 vdev->ctrl_handler = &icd->ctrl_handler;
1427 vdev->lock = &icd->video_lock; 1427 vdev->lock = &icd->video_lock;
1428 /* Locking in file operations other than ioctl should be done
1429 by the driver, not the V4L2 core.
1430 This driver needs auditing so that this flag can be removed. */
1431 set_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags);
1428 1432
1429 icd->vdev = vdev; 1433 icd->vdev = vdev;
1430 1434
diff --git a/drivers/media/video/tm6000/tm6000-video.c b/drivers/media/video/tm6000/tm6000-video.c
index 1ba26d5b2ba6..375f26abd916 100644
--- a/drivers/media/video/tm6000/tm6000-video.c
+++ b/drivers/media/video/tm6000/tm6000-video.c
@@ -1731,6 +1731,10 @@ static struct video_device *vdev_init(struct tm6000_core *dev,
1731 vfd->release = video_device_release; 1731 vfd->release = video_device_release;
1732 vfd->debug = tm6000_debug; 1732 vfd->debug = tm6000_debug;
1733 vfd->lock = &dev->lock; 1733 vfd->lock = &dev->lock;
1734 /* Locking in file operations other than ioctl should be done
1735 by the driver, not the V4L2 core.
1736 This driver needs auditing so that this flag can be removed. */
1737 set_bit(V4L2_FL_LOCK_ALL_FOPS, &vfd->flags);
1734 1738
1735 snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name); 1739 snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name);
1736 1740
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index 5a74f5e07d7d..9bd8f084f348 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -1296,6 +1296,10 @@ static struct video_device *usbvision_vdev_init(struct usb_usbvision *usbvision,
1296 if (NULL == vdev) 1296 if (NULL == vdev)
1297 return NULL; 1297 return NULL;
1298 *vdev = *vdev_template; 1298 *vdev = *vdev_template;
1299 /* Locking in file operations other than ioctl should be done
1300 by the driver, not the V4L2 core.
1301 This driver needs auditing so that this flag can be removed. */
1302 set_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags);
1299 vdev->lock = &usbvision->v4l2_lock; 1303 vdev->lock = &usbvision->v4l2_lock;
1300 vdev->v4l2_dev = &usbvision->v4l2_dev; 1304 vdev->v4l2_dev = &usbvision->v4l2_dev;
1301 snprintf(vdev->name, sizeof(vdev->name), "%s", name); 1305 snprintf(vdev->name, sizeof(vdev->name), "%s", name);
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index b1f0923212e6..2c4feffa4939 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -274,11 +274,12 @@ static ssize_t v4l2_read(struct file *filp, char __user *buf,
274 274
275 if (!vdev->fops->read) 275 if (!vdev->fops->read)
276 return -EINVAL; 276 return -EINVAL;
277 if (vdev->lock && mutex_lock_interruptible(vdev->lock)) 277 if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags) &&
278 mutex_lock_interruptible(vdev->lock))
278 return -ERESTARTSYS; 279 return -ERESTARTSYS;
279 if (video_is_registered(vdev)) 280 if (video_is_registered(vdev))
280 ret = vdev->fops->read(filp, buf, sz, off); 281 ret = vdev->fops->read(filp, buf, sz, off);
281 if (vdev->lock) 282 if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags))
282 mutex_unlock(vdev->lock); 283 mutex_unlock(vdev->lock);
283 return ret; 284 return ret;
284} 285}
@@ -291,11 +292,12 @@ static ssize_t v4l2_write(struct file *filp, const char __user *buf,
291 292
292 if (!vdev->fops->write) 293 if (!vdev->fops->write)
293 return -EINVAL; 294 return -EINVAL;
294 if (vdev->lock && mutex_lock_interruptible(vdev->lock)) 295 if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags) &&
296 mutex_lock_interruptible(vdev->lock))
295 return -ERESTARTSYS; 297 return -ERESTARTSYS;
296 if (video_is_registered(vdev)) 298 if (video_is_registered(vdev))
297 ret = vdev->fops->write(filp, buf, sz, off); 299 ret = vdev->fops->write(filp, buf, sz, off);
298 if (vdev->lock) 300 if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags))
299 mutex_unlock(vdev->lock); 301 mutex_unlock(vdev->lock);
300 return ret; 302 return ret;
301} 303}
@@ -307,11 +309,11 @@ static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll)
307 309
308 if (!vdev->fops->poll) 310 if (!vdev->fops->poll)
309 return DEFAULT_POLLMASK; 311 return DEFAULT_POLLMASK;
310 if (vdev->lock) 312 if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags))
311 mutex_lock(vdev->lock); 313 mutex_lock(vdev->lock);
312 if (video_is_registered(vdev)) 314 if (video_is_registered(vdev))
313 ret = vdev->fops->poll(filp, poll); 315 ret = vdev->fops->poll(filp, poll);
314 if (vdev->lock) 316 if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags))
315 mutex_unlock(vdev->lock); 317 mutex_unlock(vdev->lock);
316 return ret; 318 return ret;
317} 319}
@@ -399,11 +401,12 @@ static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm)
399 401
400 if (!vdev->fops->mmap) 402 if (!vdev->fops->mmap)
401 return ret; 403 return ret;
402 if (vdev->lock && mutex_lock_interruptible(vdev->lock)) 404 if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags) &&
405 mutex_lock_interruptible(vdev->lock))
403 return -ERESTARTSYS; 406 return -ERESTARTSYS;
404 if (video_is_registered(vdev)) 407 if (video_is_registered(vdev))
405 ret = vdev->fops->mmap(filp, vm); 408 ret = vdev->fops->mmap(filp, vm);
406 if (vdev->lock) 409 if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags))
407 mutex_unlock(vdev->lock); 410 mutex_unlock(vdev->lock);
408 return ret; 411 return ret;
409} 412}
@@ -426,7 +429,8 @@ static int v4l2_open(struct inode *inode, struct file *filp)
426 video_get(vdev); 429 video_get(vdev);
427 mutex_unlock(&videodev_lock); 430 mutex_unlock(&videodev_lock);
428 if (vdev->fops->open) { 431 if (vdev->fops->open) {
429 if (vdev->lock && mutex_lock_interruptible(vdev->lock)) { 432 if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags) &&
433 mutex_lock_interruptible(vdev->lock)) {
430 ret = -ERESTARTSYS; 434 ret = -ERESTARTSYS;
431 goto err; 435 goto err;
432 } 436 }
@@ -434,7 +438,7 @@ static int v4l2_open(struct inode *inode, struct file *filp)
434 ret = vdev->fops->open(filp); 438 ret = vdev->fops->open(filp);
435 else 439 else
436 ret = -ENODEV; 440 ret = -ENODEV;
437 if (vdev->lock) 441 if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags))
438 mutex_unlock(vdev->lock); 442 mutex_unlock(vdev->lock);
439 } 443 }
440 444
@@ -452,10 +456,10 @@ static int v4l2_release(struct inode *inode, struct file *filp)
452 int ret = 0; 456 int ret = 0;
453 457
454 if (vdev->fops->release) { 458 if (vdev->fops->release) {
455 if (vdev->lock) 459 if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags))
456 mutex_lock(vdev->lock); 460 mutex_lock(vdev->lock);
457 vdev->fops->release(filp); 461 vdev->fops->release(filp);
458 if (vdev->lock) 462 if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags))
459 mutex_unlock(vdev->lock); 463 mutex_unlock(vdev->lock);
460 } 464 }
461 /* decrease the refcount unconditionally since the release() 465 /* decrease the refcount unconditionally since the release()
@@ -831,6 +835,10 @@ int __video_register_device(struct video_device *vdev, int type, int nr,
831 WARN_ON(video_device[vdev->minor] != NULL); 835 WARN_ON(video_device[vdev->minor] != NULL);
832 vdev->index = get_index(vdev); 836 vdev->index = get_index(vdev);
833 mutex_unlock(&videodev_lock); 837 mutex_unlock(&videodev_lock);
838 /* if no lock was passed, then make sure the LOCK_ALL_FOPS bit is
839 clear and warn if it wasn't. */
840 if (vdev->lock == NULL)
841 WARN_ON(test_and_clear_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags));
834 842
835 if (vdev->ioctl_ops) 843 if (vdev->ioctl_ops)
836 determine_valid_ioctls(vdev); 844 determine_valid_ioctls(vdev);
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index 280c84ec4cc2..c365cdf714ea 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -898,6 +898,10 @@ dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
898 INIT_LIST_HEAD(&pd->dmaq); 898 INIT_LIST_HEAD(&pd->dmaq);
899 mutex_init(&pd->mux); 899 mutex_init(&pd->mux);
900 pd->vdev->lock = &pd->mux; /* for locking v4l2_file_operations */ 900 pd->vdev->lock = &pd->mux; /* for locking v4l2_file_operations */
901 /* Locking in file operations other than ioctl should be done
902 by the driver, not the V4L2 core.
903 This driver needs auditing so that this flag can be removed. */
904 set_bit(V4L2_FL_LOCK_ALL_FOPS, &pd->vdev->flags);
901 spin_lock_init(&pd->lock); 905 spin_lock_init(&pd->lock);
902 pd->csr2 = csr2_init; 906 pd->csr2 = csr2_init;
903 pd->config = config_init; 907 pd->config = config_init;