diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-07-26 11:01:51 (GMT) |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-07-26 12:00:58 (GMT) |
commit | 2a1d775201081c400d7e60ceb8e5ac887d11b1f7 (patch) | |
tree | 5bd3ef0d28b31918b4325c4f74459855ba2f2095 /drivers/gpu/drm/i915/i915_gem_request.c | |
parent | 4a50d20e105a4a8e46a641e4779e9431e0aabc84 (diff) | |
download | linux-2a1d775201081c400d7e60ceb8e5ac887d11b1f7.tar.xz |
drm/i915: Prefer list_first_entry_or_null
list_first_entry_or_null() can generate better code than using
if (!list_empty()) {ptr = list_first_entry()) ..., so put it to use.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1469432687-22756-3-git-send-email-chris@chris-wilson.co.uk
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1469530913-17180-2-git-send-email-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem_request.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_request.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c index 60a3a34..49396b8 100644 --- a/drivers/gpu/drm/i915/i915_gem_request.c +++ b/drivers/gpu/drm/i915/i915_gem_request.c @@ -317,12 +317,10 @@ __i915_gem_request_alloc(struct intel_engine_cs *engine, return ret; /* Move the oldest request to the slab-cache (if not in use!) */ - if (!list_empty(&engine->request_list)) { - req = list_first_entry(&engine->request_list, + req = list_first_entry_or_null(&engine->request_list, typeof(*req), list); - if (i915_gem_request_completed(req)) - i915_gem_request_retire(req); - } + if (req && i915_gem_request_completed(req)) + i915_gem_request_retire(req); req = kmem_cache_zalloc(dev_priv->requests, GFP_KERNEL); if (!req) |