[Intel-gfx] [PATCH 2/5] drm/i915: Convert i915_ggtt_view to use an anonymous union
Joonas Lahtinen
joonas.lahtinen at linux.intel.com
Thu Dec 22 11:24:21 UTC 2016
On to, 2016-12-22 at 10:56 +0000, Chris Wilson wrote:
> Save a lot of characters by making the union anonymous, with the
> side-effect of ignoring unset bits when comparing views.
>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Daniel could A-b, as he specifically wanted all the bits initialized.
<SNIP>
> +++ b/drivers/gpu/drm/i915/i915_vma.h
> @@ -202,9 +202,18 @@ i915_vma_compare(struct i915_vma *vma,
> if (vma->ggtt_view.type != view->type)
> return vma->ggtt_view.type - view->type;
>
> - return memcmp(&vma->ggtt_view.params,
> - &view->params,
> - sizeof(view->params));
> + switch (view->type) {
> + case I915_GGTT_VIEW_ROTATED:
> + return memcmp(&vma->ggtt_view.rotated,
> + &view->rotated,
> + sizeof(view->rotated));
> + case I915_GGTT_VIEW_PARTIAL:
> + return memcmp(&vma->ggtt_view.partial,
> + &view->partial,
> + sizeof(view->partial));
We can decide the amount of bytes to compare in switch and use one
memcmp for everything.
Regards, Joonas
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
More information about the Intel-gfx
mailing list