[Intel-gfx] [PATCH v3] drm/i915/gvt: clean up intel_gvt.h as interface for i915 core

Chris Wilson chris at chris-wilson.co.uk
Thu Oct 20 08:51:08 UTC 2016


On Thu, Oct 20, 2016 at 04:26:14PM +0800, Zhenyu Wang wrote:
>  int intel_gvt_init_device(struct drm_i915_private *dev_priv)
>  {
> -	struct intel_gvt *gvt = &dev_priv->gvt;
> +	struct intel_gvt *gvt;
>  	int ret;
>  
>  	/*
> @@ -214,9 +216,13 @@ int intel_gvt_init_device(struct drm_i915_private *dev_priv)
>  	if (WARN_ON(!intel_gvt_host.initialized))
>  		return -EINVAL;
>  
> -	if (WARN_ON(gvt->initialized))
> +	if (WARN_ON(dev_priv->gvt))

This is the odd one out

if (WARN_ON(to_gvt(dev_priv)) ?

On the other hand it matches with the assignment. but you could do
to_gvt(dev_priv) = gvt; there, that's getting ugly. So I think the
current code is sensible.

> +#define to_gvt(dev_priv) (struct intel_gvt *)((dev_priv)->gvt)

You can now dispense with the cast. I'd prefer if this was an inline for
clearer type checking.

static inline struct intel_gvt *to_gvt(struct drm_i915_private *i915)
{
	return i915->gvt;
}

Tidy up to_gvt() (whatever takes your fancy) and
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list