diff mbox

[05/24] V4L2: allow dummy file-handle initialisation by v4l2_fh_init()

Message ID 1366320945-21591-6-git-send-email-g.liakhovetski@gmx.de (mailing list archive)
State New, archived
Headers show

Commit Message

Guennadi Liakhovetski April 18, 2013, 9:35 p.m. UTC
v4l2_fh_init() can be used to initialise dummy file-handles with vdev ==
NULL.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/media/v4l2-core/v4l2-fh.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

Comments

Hans Verkuil April 19, 2013, 7:22 a.m. UTC | #1
On Thu April 18 2013 23:35:26 Guennadi Liakhovetski wrote:
> v4l2_fh_init() can be used to initialise dummy file-handles with vdev ==
> NULL.

Why would you want that?

Anyway, this would definitely have to be documented as well in v4l2-fh.h.

I'm still going through your patch series so there may be a good reason
for allowing this, but it definitely doesn't make me happy.

Regards,

	Hans

> 
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> ---
>  drivers/media/v4l2-core/v4l2-fh.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
> index e57c002..7ae608b 100644
> --- a/drivers/media/v4l2-core/v4l2-fh.c
> +++ b/drivers/media/v4l2-core/v4l2-fh.c
> @@ -33,10 +33,12 @@
>  void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)
>  {
>  	fh->vdev = vdev;
> -	/* Inherit from video_device. May be overridden by the driver. */
> -	fh->ctrl_handler = vdev->ctrl_handler;
> +	if (vdev) {
> +		/* Inherit from video_device. May be overridden by the driver. */
> +		fh->ctrl_handler = vdev->ctrl_handler;
> +		set_bit(V4L2_FL_USES_V4L2_FH, &fh->vdev->flags);
> +	}
>  	INIT_LIST_HEAD(&fh->list);
> -	set_bit(V4L2_FL_USES_V4L2_FH, &fh->vdev->flags);
>  	fh->prio = V4L2_PRIORITY_UNSET;
>  	init_waitqueue_head(&fh->wait);
>  	INIT_LIST_HEAD(&fh->available);
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Laurent Pinchart April 22, 2013, 12:07 p.m. UTC | #2
Hi Hans,

On Friday 19 April 2013 09:22:50 Hans Verkuil wrote:
> On Thu April 18 2013 23:35:26 Guennadi Liakhovetski wrote:
> > v4l2_fh_init() can be used to initialise dummy file-handles with vdev ==
> > NULL.
> 
> Why would you want that?

The reason is that subdev pad operations require a file handle and use it as a 
context to store the try rectangles. The wrappers thus need to create a dummy 
file handle.

> Anyway, this would definitely have to be documented as well in v4l2-fh.h.
> 
> I'm still going through your patch series so there may be a good reason
> for allowing this, but it definitely doesn't make me happy.
> 
> Regards,
> 
> 	Hans
> 
> > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> > ---
> > 
> >  drivers/media/v4l2-core/v4l2-fh.c |    8 +++++---
> >  1 files changed, 5 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/media/v4l2-core/v4l2-fh.c
> > b/drivers/media/v4l2-core/v4l2-fh.c index e57c002..7ae608b 100644
> > --- a/drivers/media/v4l2-core/v4l2-fh.c
> > +++ b/drivers/media/v4l2-core/v4l2-fh.c
> > @@ -33,10 +33,12 @@
> > 
> >  void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)
> >  {
> >  
> >  	fh->vdev = vdev;
> > 
> > -	/* Inherit from video_device. May be overridden by the driver. */
> > -	fh->ctrl_handler = vdev->ctrl_handler;
> > +	if (vdev) {
> > +		/* Inherit from video_device. May be overridden by the driver. */
> > +		fh->ctrl_handler = vdev->ctrl_handler;
> > +		set_bit(V4L2_FL_USES_V4L2_FH, &fh->vdev->flags);
> > +	}
> > 
> >  	INIT_LIST_HEAD(&fh->list);
> > 
> > -	set_bit(V4L2_FL_USES_V4L2_FH, &fh->vdev->flags);
> > 
> >  	fh->prio = V4L2_PRIORITY_UNSET;
> >  	init_waitqueue_head(&fh->wait);
> >  	INIT_LIST_HEAD(&fh->available);
diff mbox

Patch

diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
index e57c002..7ae608b 100644
--- a/drivers/media/v4l2-core/v4l2-fh.c
+++ b/drivers/media/v4l2-core/v4l2-fh.c
@@ -33,10 +33,12 @@ 
 void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)
 {
 	fh->vdev = vdev;
-	/* Inherit from video_device. May be overridden by the driver. */
-	fh->ctrl_handler = vdev->ctrl_handler;
+	if (vdev) {
+		/* Inherit from video_device. May be overridden by the driver. */
+		fh->ctrl_handler = vdev->ctrl_handler;
+		set_bit(V4L2_FL_USES_V4L2_FH, &fh->vdev->flags);
+	}
 	INIT_LIST_HEAD(&fh->list);
-	set_bit(V4L2_FL_USES_V4L2_FH, &fh->vdev->flags);
 	fh->prio = V4L2_PRIORITY_UNSET;
 	init_waitqueue_head(&fh->wait);
 	INIT_LIST_HEAD(&fh->available);