diff options
author | Emil Velikov <emil.l.velikov@gmail.com> | 2015-08-31 20:38:54 +0100 |
---|---|---|
committer | Emil Velikov <emil.l.velikov@gmail.com> | 2015-09-04 21:39:01 +0100 |
commit | 0ec7f4423dcb6f80bee020f98fd319b092f90581 (patch) | |
tree | 37d3f368db0c0101b2e6f0a90ea4ae7bb0251c03 /intel | |
parent | 94425f627221c0f67503a9aa4dff3502725905b3 (diff) |
intel: introduce to_bo_gem() helper
...to minimise misuse of bo_gem.
If the variable is declared at the top of the function and then used
for two (or more) different contexts this can cause confusion and errors.
Just introduce a wrapper, which can be used in a once off situations.
Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'intel')
-rw-r--r-- | intel/intel_bufmgr_gem.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index 52874192..63122d09 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -276,6 +276,11 @@ static void drm_intel_gem_bo_unreference(drm_intel_bo *bo); static void drm_intel_gem_bo_free(drm_intel_bo *bo); +static inline drm_intel_bo_gem *to_bo_gem(drm_intel_bo *bo) +{ + return (drm_intel_bo_gem *)bo; +} + static unsigned long drm_intel_gem_bo_tile_size(drm_intel_bufmgr_gem *bufmgr_gem, unsigned long size, uint32_t *tiling_mode) @@ -2116,11 +2121,10 @@ drm_intel_gem_bo_exec(drm_intel_bo *bo, int used, drm_clip_rect_t * cliprects, int num_cliprects, int DR4) { drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr; - drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo; struct drm_i915_gem_execbuffer execbuf; int ret, i; - if (bo_gem->has_error) + if (to_bo_gem(bo)->has_error) return -ENOMEM; pthread_mutex_lock(&bufmgr_gem->lock); @@ -2165,7 +2169,7 @@ drm_intel_gem_bo_exec(drm_intel_bo *bo, int used, drm_intel_gem_dump_validation_list(bufmgr_gem); for (i = 0; i < bufmgr_gem->exec_count; i++) { - bo_gem = (drm_intel_bo_gem *) bufmgr_gem->exec_bos[i]; + drm_intel_bo_gem *bo_gem = to_bo_gem(bufmgr_gem->exec_bos[i]); bo_gem->idle = false; @@ -2185,12 +2189,11 @@ do_exec2(drm_intel_bo *bo, int used, drm_intel_context *ctx, unsigned int flags) { drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr; - drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo; struct drm_i915_gem_execbuffer2 execbuf; int ret = 0; int i; - if (bo_gem->has_error) + if (to_bo_gem(bo)->has_error) return -ENOMEM; switch (flags & 0x7) { @@ -2263,7 +2266,7 @@ skip_execution: drm_intel_gem_dump_validation_list(bufmgr_gem); for (i = 0; i < bufmgr_gem->exec_count; i++) { - bo_gem = (drm_intel_bo_gem *) bufmgr_gem->exec_bos[i]; + drm_intel_bo_gem *bo_gem = to_bo_gem(bufmgr_gem->exec_bos[i]); bo_gem->idle = false; |