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

[media] v4l: soc-camera: switch to .unlocked_ioctl

Use the V4L mutex infrastructure in soc-camera core and drivers and switch to
.unlocked_ioctl.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Guennadi Liakhovetski and committed by
Mauro Carvalho Chehab
b6a633c1 c85bb69a

+19 -48
+3 -4
drivers/media/video/mx1_camera.c
··· 382 382 struct mx1_camera_dev *pcdev = ici->priv; 383 383 384 384 videobuf_queue_dma_contig_init(q, &mx1_videobuf_ops, icd->dev.parent, 385 - &pcdev->lock, 386 - V4L2_BUF_TYPE_VIDEO_CAPTURE, 387 - V4L2_FIELD_NONE, 388 - sizeof(struct mx1_buffer), icd, NULL); 385 + &pcdev->lock, V4L2_BUF_TYPE_VIDEO_CAPTURE, 386 + V4L2_FIELD_NONE, 387 + sizeof(struct mx1_buffer), icd, &icd->video_lock); 389 388 } 390 389 391 390 static int mclk_get_divisor(struct mx1_camera_dev *pcdev)
+2 -1
drivers/media/video/mx2_camera.c
··· 683 683 684 684 videobuf_queue_dma_contig_init(q, &mx2_videobuf_ops, pcdev->dev, 685 685 &pcdev->lock, V4L2_BUF_TYPE_VIDEO_CAPTURE, 686 - V4L2_FIELD_NONE, sizeof(struct mx2_buffer), icd, NULL); 686 + V4L2_FIELD_NONE, sizeof(struct mx2_buffer), 687 + icd, &icd->video_lock); 687 688 } 688 689 689 690 #define MX2_BUS_FLAGS (SOCAM_DATAWIDTH_8 | \
+1 -1
drivers/media/video/mx3_camera.c
··· 443 443 V4L2_BUF_TYPE_VIDEO_CAPTURE, 444 444 V4L2_FIELD_NONE, 445 445 sizeof(struct mx3_camera_buffer), icd, 446 - NULL); 446 + &icd->video_lock); 447 447 } 448 448 449 449 /* First part of ipu_csi_init_interface() */
+2 -2
drivers/media/video/omap1_camera.c
··· 1365 1365 videobuf_queue_dma_contig_init(q, &omap1_videobuf_ops, 1366 1366 icd->dev.parent, &pcdev->lock, 1367 1367 V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE, 1368 - sizeof(struct omap1_cam_buf), icd, NULL); 1368 + sizeof(struct omap1_cam_buf), icd, &icd->video_lock); 1369 1369 else 1370 1370 videobuf_queue_sg_init(q, &omap1_videobuf_ops, 1371 1371 icd->dev.parent, &pcdev->lock, 1372 1372 V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE, 1373 - sizeof(struct omap1_cam_buf), icd, NULL); 1373 + sizeof(struct omap1_cam_buf), icd, &icd->video_lock); 1374 1374 1375 1375 /* use videobuf mode (auto)selected with the module parameter */ 1376 1376 pcdev->vb_mode = sg_mode ? OMAP1_CAM_DMA_SG : OMAP1_CAM_DMA_CONTIG;
+1 -1
drivers/media/video/pxa_camera.c
··· 852 852 */ 853 853 videobuf_queue_sg_init(q, &pxa_videobuf_ops, NULL, &pcdev->lock, 854 854 V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE, 855 - sizeof(struct pxa_buffer), icd, NULL); 855 + sizeof(struct pxa_buffer), icd, &icd->video_lock); 856 856 } 857 857 858 858 static u32 mclk_get_divisor(struct platform_device *pdev,
+1 -1
drivers/media/video/sh_mobile_ceu_camera.c
··· 1786 1786 V4L2_BUF_TYPE_VIDEO_CAPTURE, 1787 1787 pcdev->field, 1788 1788 sizeof(struct sh_mobile_ceu_buffer), 1789 - icd, NULL); 1789 + icd, &icd->video_lock); 1790 1790 } 1791 1791 1792 1792 static int sh_mobile_ceu_get_ctrl(struct soc_camera_device *icd,
+9 -38
drivers/media/video/soc_camera.c
··· 352 352 return -EINVAL; 353 353 } 354 354 355 - /* 356 - * Protect against icd->ops->remove() until we module_get() both 357 - * drivers. 358 - */ 359 - mutex_lock(&icd->video_lock); 360 - 361 355 icd->use_count++; 362 356 363 357 /* Now we really have to activate the camera */ ··· 406 412 file->private_data = icd; 407 413 dev_dbg(&icd->dev, "camera device open\n"); 408 414 409 - mutex_unlock(&icd->video_lock); 410 - 411 415 return 0; 412 416 413 417 /* ··· 421 429 icl->power(icd->pdev, 0); 422 430 epower: 423 431 icd->use_count--; 424 - mutex_unlock(&icd->video_lock); 425 432 module_put(ici->ops->owner); 426 433 427 434 return ret; ··· 431 440 struct soc_camera_device *icd = file->private_data; 432 441 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); 433 442 434 - mutex_lock(&icd->video_lock); 435 443 icd->use_count--; 436 444 if (!icd->use_count) { 437 445 struct soc_camera_link *icl = to_soc_camera_link(icd); ··· 446 456 447 457 if (icd->streamer == file) 448 458 icd->streamer = NULL; 449 - 450 - mutex_unlock(&icd->video_lock); 451 459 452 460 module_put(ici->ops->owner); 453 461 ··· 505 517 .owner = THIS_MODULE, 506 518 .open = soc_camera_open, 507 519 .release = soc_camera_close, 508 - .ioctl = video_ioctl2, 520 + .unlocked_ioctl = video_ioctl2, 509 521 .read = soc_camera_read, 510 522 .mmap = soc_camera_mmap, 511 523 .poll = soc_camera_poll, ··· 522 534 if (icd->streamer && icd->streamer != file) 523 535 return -EBUSY; 524 536 525 - mutex_lock(&icd->vb_vidq.vb_lock); 526 - 527 537 if (icd->vb_vidq.bufs[0]) { 528 538 dev_err(&icd->dev, "S_FMT denied: queue initialised\n"); 529 - ret = -EBUSY; 530 - goto unlock; 539 + return -EBUSY; 531 540 } 532 541 533 542 ret = soc_camera_set_fmt(icd, f); 534 543 535 544 if (!ret && !icd->streamer) 536 545 icd->streamer = file; 537 - 538 - unlock: 539 - mutex_unlock(&icd->vb_vidq.vb_lock); 540 546 541 547 return ret; 542 548 } ··· 604 622 if (icd->streamer != file) 605 623 return -EBUSY; 606 624 607 - mutex_lock(&icd->video_lock); 608 - 609 625 v4l2_subdev_call(sd, video, s_stream, 1); 610 626 611 627 /* This calls buf_queue from host driver's videobuf_queue_ops */ 612 628 ret = videobuf_streamon(&icd->vb_vidq); 613 - 614 - mutex_unlock(&icd->video_lock); 615 629 616 630 return ret; 617 631 } ··· 626 648 if (icd->streamer != file) 627 649 return -EBUSY; 628 650 629 - mutex_lock(&icd->video_lock); 630 - 631 651 /* 632 652 * This calls buf_release from host driver's videobuf_queue_ops for all 633 653 * remaining buffers. When the last buffer is freed, stop capture ··· 633 657 videobuf_streamoff(&icd->vb_vidq); 634 658 635 659 v4l2_subdev_call(sd, video, s_stream, 0); 636 - 637 - mutex_unlock(&icd->video_lock); 638 660 639 661 return 0; 640 662 } ··· 722 748 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); 723 749 int ret; 724 750 725 - mutex_lock(&icd->vb_vidq.vb_lock); 726 751 ret = ici->ops->get_crop(icd, a); 727 - mutex_unlock(&icd->vb_vidq.vb_lock); 728 752 729 753 return ret; 730 754 } ··· 747 775 dev_dbg(&icd->dev, "S_CROP(%ux%u@%u:%u)\n", 748 776 rect->width, rect->height, rect->left, rect->top); 749 777 750 - /* Cropping is allowed during a running capture, guard consistency */ 751 - mutex_lock(&icd->vb_vidq.vb_lock); 752 - 753 778 /* If get_crop fails, we'll let host and / or client drivers decide */ 754 779 ret = ici->ops->get_crop(icd, &current_crop); 755 780 ··· 763 794 } else { 764 795 ret = ici->ops->set_crop(icd, a); 765 796 } 766 - 767 - mutex_unlock(&icd->vb_vidq.vb_lock); 768 797 769 798 return ret; 770 799 } ··· 965 998 966 999 icd->field = V4L2_FIELD_ANY; 967 1000 968 - /* ..._video_start() will create a device node, so we have to protect */ 1001 + icd->vdev->lock = &icd->video_lock; 1002 + 1003 + /* 1004 + * ..._video_start() will create a device node, video_register_device() 1005 + * itself is protected against concurrent open() calls, but we also have 1006 + * to protect our data. 1007 + */ 969 1008 mutex_lock(&icd->video_lock); 970 1009 971 1010 ret = soc_camera_video_start(icd); ··· 1036 1063 BUG_ON(!dev->parent); 1037 1064 1038 1065 if (vdev) { 1039 - mutex_lock(&icd->video_lock); 1040 1066 video_unregister_device(vdev); 1041 1067 icd->vdev = NULL; 1042 - mutex_unlock(&icd->video_lock); 1043 1068 } 1044 1069 1045 1070 if (icl->board_info) {