public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com,
	Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [RFCv1 PATCH 1/8] v4l2-events/fh: merge v4l2_events into v4l2_fh
Date: Wed, 15 Jun 2011 19:59:05 +0300	[thread overview]
Message-ID: <4DF8E4D9.1050604@iki.fi> (raw)
In-Reply-To: <201106151839.35935.hverkuil@xs4all.nl>

Hans Verkuil wrote:
> On Wednesday, June 15, 2011 11:30:07 Sakari Ailus wrote:
>> Hi Hans,
>>
>> Many thanks for the patch. I'm very happy to see this!
>>
>> I have just one comment below.
>>
>>> diff --git a/include/media/v4l2-event.h b/include/media/v4l2-event.h
>>> index 45e9c1e..042b893 100644
>>> --- a/include/media/v4l2-event.h
>>> +++ b/include/media/v4l2-event.h
>>> @@ -43,17 +43,6 @@ struct v4l2_subscribed_event {
>>>   	u32			id;
>>>   };
>>>
>>> -struct v4l2_events {
>>> -	wait_queue_head_t	wait;
>>> -	struct list_head	subscribed; /* Subscribed events */
>>> -	struct list_head	free; /* Events ready for use */
>>> -	struct list_head	available; /* Dequeueable event */
>>> -	unsigned int		navailable;
>>> -	unsigned int		nallocated; /* Number of allocated events */
>>> -	u32			sequence;
>>> -};
>>> -
>>> -int v4l2_event_init(struct v4l2_fh *fh);
>>>   int v4l2_event_alloc(struct v4l2_fh *fh, unsigned int n);
>>>   void v4l2_event_free(struct v4l2_fh *fh);
>>>   int v4l2_event_dequeue(struct v4l2_fh *fh, struct v4l2_event *event,
>>> diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
>>> index d247111..bfc0457 100644
>>> --- a/include/media/v4l2-fh.h
>>> +++ b/include/media/v4l2-fh.h
>>> @@ -29,15 +29,22 @@
>>>   #include<linux/list.h>
>>>
>>>   struct video_device;
>>> -struct v4l2_events;
>>>   struct v4l2_ctrl_handler;
>>>
>>>   struct v4l2_fh {
>>>   	struct list_head	list;
>>>   	struct video_device	*vdev;
>>> -	struct v4l2_events      *events; /* events, pending and subscribed */
>>>   	struct v4l2_ctrl_handler *ctrl_handler;
>>>   	enum v4l2_priority	prio;
>>> +
>>> +	/* Events */
>>> +	wait_queue_head_t	wait;
>>> +	struct list_head	subscribed; /* Subscribed events */
>>> +	struct list_head	free; /* Events ready for use */
>>> +	struct list_head	available; /* Dequeueable event */
>>> +	unsigned int		navailable;
>>> +	unsigned int		nallocated; /* Number of allocated events */
>>> +	u32			sequence;
>>
>> A question: why to move the fields from v4l2_events to v4l2_fh? Events may
>> be more important part of V4L2 than before but they're still not file
>> handles. :-) The event related field names have no hing they'd be related to
>> events --- "free", for example.
>
> The only reason that the v4l2_events struct existed was that there were so few
> drivers that needed events. So why allocate memory that you don't need? That
> all changes with the control event: almost all drivers will need that since
> almost all drivers have events.
>
> Merging it makes the code easier and v4l2_fh_init can become a void function
> (so no more error checking needed). And since these fields are always there, I
> no longer need to check whether fh->events is NULL or not.
>
> I can add a patch renaming some of the event fields if you prefer, but I don't
> think they are that bad. Note that 'free' and 'nallocated' are removed
> completely in a later patch.

Thanks for the explanation. What I had in mind that what other fields 
possibly would be added to v4l2_fh in the future? If there will be many, 
in that case keeping event related fields in a separate structure might 
make sense. I have none in mind right now, though, so perhaps this could 
be given a second thought if we're adding more things to the v4l2_fh 
structure?

I think this patchset is a significant improvement to the old behaviour.

Regards,

-- 
Sakari Ailus
sakari.ailus@iki.fi

  reply	other threads:[~2011-06-15 17:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-14 15:22 [RFCv1 PATCH 0/8] Allocate events per-event-type, v4l2-ctrls cleanup Hans Verkuil
2011-06-14 15:22 ` [RFCv1 PATCH 1/8] v4l2-events/fh: merge v4l2_events into v4l2_fh Hans Verkuil
2011-06-14 15:22   ` [RFCv1 PATCH 2/8] v4l2-ctrls/event: remove struct v4l2_ctrl_fh, instead use v4l2_subscribed_event Hans Verkuil
2011-06-20 13:50     ` Laurent Pinchart
2011-06-14 15:22   ` [RFCv1 PATCH 3/8] v4l2-event/ctrls/fh: allocate events per fh and per type instead of just per-fh Hans Verkuil
2011-06-14 15:22   ` [RFCv1 PATCH 4/8] v4l2-event: add optional 'merge' callback to merge two events Hans Verkuil
2011-06-20 14:09     ` Laurent Pinchart
2011-06-20 14:11       ` Hans Verkuil
2011-06-14 15:22   ` [RFCv1 PATCH 5/8] v4l2-ctrls: don't initially set CH_VALUE for write-only controls Hans Verkuil
2011-06-14 15:22   ` [RFCv1 PATCH 6/8] v4l2-ctrls: improve discovery of controls of the same cluster Hans Verkuil
2011-06-14 15:22   ` [RFCv1 PATCH 7/8] v4l2-ctrls: split try_or_set_ext_ctrls() Hans Verkuil
2011-06-14 15:22   ` [RFCv1 PATCH 8/8] v4l2-ctrls: v4l2_ctrl_handler_setup code simplification Hans Verkuil
2011-06-15  9:30   ` [RFCv1 PATCH 1/8] v4l2-events/fh: merge v4l2_events into v4l2_fh Sakari Ailus
2011-06-15 16:39     ` Hans Verkuil
2011-06-15 16:59       ` Sakari Ailus [this message]
2011-06-15 17:10         ` Hans Verkuil
2011-06-15 17:24 ` [RFCv1 PATCH 0/8] Allocate events per-event-type, v4l2-ctrls cleanup Sakari Ailus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DF8E4D9.1050604@iki.fi \
    --to=sakari.ailus@iki.fi \
    --cc=hans.verkuil@cisco.com \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox