Commit 3cbad5d7 authored by Chris Wilson's avatar Chris Wilson

drm/i915/gem: Refactor tests on obj->ops->flags

We repeat obj->ops->flags in our object checks, so pull that into its
own little helper for clarity.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191002123014.1545-1-chris@chris-wilson.co.uk
parent dfe324f3
...@@ -134,34 +134,41 @@ i915_gem_object_is_readonly(const struct drm_i915_gem_object *obj) ...@@ -134,34 +134,41 @@ i915_gem_object_is_readonly(const struct drm_i915_gem_object *obj)
return obj->base.vma_node.readonly; return obj->base.vma_node.readonly;
} }
static inline bool
i915_gem_object_type_has(const struct drm_i915_gem_object *obj,
unsigned long flags)
{
return obj->ops->flags & flags;
}
static inline bool static inline bool
i915_gem_object_has_struct_page(const struct drm_i915_gem_object *obj) i915_gem_object_has_struct_page(const struct drm_i915_gem_object *obj)
{ {
return obj->ops->flags & I915_GEM_OBJECT_HAS_STRUCT_PAGE; return i915_gem_object_type_has(obj, I915_GEM_OBJECT_HAS_STRUCT_PAGE);
} }
static inline bool static inline bool
i915_gem_object_is_shrinkable(const struct drm_i915_gem_object *obj) i915_gem_object_is_shrinkable(const struct drm_i915_gem_object *obj)
{ {
return obj->ops->flags & I915_GEM_OBJECT_IS_SHRINKABLE; return i915_gem_object_type_has(obj, I915_GEM_OBJECT_IS_SHRINKABLE);
} }
static inline bool static inline bool
i915_gem_object_is_proxy(const struct drm_i915_gem_object *obj) i915_gem_object_is_proxy(const struct drm_i915_gem_object *obj)
{ {
return obj->ops->flags & I915_GEM_OBJECT_IS_PROXY; return i915_gem_object_type_has(obj, I915_GEM_OBJECT_IS_PROXY);
} }
static inline bool static inline bool
i915_gem_object_never_bind_ggtt(const struct drm_i915_gem_object *obj) i915_gem_object_never_bind_ggtt(const struct drm_i915_gem_object *obj)
{ {
return obj->ops->flags & I915_GEM_OBJECT_NO_GGTT; return i915_gem_object_type_has(obj, I915_GEM_OBJECT_NO_GGTT);
} }
static inline bool static inline bool
i915_gem_object_needs_async_cancel(const struct drm_i915_gem_object *obj) i915_gem_object_needs_async_cancel(const struct drm_i915_gem_object *obj)
{ {
return obj->ops->flags & I915_GEM_OBJECT_ASYNC_CANCEL; return i915_gem_object_type_has(obj, I915_GEM_OBJECT_ASYNC_CANCEL);
} }
static inline bool static inline bool
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment