Commit c5f98085 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] sh-vou: use v4l2_fh

This allows us to drop the use_count and you get free G/S_PRIORITY support.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent d8046ee0
...@@ -63,7 +63,6 @@ enum sh_vou_status { ...@@ -63,7 +63,6 @@ enum sh_vou_status {
struct sh_vou_device { struct sh_vou_device {
struct v4l2_device v4l2_dev; struct v4l2_device v4l2_dev;
struct video_device vdev; struct video_device vdev;
atomic_t use_count;
struct sh_vou_pdata *pdata; struct sh_vou_pdata *pdata;
spinlock_t lock; spinlock_t lock;
void __iomem *base; void __iomem *base;
...@@ -79,6 +78,7 @@ struct sh_vou_device { ...@@ -79,6 +78,7 @@ struct sh_vou_device {
}; };
struct sh_vou_file { struct sh_vou_file {
struct v4l2_fh fh;
struct videobuf_queue vbq; struct videobuf_queue vbq;
}; };
...@@ -1173,20 +1173,24 @@ static int sh_vou_open(struct file *file) ...@@ -1173,20 +1173,24 @@ static int sh_vou_open(struct file *file)
dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__);
v4l2_fh_init(&vou_file->fh, &vou_dev->vdev);
if (mutex_lock_interruptible(&vou_dev->fop_lock)) { if (mutex_lock_interruptible(&vou_dev->fop_lock)) {
kfree(vou_file); kfree(vou_file);
return -ERESTARTSYS; return -ERESTARTSYS;
} }
if (atomic_inc_return(&vou_dev->use_count) == 1) { v4l2_fh_add(&vou_file->fh);
if (v4l2_fh_is_singular(&vou_file->fh)) {
int ret; int ret;
/* First open */ /* First open */
vou_dev->status = SH_VOU_INITIALISING; vou_dev->status = SH_VOU_INITIALISING;
pm_runtime_get_sync(vou_dev->v4l2_dev.dev); pm_runtime_get_sync(vou_dev->v4l2_dev.dev);
ret = sh_vou_hw_init(vou_dev); ret = sh_vou_hw_init(vou_dev);
if (ret < 0) { if (ret < 0) {
atomic_dec(&vou_dev->use_count);
pm_runtime_put(vou_dev->v4l2_dev.dev); pm_runtime_put(vou_dev->v4l2_dev.dev);
vou_dev->status = SH_VOU_IDLE; vou_dev->status = SH_VOU_IDLE;
v4l2_fh_del(&vou_file->fh);
v4l2_fh_exit(&vou_file->fh);
mutex_unlock(&vou_dev->fop_lock); mutex_unlock(&vou_dev->fop_lock);
kfree(vou_file); kfree(vou_file);
return ret; return ret;
...@@ -1213,14 +1217,16 @@ static int sh_vou_release(struct file *file) ...@@ -1213,14 +1217,16 @@ static int sh_vou_release(struct file *file)
dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__);
if (!atomic_dec_return(&vou_dev->use_count)) {
mutex_lock(&vou_dev->fop_lock); mutex_lock(&vou_dev->fop_lock);
if (v4l2_fh_is_singular(&vou_file->fh)) {
/* Last close */ /* Last close */
vou_dev->status = SH_VOU_IDLE; vou_dev->status = SH_VOU_IDLE;
sh_vou_reg_a_set(vou_dev, VOUER, 0, 0x101); sh_vou_reg_a_set(vou_dev, VOUER, 0, 0x101);
pm_runtime_put(vou_dev->v4l2_dev.dev); pm_runtime_put(vou_dev->v4l2_dev.dev);
mutex_unlock(&vou_dev->fop_lock);
} }
v4l2_fh_del(&vou_file->fh);
v4l2_fh_exit(&vou_file->fh);
mutex_unlock(&vou_dev->fop_lock);
file->private_data = NULL; file->private_data = NULL;
kfree(vou_file); kfree(vou_file);
...@@ -1321,7 +1327,6 @@ static int sh_vou_probe(struct platform_device *pdev) ...@@ -1321,7 +1327,6 @@ static int sh_vou_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&vou_dev->queue); INIT_LIST_HEAD(&vou_dev->queue);
spin_lock_init(&vou_dev->lock); spin_lock_init(&vou_dev->lock);
mutex_init(&vou_dev->fop_lock); mutex_init(&vou_dev->fop_lock);
atomic_set(&vou_dev->use_count, 0);
vou_dev->pdata = vou_pdata; vou_dev->pdata = vou_pdata;
vou_dev->status = SH_VOU_IDLE; vou_dev->status = SH_VOU_IDLE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment