static int rvin_mc_open(struct file *file) { struct rvin_dev *vin = video_drvdata(file); int ret; ret = mutex_lock_interruptible(&vin->lock); if (ret) return ret; ret = pm_runtime_get_sync(vin->dev); if (ret < 0) goto err_unlock; ret = v4l2_pipeline_pm_use(&vin->vdev.entity, 1); if (ret < 0) goto err_pm; file->private_data = vin; ret = v4l2_fh_open(file); if (ret) goto err_v4l2pm; mutex_unlock(&vin->lock); return 0; err_v4l2pm: v4l2_pipeline_pm_use(&vin->vdev.entity, 0); err_pm: pm_runtime_put(vin->dev); err_unlock: mutex_unlock(&vin->lock); return ret; }
static int video_release(struct file *file) { struct video_device *vdev = video_devdata(file); vb2_fop_release(file); v4l2_pipeline_pm_use(&vdev->entity, 0); file->private_data = NULL; return 0; }
static int rvin_mc_release(struct file *file) { struct rvin_dev *vin = video_drvdata(file); int ret; mutex_lock(&vin->lock); /* the release helper will cleanup any on-going streaming. */ ret = _vb2_fop_release(file, NULL); v4l2_pipeline_pm_use(&vin->vdev.entity, 0); pm_runtime_put(vin->dev); mutex_unlock(&vin->lock); return ret; }
static int video_open(struct file *file) { struct video_device *vdev = video_devdata(file); struct camss_video *video = video_drvdata(file); struct v4l2_fh *vfh; int ret; mutex_lock(&video->lock); vfh = kzalloc(sizeof(*vfh), GFP_KERNEL); if (vfh == NULL) { ret = -ENOMEM; goto error_alloc; } v4l2_fh_init(vfh, vdev); v4l2_fh_add(vfh); file->private_data = vfh; ret = v4l2_pipeline_pm_use(&vdev->entity, 1); if (ret < 0) { dev_err(video->camss->dev, "Failed to power up pipeline: %d\n", ret); goto error_pm_use; } mutex_unlock(&video->lock); return 0; error_pm_use: v4l2_fh_release(file); error_alloc: mutex_unlock(&video->lock); return ret; }