diff mbox

[RFC,v2,2/4] v4l: vb2: Only poll for events if the user is interested in them

Message ID 1380721516-488-3-git-send-email-sakari.ailus@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sakari Ailus Oct. 2, 2013, 1:45 p.m. UTC
Also poll_wait() before checking the events since otherwise it's possible to
go to sleep and not getting woken up if the event arrives between the two
operations.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/v4l2-core/videobuf2-core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Hans Verkuil Oct. 2, 2013, 2:07 p.m. UTC | #1
On 10/02/13 15:45, Sakari Ailus wrote:
> Also poll_wait() before checking the events since otherwise it's possible to
> go to sleep and not getting woken up if the event arrives between the two
> operations.
>
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>   drivers/media/v4l2-core/videobuf2-core.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
> index 594c75e..79acf5e 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -2003,13 +2003,14 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
>   	unsigned int res = 0;
>   	unsigned long flags;
>
> -	if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) {
> +	if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) &&
> +	    req_events & POLLPRI) {

Can you add parenthesis around 'req_events & POLLPRI'? When mixing '&&' 
and '&' that makes it more readable.

>   		struct v4l2_fh *fh = file->private_data;
>
> +		poll_wait(file, &fh->wait, wait);
> +
>   		if (v4l2_event_pending(fh))
>   			res = POLLPRI;
> -		else if (req_events & POLLPRI)
> -			poll_wait(file, &fh->wait, wait);
>   	}
>
>   	if (!V4L2_TYPE_IS_OUTPUT(q->type) && !(req_events & (POLLIN | POLLRDNORM)))
>

After making that change you can add my:

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans
--
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
diff mbox

Patch

diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 594c75e..79acf5e 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -2003,13 +2003,14 @@  unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
 	unsigned int res = 0;
 	unsigned long flags;
 
-	if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) {
+	if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) &&
+	    req_events & POLLPRI) {
 		struct v4l2_fh *fh = file->private_data;
 
+		poll_wait(file, &fh->wait, wait);
+
 		if (v4l2_event_pending(fh))
 			res = POLLPRI;
-		else if (req_events & POLLPRI)
-			poll_wait(file, &fh->wait, wait);
 	}
 
 	if (!V4L2_TYPE_IS_OUTPUT(q->type) && !(req_events & (POLLIN | POLLRDNORM)))