Commit 9af39713feb53da96ba23fa94a73ffd0de50a815

Authored by Hans Verkuil
Committed by Mauro Carvalho Chehab
1 parent b219ab9cfb

[media] saa7146: Convert from .ioctl to .unlocked_ioctl

Convert saa7146 to use core-assisted locking.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

Showing 5 changed files with 6 additions and 28 deletions Side-by-side Diff

drivers/media/common/saa7146_core.c
... ... @@ -452,7 +452,7 @@
452 452 INFO(("found saa7146 @ mem %p (revision %d, irq %d) (0x%04x,0x%04x).\n", dev->mem, dev->revision, pci->irq, pci->subsystem_vendor, pci->subsystem_device));
453 453 dev->ext = ext;
454 454  
455   - mutex_init(&dev->lock);
  455 + mutex_init(&dev->v4l2_lock);
456 456 spin_lock_init(&dev->int_slock);
457 457 spin_lock_init(&dev->slock);
458 458  
drivers/media/common/saa7146_fops.c
... ... @@ -15,18 +15,15 @@
15 15 }
16 16  
17 17 /* is it free? */
18   - mutex_lock(&dev->lock);
19 18 if (vv->resources & bit) {
20 19 DEB_D(("locked! vv->resources:0x%02x, we want:0x%02x\n",vv->resources,bit));
21 20 /* no, someone else uses it */
22   - mutex_unlock(&dev->lock);
23 21 return 0;
24 22 }
25 23 /* it's free, grab it */
26 24 fh->resources |= bit;
27 25 vv->resources |= bit;
28 26 DEB_D(("res: get 0x%02x, cur:0x%02x\n",bit,vv->resources));
29   - mutex_unlock(&dev->lock);
30 27 return 1;
31 28 }
32 29  
33 30  
... ... @@ -37,11 +34,9 @@
37 34  
38 35 BUG_ON((fh->resources & bits) != bits);
39 36  
40   - mutex_lock(&dev->lock);
41 37 fh->resources &= ~bits;
42 38 vv->resources &= ~bits;
43 39 DEB_D(("res: put 0x%02x, cur:0x%02x\n",bits,vv->resources));
44   - mutex_unlock(&dev->lock);
45 40 }
46 41  
47 42  
... ... @@ -396,7 +391,7 @@
396 391 .write = fops_write,
397 392 .poll = fops_poll,
398 393 .mmap = fops_mmap,
399   - .ioctl = video_ioctl2,
  394 + .unlocked_ioctl = video_ioctl2,
400 395 };
401 396  
402 397 static void vv_callback(struct saa7146_dev *dev, unsigned long status)
... ... @@ -505,6 +500,7 @@
505 500 vfd->fops = &video_fops;
506 501 vfd->ioctl_ops = &dev->ext_vv_data->ops;
507 502 vfd->release = video_device_release;
  503 + vfd->lock = &dev->v4l2_lock;
508 504 vfd->tvnorms = 0;
509 505 for (i = 0; i < dev->ext_vv_data->num_stds; i++)
510 506 vfd->tvnorms |= dev->ext_vv_data->stds[i].id;
drivers/media/common/saa7146_vbi.c
... ... @@ -412,7 +412,7 @@
412 412 V4L2_BUF_TYPE_VBI_CAPTURE,
413 413 V4L2_FIELD_SEQ_TB, // FIXME: does this really work?
414 414 sizeof(struct saa7146_buf),
415   - file, NULL);
  415 + file, &dev->v4l2_lock);
416 416  
417 417 init_timer(&fh->vbi_read_timeout);
418 418 fh->vbi_read_timeout.function = vbi_read_timeout;
drivers/media/common/saa7146_video.c
... ... @@ -553,8 +553,6 @@
553 553 }
554 554 }
555 555  
556   - mutex_lock(&dev->lock);
557   -
558 556 /* ok, accept it */
559 557 vv->ov_fb = *fb;
560 558 vv->ov_fmt = fmt;
... ... @@ -563,8 +561,6 @@
563 561 vv->ov_fb.fmt.bytesperline = vv->ov_fb.fmt.width * fmt->depth / 8;
564 562 DEB_D(("setting bytesperline to %d\n", vv->ov_fb.fmt.bytesperline));
565 563 }
566   -
567   - mutex_unlock(&dev->lock);
568 564 return 0;
569 565 }
570 566  
... ... @@ -649,8 +645,6 @@
649 645 return -EINVAL;
650 646 }
651 647  
652   - mutex_lock(&dev->lock);
653   -
654 648 switch (ctrl->type) {
655 649 case V4L2_CTRL_TYPE_BOOLEAN:
656 650 case V4L2_CTRL_TYPE_MENU:
... ... @@ -693,7 +687,6 @@
693 687 /* fixme: we can support changing VFLIP and HFLIP here... */
694 688 if (IS_CAPTURE_ACTIVE(fh) != 0) {
695 689 DEB_D(("V4L2_CID_HFLIP while active capture.\n"));
696   - mutex_unlock(&dev->lock);
697 690 return -EBUSY;
698 691 }
699 692 vv->hflip = c->value;
700 693  
701 694  
... ... @@ -701,16 +694,13 @@
701 694 case V4L2_CID_VFLIP:
702 695 if (IS_CAPTURE_ACTIVE(fh) != 0) {
703 696 DEB_D(("V4L2_CID_VFLIP while active capture.\n"));
704   - mutex_unlock(&dev->lock);
705 697 return -EBUSY;
706 698 }
707 699 vv->vflip = c->value;
708 700 break;
709 701 default:
710   - mutex_unlock(&dev->lock);
711 702 return -EINVAL;
712 703 }
713   - mutex_unlock(&dev->lock);
714 704  
715 705 if (IS_OVERLAY_ACTIVE(fh) != 0) {
716 706 saa7146_stop_preview(fh);
717 707  
718 708  
... ... @@ -902,22 +892,18 @@
902 892 err = vidioc_try_fmt_vid_overlay(file, fh, f);
903 893 if (0 != err)
904 894 return err;
905   - mutex_lock(&dev->lock);
906 895 fh->ov.win = f->fmt.win;
907 896 fh->ov.nclips = f->fmt.win.clipcount;
908 897 if (fh->ov.nclips > 16)
909 898 fh->ov.nclips = 16;
910 899 if (copy_from_user(fh->ov.clips, f->fmt.win.clips,
911 900 sizeof(struct v4l2_clip) * fh->ov.nclips)) {
912   - mutex_unlock(&dev->lock);
913 901 return -EFAULT;
914 902 }
915 903  
916 904 /* fh->ov.fh is used to indicate that we have valid overlay informations, too */
917 905 fh->ov.fh = fh;
918 906  
919   - mutex_unlock(&dev->lock);
920   -
921 907 /* check if our current overlay is active */
922 908 if (IS_OVERLAY_ACTIVE(fh) != 0) {
923 909 saa7146_stop_preview(fh);
... ... @@ -976,8 +962,6 @@
976 962 }
977 963 }
978 964  
979   - mutex_lock(&dev->lock);
980   -
981 965 for (i = 0; i < dev->ext_vv_data->num_stds; i++)
982 966 if (*id & dev->ext_vv_data->stds[i].id)
983 967 break;
... ... @@ -988,8 +972,6 @@
988 972 found = 1;
989 973 }
990 974  
991   - mutex_unlock(&dev->lock);
992   -
993 975 if (vv->ov_suspend != NULL) {
994 976 saa7146_start_preview(vv->ov_suspend);
995 977 vv->ov_suspend = NULL;
... ... @@ -1354,7 +1336,7 @@
1354 1336 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1355 1337 V4L2_FIELD_INTERLACED,
1356 1338 sizeof(struct saa7146_buf),
1357   - file, NULL);
  1339 + file, &dev->v4l2_lock);
1358 1340  
1359 1341 return 0;
1360 1342 }
include/media/saa7146.h
... ... @@ -115,7 +115,7 @@
115 115  
116 116 /* different device locks */
117 117 spinlock_t slock;
118   - struct mutex lock;
  118 + struct mutex v4l2_lock;
119 119  
120 120 unsigned char __iomem *mem; /* pointer to mapped IO memory */
121 121 u32 revision; /* chip revision; needed for bug-workarounds*/