mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
media: Set file->private_data in v4l2_fh_add()
All the drivers that use v4l2_fh and call v4l2_fh_add() manually store a
pointer to the v4l2_fh instance in file->private_data in their video
device .open() file operation handler. Move the code to the
v4l2_fh_add() function to avoid direct access to file->private_data in
drivers. This requires adding a file pointer argument to the function.
Changes to drivers have been generated with the following coccinelle
semantic patch:
@@
expression fh;
identifier filp;
identifier open;
type ret;
@@
ret open(..., struct file *filp, ...)
{
<...
- filp->private_data = fh;
...
- v4l2_fh_add(fh);
+ v4l2_fh_add(fh, filp);
...>
}
@@
expression fh;
identifier filp;
identifier open;
type ret;
@@
ret open(..., struct file *filp, ...)
{
<...
- v4l2_fh_add(fh);
+ v4l2_fh_add(fh, filp);
...
- filp->private_data = fh;
...>
}
Manual changes have been applied to Documentation/ to update the usage
patterns, to drivers/media/v4l2-core/v4l2-fh.c to update the
v4l2_fh_add() prototype set file->private_data, and to
include/media/v4l2-fh.h to update the v4l2_fh_add() function prototype
and its documentation.
Additionally, white space issues have been fixed manually in
drivers/media/platform/nvidia/tegra-vde/v4l2.c,
drivers/media/platform/rockchip/rkvdec/rkvdec.c,
drivers/media/v4l2-core/v4l2-fh.c and
drivers/staging/most/video/video.c.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
parent
32eab51811
commit
47f4b1acb4
|
|
@ -11,25 +11,22 @@ data that is used by the V4L2 framework.
|
|||
since it is also used to implement priority handling
|
||||
(:ref:`VIDIOC_G_PRIORITY`).
|
||||
|
||||
The users of :c:type:`v4l2_fh` (in the V4L2 framework, not the driver) know
|
||||
whether a driver uses :c:type:`v4l2_fh` as its ``file->private_data`` pointer
|
||||
by testing the ``V4L2_FL_USES_V4L2_FH`` bit in :c:type:`video_device`->flags.
|
||||
This bit is set whenever :c:func:`v4l2_fh_init` is called.
|
||||
struct v4l2_fh is allocated in the driver's ``open()`` file operation handler.
|
||||
It is typically embedded in a larger driver-specific structure. The
|
||||
:c:type:`v4l2_fh` must be initialized with a call to :c:func:`v4l2_fh_init`,
|
||||
and added to the video device with :c:func:`v4l2_fh_add`. This associates the
|
||||
:c:type:`v4l2_fh` with the :c:type:`file` by setting ``file->private_data`` to
|
||||
point to the :c:type:`v4l2_fh`.
|
||||
|
||||
struct v4l2_fh is allocated as a part of the driver's own file handle
|
||||
structure and ``file->private_data`` is set to it in the driver's ``open()``
|
||||
function by the driver. The :c:type:`v4l2_fh` file handle can be retrieved
|
||||
from the :c:type:`file` using :c:func:`file_to_v4l2_fh`. Drivers must not
|
||||
access ``file->private_data`` directly.
|
||||
Similarly, the struct v4l2_fh is freed in the driver's ``release()`` file
|
||||
operation handler. It must be removed from the video device with
|
||||
:c:func:`v4l2_fh_del` and cleaned up with :c:func:`v4l2_fh_exit` before being
|
||||
freed.
|
||||
|
||||
In many cases the struct v4l2_fh will be embedded in a larger
|
||||
structure. In that case you should call:
|
||||
|
||||
#) :c:func:`v4l2_fh_init` and :c:func:`v4l2_fh_add` in ``open()``
|
||||
#) :c:func:`v4l2_fh_del` and :c:func:`v4l2_fh_exit` in ``release()``
|
||||
|
||||
Drivers can extract their own file handle structure by using the container_of
|
||||
macro.
|
||||
Drivers must not access ``file->private_data`` directly. They can retrieve the
|
||||
:c:type:`v4l2_fh` associated with a :c:type:`file` by calling
|
||||
:c:func:`file_to_v4l2_fh`. Drivers can extract their own file handle structure
|
||||
by using the container_of macro.
|
||||
|
||||
Example:
|
||||
|
||||
|
|
@ -58,8 +55,7 @@ Example:
|
|||
|
||||
...
|
||||
|
||||
file->private_data = &my_fh->fh;
|
||||
v4l2_fh_add(&my_fh->fh);
|
||||
v4l2_fh_add(&my_fh->fh, file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +80,7 @@ Below is a short description of the :c:type:`v4l2_fh` functions used:
|
|||
:c:type:`v4l2_file_operations`->open() handler.
|
||||
|
||||
:c:func:`v4l2_fh_add <v4l2_fh_add>`
|
||||
(:c:type:`fh <v4l2_fh>`)
|
||||
(:c:type:`fh <v4l2_fh>`, struct file \*filp)
|
||||
|
||||
- Add a :c:type:`v4l2_fh` to :c:type:`video_device` file handle list.
|
||||
Must be called once the file handle is completely initialized.
|
||||
|
|
@ -138,6 +134,12 @@ associated device node:
|
|||
|
||||
- Same, but it calls v4l2_fh_is_singular with filp->private_data.
|
||||
|
||||
.. note::
|
||||
The V4L2 framework knows whether a driver uses :c:type:`v4l2_fh` as its
|
||||
``file->private_data`` pointer by testing the ``V4L2_FL_USES_V4L2_FH``
|
||||
bit in :c:type:`video_device`->flags. This bit is set whenever
|
||||
:c:func:`v4l2_fh_init` is called.
|
||||
|
||||
|
||||
V4L2 fh functions and data structures
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -812,8 +812,7 @@ int my_open(struct file *file)
|
|||
|
||||
...
|
||||
|
||||
file->private_data = &my_fh->fh;
|
||||
v4l2_fh_add(&my_fh->fh);
|
||||
v4l2_fh_add(&my_fh->fh, file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -836,7 +835,7 @@ void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)
|
|||
初始化文件句柄。这*必须*在驱动的 v4l2_file_operations->open()
|
||||
函数中执行。
|
||||
|
||||
void v4l2_fh_add(struct v4l2_fh *fh)
|
||||
void v4l2_fh_add(struct v4l2_fh *fh, struct file *filp)
|
||||
|
||||
添加一个 v4l2_fh 到 video_device 文件句柄列表。一旦文件句柄
|
||||
初始化完成就必须调用。
|
||||
|
|
|
|||
|
|
@ -743,8 +743,7 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp)
|
|||
item->type = s->type;
|
||||
|
||||
item->open_id = cx->open_id++;
|
||||
filp->private_data = &item->fh;
|
||||
v4l2_fh_add(&item->fh);
|
||||
v4l2_fh_add(&item->fh, filp);
|
||||
|
||||
if (item->type == CX18_ENC_STREAM_TYPE_RAD &&
|
||||
v4l2_fh_is_singular_file(filp)) {
|
||||
|
|
|
|||
|
|
@ -998,9 +998,7 @@ static int ivtv_open(struct file *filp)
|
|||
v4l2_fh_init(&item->fh, &s->vdev);
|
||||
item->itv = itv;
|
||||
item->type = s->type;
|
||||
|
||||
filp->private_data = &item->fh;
|
||||
v4l2_fh_add(&item->fh);
|
||||
v4l2_fh_add(&item->fh, filp);
|
||||
|
||||
if (item->type == IVTV_ENC_STREAM_TYPE_RAD &&
|
||||
v4l2_fh_is_singular_file(filp)) {
|
||||
|
|
|
|||
|
|
@ -725,8 +725,7 @@ static int fops_open(struct file *file)
|
|||
|
||||
fh->port = port;
|
||||
v4l2_fh_init(&fh->fh, video_devdata(file));
|
||||
v4l2_fh_add(&fh->fh);
|
||||
file->private_data = &fh->fh;
|
||||
v4l2_fh_add(&fh->fh, file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -428,8 +428,7 @@ static int fops_open(struct file *file)
|
|||
|
||||
fh->port = port;
|
||||
v4l2_fh_init(&fh->fh, video_devdata(file));
|
||||
v4l2_fh_add(&fh->fh);
|
||||
file->private_data = &fh->fh;
|
||||
v4l2_fh_add(&fh->fh, file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3219,8 +3219,7 @@ static int allegro_open(struct file *file)
|
|||
}
|
||||
|
||||
list_add(&channel->list, &dev->channels);
|
||||
file->private_data = &channel->fh;
|
||||
v4l2_fh_add(&channel->fh);
|
||||
v4l2_fh_add(&channel->fh, file);
|
||||
|
||||
allegro_channel_adjust(channel);
|
||||
|
||||
|
|
|
|||
|
|
@ -860,8 +860,7 @@ static int ge2d_open(struct file *file)
|
|||
return ret;
|
||||
}
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
ge2d_setup_ctrls(ctx);
|
||||
|
||||
|
|
|
|||
|
|
@ -760,7 +760,7 @@ int vpu_v4l2_open(struct file *file, struct vpu_inst *inst)
|
|||
inst->min_buffer_cap = 2;
|
||||
inst->min_buffer_out = 2;
|
||||
v4l2_fh_init(&inst->fh, func->vfd);
|
||||
v4l2_fh_add(&inst->fh);
|
||||
v4l2_fh_add(&inst->fh, file);
|
||||
|
||||
ret = call_vop(inst, ctrl_init);
|
||||
if (ret)
|
||||
|
|
@ -774,7 +774,6 @@ int vpu_v4l2_open(struct file *file, struct vpu_inst *inst)
|
|||
}
|
||||
|
||||
inst->fh.ctrl_handler = &inst->ctrl_handler;
|
||||
file->private_data = &inst->fh;
|
||||
inst->state = VPU_CODEC_STATE_DEINIT;
|
||||
inst->workqueue = alloc_ordered_workqueue("vpu_inst", WQ_MEM_RECLAIM);
|
||||
if (inst->workqueue) {
|
||||
|
|
|
|||
|
|
@ -2642,8 +2642,7 @@ static int coda_open(struct file *file)
|
|||
if (ctx->ops->seq_end_work)
|
||||
INIT_WORK(&ctx->seq_end_work, ctx->ops->seq_end_work);
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
ctx->dev = dev;
|
||||
ctx->idx = idx;
|
||||
|
||||
|
|
|
|||
|
|
@ -1761,8 +1761,7 @@ static int wave5_vpu_open_dec(struct file *filp)
|
|||
return -ENOMEM;
|
||||
|
||||
v4l2_fh_init(&inst->v4l2_fh, vdev);
|
||||
filp->private_data = &inst->v4l2_fh;
|
||||
v4l2_fh_add(&inst->v4l2_fh);
|
||||
v4l2_fh_add(&inst->v4l2_fh, filp);
|
||||
|
||||
INIT_LIST_HEAD(&inst->list);
|
||||
|
||||
|
|
|
|||
|
|
@ -1587,8 +1587,7 @@ static int wave5_vpu_open_enc(struct file *filp)
|
|||
return -ENOMEM;
|
||||
|
||||
v4l2_fh_init(&inst->v4l2_fh, vdev);
|
||||
filp->private_data = &inst->v4l2_fh;
|
||||
v4l2_fh_add(&inst->v4l2_fh);
|
||||
v4l2_fh_add(&inst->v4l2_fh, filp);
|
||||
|
||||
INIT_LIST_HEAD(&inst->list);
|
||||
|
||||
|
|
|
|||
|
|
@ -742,8 +742,7 @@ static int e5010_open(struct file *file)
|
|||
}
|
||||
|
||||
v4l2_fh_init(&ctx->fh, vdev);
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
ctx->e5010 = e5010;
|
||||
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(e5010->m2m_dev, ctx, queue_init);
|
||||
|
|
|
|||
|
|
@ -847,7 +847,6 @@ static int deinterlace_open(struct file *file)
|
|||
return -ENOMEM;
|
||||
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
ctx->dev = pcdev;
|
||||
|
||||
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(pcdev->m2m_dev, ctx, &queue_init);
|
||||
|
|
@ -866,7 +865,7 @@ static int deinterlace_open(struct file *file)
|
|||
}
|
||||
|
||||
ctx->colorspace = V4L2_COLORSPACE_REC709;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
dprintk(pcdev, "Created instance %p, m2m_ctx: %p\n",
|
||||
ctx, ctx->fh.m2m_ctx);
|
||||
|
|
|
|||
|
|
@ -1176,8 +1176,7 @@ static int mtk_jpeg_open(struct file *file)
|
|||
INIT_LIST_HEAD(&ctx->dst_done_queue);
|
||||
spin_lock_init(&ctx->done_queue_lock);
|
||||
v4l2_fh_init(&ctx->fh, vfd);
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
ctx->jpeg = jpeg;
|
||||
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(jpeg->m2m_dev, ctx,
|
||||
|
|
|
|||
|
|
@ -1070,14 +1070,13 @@ static int mtk_mdp_m2m_open(struct file *file)
|
|||
mutex_init(&ctx->slock);
|
||||
ctx->id = mdp->id_counter++;
|
||||
v4l2_fh_init(&ctx->fh, vfd);
|
||||
file->private_data = &ctx->fh;
|
||||
ret = mtk_mdp_ctrls_create(ctx);
|
||||
if (ret)
|
||||
goto error_ctrls;
|
||||
|
||||
/* Use separate control handler per file handle */
|
||||
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
INIT_LIST_HEAD(&ctx->list);
|
||||
|
||||
ctx->mdp_dev = mdp;
|
||||
|
|
|
|||
|
|
@ -590,14 +590,13 @@ static int mdp_m2m_open(struct file *file)
|
|||
ctx->mdp_dev = mdp;
|
||||
|
||||
v4l2_fh_init(&ctx->fh, vdev);
|
||||
file->private_data = &ctx->fh;
|
||||
ret = mdp_m2m_ctrls_create(ctx);
|
||||
if (ret)
|
||||
goto err_exit_fh;
|
||||
|
||||
/* Use separate control handler per file handle */
|
||||
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
mutex_init(&ctx->ctx_lock);
|
||||
ctx->m2m_ctx = v4l2_m2m_ctx_init(mdp->m2m_dev, ctx, mdp_m2m_queue_init);
|
||||
|
|
|
|||
|
|
@ -206,8 +206,7 @@ static int fops_vcodec_open(struct file *file)
|
|||
mutex_lock(&dev->dev_mutex);
|
||||
ctx->id = dev->id_counter++;
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
INIT_LIST_HEAD(&ctx->list);
|
||||
ctx->dev = dev;
|
||||
if (ctx->dev->vdec_pdata->is_subdev_supported) {
|
||||
|
|
|
|||
|
|
@ -129,8 +129,7 @@ static int fops_vcodec_open(struct file *file)
|
|||
*/
|
||||
ctx->id = dev->id_counter++;
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
INIT_LIST_HEAD(&ctx->list);
|
||||
ctx->dev = dev;
|
||||
init_waitqueue_head(&ctx->queue[0]);
|
||||
|
|
|
|||
|
|
@ -832,8 +832,7 @@ static int tegra_open(struct file *file)
|
|||
goto free_ctrls;
|
||||
}
|
||||
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
tegra_reset_coded_fmt(ctx);
|
||||
tegra_try_coded_fmt(file, &ctx->fh, &ctx->coded_fmt);
|
||||
|
|
|
|||
|
|
@ -607,7 +607,6 @@ static int dw100_open(struct file *file)
|
|||
|
||||
mutex_init(&ctx->vq_mutex);
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
ctx->dw_dev = dw_dev;
|
||||
|
||||
ctx->q_data[DW100_QUEUE_SRC].fmt = &formats[0];
|
||||
|
|
@ -651,7 +650,7 @@ static int dw100_open(struct file *file)
|
|||
goto err;
|
||||
}
|
||||
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -2205,8 +2205,7 @@ static int mxc_jpeg_open(struct file *file)
|
|||
}
|
||||
|
||||
v4l2_fh_init(&ctx->fh, mxc_vfd);
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
ctx->mxc_jpeg = mxc_jpeg;
|
||||
|
||||
|
|
|
|||
|
|
@ -1660,7 +1660,6 @@ static int pxp_open(struct file *file)
|
|||
}
|
||||
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
ctx->dev = dev;
|
||||
hdl = &ctx->hdl;
|
||||
v4l2_ctrl_handler_init(hdl, 4);
|
||||
|
|
@ -1699,7 +1698,7 @@ static int pxp_open(struct file *file)
|
|||
goto open_unlock;
|
||||
}
|
||||
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
atomic_inc(&dev->num_inst);
|
||||
|
||||
dprintk(dev, "Created instance: %p, m2m_ctx: %p\n",
|
||||
|
|
|
|||
|
|
@ -673,7 +673,6 @@ static int mxc_isi_m2m_open(struct file *file)
|
|||
mutex_init(&ctx->vb2_lock);
|
||||
|
||||
v4l2_fh_init(&ctx->fh, vdev);
|
||||
file->private_data = &ctx->fh;
|
||||
|
||||
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(m2m->m2m_dev, ctx,
|
||||
&mxc_isi_m2m_queue_init);
|
||||
|
|
@ -694,7 +693,7 @@ static int mxc_isi_m2m_open(struct file *file)
|
|||
if (ret)
|
||||
goto err_ctrls;
|
||||
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -730,7 +730,6 @@ static int emmaprp_open(struct file *file)
|
|||
return -ENOMEM;
|
||||
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
ctx->dev = pcdev;
|
||||
|
||||
if (mutex_lock_interruptible(&pcdev->dev_mutex)) {
|
||||
|
|
@ -752,7 +751,7 @@ static int emmaprp_open(struct file *file)
|
|||
clk_prepare_enable(pcdev->clk_emma_ahb);
|
||||
ctx->q_data[V4L2_M2M_SRC].fmt = &formats[1];
|
||||
ctx->q_data[V4L2_M2M_DST].fmt = &formats[0];
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
mutex_unlock(&pcdev->dev_mutex);
|
||||
|
||||
dprintk(pcdev, "Created instance %p, m2m_ctx: %p\n", ctx, ctx->fh.m2m_ctx);
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@ static void iris_v4l2_fh_init(struct iris_inst *inst, struct file *filp)
|
|||
{
|
||||
v4l2_fh_init(&inst->fh, inst->core->vdev_dec);
|
||||
inst->fh.ctrl_handler = &inst->ctrl_handler;
|
||||
v4l2_fh_add(&inst->fh);
|
||||
filp->private_data = &inst->fh;
|
||||
v4l2_fh_add(&inst->fh, filp);
|
||||
}
|
||||
|
||||
static void iris_v4l2_fh_deinit(struct iris_inst *inst, struct file *filp)
|
||||
|
|
|
|||
|
|
@ -1732,9 +1732,8 @@ static int vdec_open(struct file *file)
|
|||
v4l2_fh_init(&inst->fh, core->vdev_dec);
|
||||
|
||||
inst->fh.ctrl_handler = &inst->ctrl_handler;
|
||||
v4l2_fh_add(&inst->fh);
|
||||
v4l2_fh_add(&inst->fh, file);
|
||||
inst->fh.m2m_ctx = inst->m2m_ctx;
|
||||
file->private_data = &inst->fh;
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -1515,9 +1515,8 @@ static int venc_open(struct file *file)
|
|||
v4l2_fh_init(&inst->fh, core->vdev_enc);
|
||||
|
||||
inst->fh.ctrl_handler = &inst->ctrl_handler;
|
||||
v4l2_fh_add(&inst->fh);
|
||||
v4l2_fh_add(&inst->fh, file);
|
||||
inst->fh.m2m_ctx = inst->m2m_ctx;
|
||||
file->private_data = &inst->fh;
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -2093,7 +2093,6 @@ static int fdp1_open(struct file *file)
|
|||
}
|
||||
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
ctx->fdp1 = fdp1;
|
||||
|
||||
/* Initialise Queues */
|
||||
|
|
@ -2142,7 +2141,7 @@ static int fdp1_open(struct file *file)
|
|||
if (ret < 0)
|
||||
goto error_pm;
|
||||
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
dprintk(fdp1, "Created instance: %p, m2m_ctx: %p\n",
|
||||
ctx, ctx->fh.m2m_ctx);
|
||||
|
|
|
|||
|
|
@ -1231,8 +1231,7 @@ static int jpu_open(struct file *file)
|
|||
|
||||
v4l2_fh_init(&ctx->fh, vfd);
|
||||
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
ctx->jpu = jpu;
|
||||
ctx->encoder = vfd == &jpu->vfd_encoder;
|
||||
|
|
|
|||
|
|
@ -1079,9 +1079,7 @@ static int vsp1_video_open(struct file *file)
|
|||
return -ENOMEM;
|
||||
|
||||
v4l2_fh_init(vfh, &video->video);
|
||||
v4l2_fh_add(vfh);
|
||||
|
||||
file->private_data = vfh;
|
||||
v4l2_fh_add(vfh, file);
|
||||
|
||||
ret = vsp1_device_get(video->vsp1);
|
||||
if (ret < 0) {
|
||||
|
|
|
|||
|
|
@ -395,8 +395,7 @@ static int rga_open(struct file *file)
|
|||
return ret;
|
||||
}
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
rga_setup_ctrls(ctx);
|
||||
|
||||
|
|
|
|||
|
|
@ -938,8 +938,7 @@ static int rkvdec_open(struct file *filp)
|
|||
if (ret)
|
||||
goto err_cleanup_m2m_ctx;
|
||||
|
||||
filp->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, filp);
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -625,8 +625,7 @@ static int gsc_m2m_open(struct file *file)
|
|||
|
||||
/* Use separate control handler per file handle */
|
||||
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
ctx->gsc_dev = gsc;
|
||||
/* Default color format */
|
||||
|
|
|
|||
|
|
@ -634,8 +634,7 @@ static int fimc_m2m_open(struct file *file)
|
|||
|
||||
/* Use separate control handler per file handle */
|
||||
ctx->fh.ctrl_handler = &ctx->ctrls.handler;
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
/* Setup the device context for memory-to-memory mode */
|
||||
ctx->state = FIMC_CTX_M2M;
|
||||
|
|
|
|||
|
|
@ -257,8 +257,7 @@ static int g2d_open(struct file *file)
|
|||
return ret;
|
||||
}
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
g2d_setup_ctrls(ctx);
|
||||
|
||||
|
|
|
|||
|
|
@ -970,8 +970,7 @@ static int s5p_jpeg_open(struct file *file)
|
|||
v4l2_fh_init(&ctx->fh, vfd);
|
||||
/* Use separate control handler per file handle */
|
||||
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
ctx->jpeg = jpeg;
|
||||
if (vfd == jpeg->vfd_encoder) {
|
||||
|
|
|
|||
|
|
@ -801,8 +801,7 @@ static int s5p_mfc_open(struct file *file)
|
|||
}
|
||||
init_waitqueue_head(&ctx->queue);
|
||||
v4l2_fh_init(&ctx->fh, vdev);
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
ctx->dev = dev;
|
||||
INIT_LIST_HEAD(&ctx->src_queue);
|
||||
INIT_LIST_HEAD(&ctx->dst_queue);
|
||||
|
|
|
|||
|
|
@ -608,8 +608,7 @@ static int bdisp_open(struct file *file)
|
|||
|
||||
/* Use separate control handler per file handle */
|
||||
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
/* Default format */
|
||||
ctx->src = bdisp_dflt_fmt;
|
||||
|
|
|
|||
|
|
@ -1639,8 +1639,7 @@ static int delta_open(struct file *file)
|
|||
ctx->dev = delta;
|
||||
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
INIT_WORK(&ctx->run_work, delta_run_work);
|
||||
mutex_init(&ctx->lock);
|
||||
|
|
|
|||
|
|
@ -1174,8 +1174,7 @@ static int hva_open(struct file *file)
|
|||
|
||||
INIT_WORK(&ctx->run_work, hva_run_work);
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
ret = hva_ctrls_setup(ctx);
|
||||
if (ret) {
|
||||
|
|
|
|||
|
|
@ -304,8 +304,7 @@ static int dma2d_open(struct file *file)
|
|||
}
|
||||
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
dma2d_setup_ctrls(ctx);
|
||||
|
||||
|
|
|
|||
|
|
@ -730,7 +730,6 @@ static int deinterlace_open(struct file *file)
|
|||
deinterlace_prepare_format(&ctx->dst_fmt);
|
||||
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
ctx->dev = dev;
|
||||
|
||||
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx,
|
||||
|
|
@ -740,7 +739,7 @@ static int deinterlace_open(struct file *file)
|
|||
goto err_free;
|
||||
}
|
||||
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
mutex_unlock(&dev->dev_mutex);
|
||||
|
||||
|
|
|
|||
|
|
@ -659,7 +659,6 @@ static int rotate_open(struct file *file)
|
|||
rotate_set_cap_format(ctx, &ctx->dst_fmt, ctx->rotate);
|
||||
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
ctx->dev = dev;
|
||||
|
||||
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx,
|
||||
|
|
@ -669,7 +668,7 @@ static int rotate_open(struct file *file)
|
|||
goto err_free;
|
||||
}
|
||||
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
ret = rotate_setup_ctrls(ctx);
|
||||
if (ret)
|
||||
|
|
|
|||
|
|
@ -1297,7 +1297,7 @@ static int isp_video_open(struct file *file)
|
|||
return -ENOMEM;
|
||||
|
||||
v4l2_fh_init(&handle->vfh, &video->video);
|
||||
v4l2_fh_add(&handle->vfh);
|
||||
v4l2_fh_add(&handle->vfh, file);
|
||||
|
||||
/* If this is the first user, initialise the pipeline. */
|
||||
if (omap3isp_get(video->isp) == NULL) {
|
||||
|
|
@ -1333,7 +1333,6 @@ static int isp_video_open(struct file *file)
|
|||
handle->timeperframe.denominator = 1;
|
||||
|
||||
handle->video = video;
|
||||
file->private_data = &handle->vfh;
|
||||
|
||||
done:
|
||||
if (ret < 0) {
|
||||
|
|
|
|||
|
|
@ -2310,7 +2310,6 @@ static int vpe_open(struct file *file)
|
|||
init_adb_hdrs(ctx);
|
||||
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
|
||||
hdl = &ctx->hdl;
|
||||
v4l2_ctrl_handler_init(hdl, 1);
|
||||
|
|
@ -2364,7 +2363,7 @@ static int vpe_open(struct file *file)
|
|||
goto exit_fh;
|
||||
}
|
||||
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
/*
|
||||
* for now, just report the creation of the first instance, we can later
|
||||
|
|
|
|||
|
|
@ -663,8 +663,7 @@ static int hantro_open(struct file *filp)
|
|||
}
|
||||
|
||||
v4l2_fh_init(&ctx->fh, vdev);
|
||||
filp->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, filp);
|
||||
|
||||
hantro_reset_fmts(ctx);
|
||||
|
||||
|
|
|
|||
|
|
@ -1848,7 +1848,6 @@ static int vicodec_open(struct file *file)
|
|||
ctx->is_stateless = true;
|
||||
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
ctx->dev = dev;
|
||||
hdl = &ctx->hdl;
|
||||
v4l2_ctrl_handler_init(hdl, 5);
|
||||
|
|
@ -1932,7 +1931,7 @@ static int vicodec_open(struct file *file)
|
|||
goto open_unlock;
|
||||
}
|
||||
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
open_unlock:
|
||||
mutex_unlock(vfd->lock);
|
||||
|
|
|
|||
|
|
@ -1389,7 +1389,6 @@ static int vim2m_open(struct file *file)
|
|||
}
|
||||
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
ctx->dev = dev;
|
||||
hdl = &ctx->hdl;
|
||||
v4l2_ctrl_handler_init(hdl, 4);
|
||||
|
|
@ -1433,7 +1432,7 @@ static int vim2m_open(struct file *file)
|
|||
goto open_unlock;
|
||||
}
|
||||
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
atomic_inc(&dev->num_inst);
|
||||
|
||||
dprintk(dev, 1, "Created instance: %p, m2m_ctx: %p\n",
|
||||
|
|
|
|||
|
|
@ -341,7 +341,6 @@ static int visl_open(struct file *file)
|
|||
ctx->tpg_str_buf = kzalloc(TPG_STR_BUF_SZ, GFP_KERNEL);
|
||||
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
ctx->dev = dev;
|
||||
|
||||
rc = visl_init_ctrls(ctx);
|
||||
|
|
@ -361,7 +360,7 @@ static int visl_open(struct file *file)
|
|||
if (rc)
|
||||
goto free_m2m_ctx;
|
||||
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
dprintk(dev, "Created instance: %p, m2m_ctx: %p\n",
|
||||
ctx, ctx->fh.m2m_ctx);
|
||||
|
|
|
|||
|
|
@ -380,8 +380,7 @@ static int hdpvr_open(struct file *file)
|
|||
return -ENOMEM;
|
||||
fh->legacy_mode = true;
|
||||
v4l2_fh_init(&fh->fh, video_devdata(file));
|
||||
v4l2_fh_add(&fh->fh);
|
||||
file->private_data = &fh->fh;
|
||||
v4l2_fh_add(&fh->fh, file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1003,10 +1003,9 @@ static int pvr2_v4l2_open(struct file *file)
|
|||
}
|
||||
|
||||
fhp->file = file;
|
||||
file->private_data = &fhp->fh;
|
||||
|
||||
fhp->fw_mode_flag = pvr2_hdw_cpufw_get_enabled(hdw);
|
||||
v4l2_fh_add(&fhp->fh);
|
||||
v4l2_fh_add(&fhp->fh, file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -600,10 +600,9 @@ static int uvc_v4l2_open(struct file *file)
|
|||
return -ENOMEM;
|
||||
|
||||
v4l2_fh_init(&handle->vfh, &stream->vdev);
|
||||
v4l2_fh_add(&handle->vfh);
|
||||
v4l2_fh_add(&handle->vfh, file);
|
||||
handle->chain = stream->chain;
|
||||
handle->stream = stream;
|
||||
file->private_data = &handle->vfh;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,10 +41,12 @@ void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(v4l2_fh_init);
|
||||
|
||||
void v4l2_fh_add(struct v4l2_fh *fh)
|
||||
void v4l2_fh_add(struct v4l2_fh *fh, struct file *filp)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
filp->private_data = fh;
|
||||
|
||||
v4l2_prio_open(fh->vdev->prio, &fh->prio);
|
||||
spin_lock_irqsave(&fh->vdev->fh_lock, flags);
|
||||
list_add(&fh->list, &fh->vdev->fh_list);
|
||||
|
|
@ -57,11 +59,10 @@ int v4l2_fh_open(struct file *filp)
|
|||
struct video_device *vdev = video_devdata(filp);
|
||||
struct v4l2_fh *fh = kzalloc(sizeof(*fh), GFP_KERNEL);
|
||||
|
||||
filp->private_data = fh;
|
||||
if (fh == NULL)
|
||||
return -ENOMEM;
|
||||
v4l2_fh_init(fh, vdev);
|
||||
v4l2_fh_add(fh);
|
||||
v4l2_fh_add(fh, filp);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(v4l2_fh_open);
|
||||
|
|
|
|||
|
|
@ -86,8 +86,7 @@ static int subdev_open(struct file *file)
|
|||
}
|
||||
|
||||
v4l2_fh_init(&subdev_fh->vfh, vdev);
|
||||
v4l2_fh_add(&subdev_fh->vfh);
|
||||
file->private_data = &subdev_fh->vfh;
|
||||
v4l2_fh_add(&subdev_fh->vfh, file);
|
||||
|
||||
if (sd->v4l2_dev->mdev && sd->entity.graph_obj.mdev->dev) {
|
||||
struct module *owner;
|
||||
|
|
|
|||
|
|
@ -765,8 +765,7 @@ static int ipu_csc_scaler_open(struct file *file)
|
|||
ctx->rot_mode = IPU_ROTATE_NONE;
|
||||
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
ctx->priv = priv;
|
||||
|
||||
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(priv->m2m_dev, ctx,
|
||||
|
|
|
|||
|
|
@ -908,9 +908,8 @@ static int vdec_open(struct file *file)
|
|||
|
||||
v4l2_fh_init(&sess->fh, core->vdev_dec);
|
||||
sess->fh.ctrl_handler = &sess->ctrl_handler;
|
||||
v4l2_fh_add(&sess->fh);
|
||||
v4l2_fh_add(&sess->fh, file);
|
||||
sess->fh.m2m_ctx = sess->m2m_ctx;
|
||||
file->private_data = &sess->fh;
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -366,7 +366,6 @@ static int cedrus_open(struct file *file)
|
|||
}
|
||||
|
||||
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
||||
file->private_data = &ctx->fh;
|
||||
ctx->dev = dev;
|
||||
ctx->bit_depth = 8;
|
||||
|
||||
|
|
@ -383,7 +382,7 @@ static int cedrus_open(struct file *file)
|
|||
if (ret)
|
||||
goto err_m2m_release;
|
||||
|
||||
v4l2_fh_add(&ctx->fh);
|
||||
v4l2_fh_add(&ctx->fh, file);
|
||||
|
||||
mutex_unlock(&dev->dev_mutex);
|
||||
|
||||
|
|
|
|||
|
|
@ -96,9 +96,7 @@ static int comp_vdev_open(struct file *filp)
|
|||
|
||||
fh->mdev = mdev;
|
||||
v4l2_fh_init(&fh->fh, vdev);
|
||||
filp->private_data = &fh->fh;
|
||||
|
||||
v4l2_fh_add(&fh->fh);
|
||||
v4l2_fh_add(&fh->fh, filp);
|
||||
|
||||
ret = most_start_channel(mdev->iface, mdev->ch_idx, &comp);
|
||||
if (ret) {
|
||||
|
|
|
|||
|
|
@ -672,10 +672,9 @@ uvc_v4l2_open(struct file *file)
|
|||
return -ENOMEM;
|
||||
|
||||
v4l2_fh_init(&handle->vfh, vdev);
|
||||
v4l2_fh_add(&handle->vfh);
|
||||
v4l2_fh_add(&handle->vfh, file);
|
||||
|
||||
handle->device = &uvc->video;
|
||||
file->private_data = &handle->vfh;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,11 +87,14 @@ void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev);
|
|||
* v4l2_fh_add - Add the fh to the list of file handles on a video_device.
|
||||
*
|
||||
* @fh: pointer to &struct v4l2_fh
|
||||
* @filp: pointer to &struct file associated with @fh
|
||||
*
|
||||
* The function sets filp->private_data to point to @fh.
|
||||
*
|
||||
* .. note::
|
||||
* The @fh file handle must be initialised first.
|
||||
*/
|
||||
void v4l2_fh_add(struct v4l2_fh *fh);
|
||||
void v4l2_fh_add(struct v4l2_fh *fh, struct file *filp);
|
||||
|
||||
/**
|
||||
* v4l2_fh_open - Ancillary routine that can be used as the open\(\) op
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user