Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
9af39713 b219ab9c

+6 -28
+1 -1
drivers/media/common/saa7146_core.c
··· 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
+2 -6
drivers/media/common/saa7146_fops.c
··· 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 ··· 34 37 35 38 BUG_ON((fh->resources & bits) != bits); 36 39 37 - mutex_lock(&dev->lock); 38 40 fh->resources &= ~bits; 39 41 vv->resources &= ~bits; 40 42 DEB_D(("res: put 0x%02x, cur:0x%02x\n",bits,vv->resources)); 41 - mutex_unlock(&dev->lock); 42 43 } 43 44 44 45 ··· 391 396 .write = fops_write, 392 397 .poll = fops_poll, 393 398 .mmap = fops_mmap, 394 - .ioctl = video_ioctl2, 399 + .unlocked_ioctl = video_ioctl2, 395 400 }; 396 401 397 402 static void vv_callback(struct saa7146_dev *dev, unsigned long status) ··· 500 505 vfd->fops = &video_fops; 501 506 vfd->ioctl_ops = &dev->ext_vv_data->ops; 502 507 vfd->release = video_device_release; 508 + vfd->lock = &dev->v4l2_lock; 503 509 vfd->tvnorms = 0; 504 510 for (i = 0; i < dev->ext_vv_data->num_stds; i++) 505 511 vfd->tvnorms |= dev->ext_vv_data->stds[i].id;
+1 -1
drivers/media/common/saa7146_vbi.c
··· 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;
+1 -19
drivers/media/common/saa7146_video.c
··· 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; ··· 561 563 vv->ov_fb.fmt.bytesperline = vv->ov_fb.fmt.width * fmt->depth / 8; 562 564 DEB_D(("setting bytesperline to %d\n", vv->ov_fb.fmt.bytesperline)); 563 565 } 564 - 565 - mutex_unlock(&dev->lock); 566 566 return 0; 567 567 } 568 568 ··· 645 649 return -EINVAL; 646 650 } 647 651 648 - mutex_lock(&dev->lock); 649 - 650 652 switch (ctrl->type) { 651 653 case V4L2_CTRL_TYPE_BOOLEAN: 652 654 case V4L2_CTRL_TYPE_MENU: ··· 687 693 /* fixme: we can support changing VFLIP and HFLIP here... */ 688 694 if (IS_CAPTURE_ACTIVE(fh) != 0) { 689 695 DEB_D(("V4L2_CID_HFLIP while active capture.\n")); 690 - mutex_unlock(&dev->lock); 691 696 return -EBUSY; 692 697 } 693 698 vv->hflip = c->value; ··· 694 701 case V4L2_CID_VFLIP: 695 702 if (IS_CAPTURE_ACTIVE(fh) != 0) { 696 703 DEB_D(("V4L2_CID_VFLIP while active capture.\n")); 697 - mutex_unlock(&dev->lock); 698 704 return -EBUSY; 699 705 } 700 706 vv->vflip = c->value; 701 707 break; 702 708 default: 703 - mutex_unlock(&dev->lock); 704 709 return -EINVAL; 705 710 } 706 - mutex_unlock(&dev->lock); 707 711 708 712 if (IS_OVERLAY_ACTIVE(fh) != 0) { 709 713 saa7146_stop_preview(fh); ··· 892 902 err = vidioc_try_fmt_vid_overlay(file, fh, f); 893 903 if (0 != err) 894 904 return err; 895 - mutex_lock(&dev->lock); 896 905 fh->ov.win = f->fmt.win; 897 906 fh->ov.nclips = f->fmt.win.clipcount; 898 907 if (fh->ov.nclips > 16) 899 908 fh->ov.nclips = 16; 900 909 if (copy_from_user(fh->ov.clips, f->fmt.win.clips, 901 910 sizeof(struct v4l2_clip) * fh->ov.nclips)) { 902 - mutex_unlock(&dev->lock); 903 911 return -EFAULT; 904 912 } 905 913 906 914 /* fh->ov.fh is used to indicate that we have valid overlay informations, too */ 907 915 fh->ov.fh = fh; 908 - 909 - mutex_unlock(&dev->lock); 910 916 911 917 /* check if our current overlay is active */ 912 918 if (IS_OVERLAY_ACTIVE(fh) != 0) { ··· 962 976 } 963 977 } 964 978 965 - mutex_lock(&dev->lock); 966 - 967 979 for (i = 0; i < dev->ext_vv_data->num_stds; i++) 968 980 if (*id & dev->ext_vv_data->stds[i].id) 969 981 break; ··· 971 987 dev->ext_vv_data->std_callback(dev, vv->standard); 972 988 found = 1; 973 989 } 974 - 975 - mutex_unlock(&dev->lock); 976 990 977 991 if (vv->ov_suspend != NULL) { 978 992 saa7146_start_preview(vv->ov_suspend); ··· 1336 1354 V4L2_BUF_TYPE_VIDEO_CAPTURE, 1337 1355 V4L2_FIELD_INTERLACED, 1338 1356 sizeof(struct saa7146_buf), 1339 - file, NULL); 1357 + file, &dev->v4l2_lock); 1340 1358 1341 1359 return 0; 1342 1360 }
+1 -1
include/media/saa7146.h
··· 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*/