diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2012-06-24 05:16:44 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-08-09 18:49:54 -0400 |
commit | cbc807dc8a53b997eb8cd8ddbea42b9077a6640f (patch) | |
tree | 3dc45ca9a405dbe22bb4c81baa9c2194fce12929 /drivers | |
parent | 0e1f0edfdd25a3462662cdf65796577147c67e53 (diff) |
[media] vpbe_display: remove V4L2_FL_LOCK_ALL_FOPS
Add proper locking to the file operations, allowing for the removal
of the V4L2_FL_LOCK_ALL_FOPS flag.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/davinci/vpbe_display.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/media/video/davinci/vpbe_display.c b/drivers/media/video/davinci/vpbe_display.c index 6fe7034bea7c..9a05c817462c 100644 --- a/drivers/media/video/davinci/vpbe_display.c +++ b/drivers/media/video/davinci/vpbe_display.c | |||
@@ -1376,10 +1376,15 @@ static int vpbe_display_mmap(struct file *filep, struct vm_area_struct *vma) | |||
1376 | struct vpbe_fh *fh = filep->private_data; | 1376 | struct vpbe_fh *fh = filep->private_data; |
1377 | struct vpbe_layer *layer = fh->layer; | 1377 | struct vpbe_layer *layer = fh->layer; |
1378 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; | 1378 | struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; |
1379 | int ret; | ||
1379 | 1380 | ||
1380 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_mmap\n"); | 1381 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_mmap\n"); |
1381 | 1382 | ||
1382 | return videobuf_mmap_mapper(&layer->buffer_queue, vma); | 1383 | if (mutex_lock_interruptible(&layer->opslock)) |
1384 | return -ERESTARTSYS; | ||
1385 | ret = videobuf_mmap_mapper(&layer->buffer_queue, vma); | ||
1386 | mutex_unlock(&layer->opslock); | ||
1387 | return ret; | ||
1383 | } | 1388 | } |
1384 | 1389 | ||
1385 | /* vpbe_display_poll(): It is used for select/poll system call | 1390 | /* vpbe_display_poll(): It is used for select/poll system call |
@@ -1392,8 +1397,11 @@ static unsigned int vpbe_display_poll(struct file *filep, poll_table *wait) | |||
1392 | unsigned int err = 0; | 1397 | unsigned int err = 0; |
1393 | 1398 | ||
1394 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_poll\n"); | 1399 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_poll\n"); |
1395 | if (layer->started) | 1400 | if (layer->started) { |
1401 | mutex_lock(&layer->opslock); | ||
1396 | err = videobuf_poll_stream(filep, &layer->buffer_queue, wait); | 1402 | err = videobuf_poll_stream(filep, &layer->buffer_queue, wait); |
1403 | mutex_unlock(&layer->opslock); | ||
1404 | } | ||
1397 | return err; | 1405 | return err; |
1398 | } | 1406 | } |
1399 | 1407 | ||
@@ -1428,10 +1436,12 @@ static int vpbe_display_open(struct file *file) | |||
1428 | fh->disp_dev = disp_dev; | 1436 | fh->disp_dev = disp_dev; |
1429 | 1437 | ||
1430 | if (!layer->usrs) { | 1438 | if (!layer->usrs) { |
1431 | 1439 | if (mutex_lock_interruptible(&layer->opslock)) | |
1440 | return -ERESTARTSYS; | ||
1432 | /* First claim the layer for this device */ | 1441 | /* First claim the layer for this device */ |
1433 | err = osd_device->ops.request_layer(osd_device, | 1442 | err = osd_device->ops.request_layer(osd_device, |
1434 | layer->layer_info.id); | 1443 | layer->layer_info.id); |
1444 | mutex_unlock(&layer->opslock); | ||
1435 | if (err < 0) { | 1445 | if (err < 0) { |
1436 | /* Couldn't get layer */ | 1446 | /* Couldn't get layer */ |
1437 | v4l2_err(&vpbe_dev->v4l2_dev, | 1447 | v4l2_err(&vpbe_dev->v4l2_dev, |
@@ -1469,6 +1479,7 @@ static int vpbe_display_release(struct file *file) | |||
1469 | 1479 | ||
1470 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_release\n"); | 1480 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_release\n"); |
1471 | 1481 | ||
1482 | mutex_lock(&layer->opslock); | ||
1472 | /* if this instance is doing IO */ | 1483 | /* if this instance is doing IO */ |
1473 | if (fh->io_allowed) { | 1484 | if (fh->io_allowed) { |
1474 | /* Reset io_usrs member of layer object */ | 1485 | /* Reset io_usrs member of layer object */ |
@@ -1503,6 +1514,7 @@ static int vpbe_display_release(struct file *file) | |||
1503 | /* Close the priority */ | 1514 | /* Close the priority */ |
1504 | v4l2_prio_close(&layer->prio, fh->prio); | 1515 | v4l2_prio_close(&layer->prio, fh->prio); |
1505 | file->private_data = NULL; | 1516 | file->private_data = NULL; |
1517 | mutex_unlock(&layer->opslock); | ||
1506 | 1518 | ||
1507 | /* Free memory allocated to file handle object */ | 1519 | /* Free memory allocated to file handle object */ |
1508 | kfree(fh); | 1520 | kfree(fh); |
@@ -1620,10 +1632,6 @@ static __devinit int init_vpbe_layer(int i, struct vpbe_display *disp_dev, | |||
1620 | vbd->ioctl_ops = &vpbe_ioctl_ops; | 1632 | vbd->ioctl_ops = &vpbe_ioctl_ops; |
1621 | vbd->minor = -1; | 1633 | vbd->minor = -1; |
1622 | vbd->v4l2_dev = &disp_dev->vpbe_dev->v4l2_dev; | 1634 | vbd->v4l2_dev = &disp_dev->vpbe_dev->v4l2_dev; |
1623 | /* Locking in file operations other than ioctl should be done | ||
1624 | by the driver, not the V4L2 core. | ||
1625 | This driver needs auditing so that this flag can be removed. */ | ||
1626 | set_bit(V4L2_FL_LOCK_ALL_FOPS, &vbd->flags); | ||
1627 | vbd->lock = &vpbe_display_layer->opslock; | 1635 | vbd->lock = &vpbe_display_layer->opslock; |
1628 | 1636 | ||
1629 | if (disp_dev->vpbe_dev->current_timings.timings_type & | 1637 | if (disp_dev->vpbe_dev->current_timings.timings_type & |