dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jesse Barnes <jbarnes@virtuousgeek.org>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm: Implement O_NONBLOCK support on /dev/dri/cardN
Date: Tue, 7 Oct 2014 12:33:01 -0700	[thread overview]
Message-ID: <20141007123301.7d02595e@jbarnes-t420> (raw)
In-Reply-To: <1412687631-28424-1-git-send-email-chris@chris-wilson.co.uk>

On Tue,  7 Oct 2014 14:13:51 +0100
Chris Wilson <chris@chris-wilson.co.uk> wrote:

> The implmentation is simple in the extreme: we only want to wait for
> events if the device was opened in blocking mode, otherwise we grab
> what is available and report an error if there was none.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: dri-devel@lists.freedesktop.org
> ---
>  drivers/gpu/drm/drm_fops.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> index ed7bc68f7e87..91e1105f2800 100644
> --- a/drivers/gpu/drm/drm_fops.c
> +++ b/drivers/gpu/drm/drm_fops.c
> @@ -515,10 +515,12 @@ ssize_t drm_read(struct file *filp, char __user
> *buffer, size_t total;
>  	ssize_t ret;
>  
> -	ret = wait_event_interruptible(file_priv->event_wait,
> -				       !list_empty(&file_priv->event_list));
> -	if (ret < 0)
> -		return ret;
> +	if ((filp->f_flags & O_NONBLOCK) == 0) {
> +		ret = wait_event_interruptible(file_priv->event_wait,
> +					       !list_empty(&file_priv->event_list));
> +		if (ret < 0)
> +			return ret;
> +	}
>  
>  	total = 0;
>  	while (drm_dequeue_event(file_priv, total, count, &e)) {
> @@ -532,7 +534,7 @@ ssize_t drm_read(struct file *filp, char __user
> *buffer, e->destroy(e);
>  	}
>  
> -	return total;
> +	return total ?: -EAGAIN;
>  }
>  EXPORT_SYMBOL(drm_read);

I'd prefer "total" to be spelled out after the ? (is this just a GNU
thing or does recent C implicitly use the first operand too?), but
that's no biggie.  Looks fine.

Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>

  reply	other threads:[~2014-10-07 19:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-07 13:13 [PATCH] drm: Implement O_NONBLOCK support on /dev/dri/cardN Chris Wilson
2014-10-07 19:33 ` Jesse Barnes [this message]
2014-10-08  9:16 ` Daniel Vetter
2014-10-08  9:45   ` Chris Wilson
2014-10-08 13:09     ` Daniel Vetter

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=20141007123301.7d02595e@jbarnes-t420 \
    --to=jbarnes@virtuousgeek.org \
    --cc=chris@chris-wilson.co.uk \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.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