public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/2] drm/i915: Agnostic INTEL_INFO
Date: Mon, 11 Aug 2014 13:14:50 +0300	[thread overview]
Message-ID: <87zjfb5o4l.fsf@intel.com> (raw)
In-Reply-To: <1407608323-30693-2-git-send-email-chris@chris-wilson.co.uk>

On Sat, 09 Aug 2014, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> Adapt the macro so that we can pass either the struct drm_device or the
> struct drm_i915_private pointers and get the answer we want. Over time,
> my plan is to convert all users over to using drm_i915_private and so
> trimming down the pointer dance. Having spent a few hours chasing that
> goal and achieved over 8k of object code saving, it appears to be a
> worthwhile target. This interim macro allows us to slowly convert over.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/i915_dma.c | 3 +++
>  drivers/gpu/drm/i915/i915_drv.h | 3 ++-
>  2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> index 39988940d468..49149406fcd8 100644
> --- a/drivers/gpu/drm/i915/i915_dma.c
> +++ b/drivers/gpu/drm/i915/i915_dma.c
> @@ -1585,6 +1585,9 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
>  	if (!drm_core_check_feature(dev, DRIVER_MODESET) && !dev->agp)
>  		return -EINVAL;
>  
> +	/* For the ugly agnostic INTEL_INFO macro */
> +	BUILD_BUG_ON(sizeof(*dev_priv) == sizeof(*dev));
> +
>  	dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
>  	if (dev_priv == NULL)
>  		return -ENOMEM;
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 0aef763ffa75..e66465430bdc 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -2063,7 +2063,8 @@ struct drm_i915_cmd_table {
>  	int count;
>  };
>  
> -#define INTEL_INFO(p) 	(&to_i915(p)->info)
> +#define __I915__(p)	((sizeof(*(p)) == sizeof(struct drm_i915_private)) ? (struct drm_i915_private *)(p) : to_i915((struct drm_device *)p))

The explicit casts make me uncomfortable. Indeed, aren't they completely
unnecessary? If the sizeof matches, p is expected to be struct
drm_i915_private *, and if not, it's expected to be struct drm_device *,
right?

#define __I915__(p)	((sizeof(*(p)) == sizeof(struct drm_i915_private)) ? (p) : to_i915(p))

Otherwise you won't even get a compiler warning if you pass a random
pointer to this macro.

BR,
Jani.



> +#define INTEL_INFO(p) 	(&__I915__(p)->info)
>  #define INTEL_DEVID(p)	(INTEL_INFO(p)->device_id)
>  
>  #define IS_I830(dev)		(INTEL_DEVID(dev) == 0x3577)
> -- 
> 2.1.0.rc1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Jani Nikula, Intel Open Source Technology Center

  reply	other threads:[~2014-08-11 10:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-09 18:18 [PATCH 1/2] drm/i915: Copy PCI device id into the device info block Chris Wilson
2014-08-09 18:18 ` [PATCH 2/2] drm/i915: Agnostic INTEL_INFO Chris Wilson
2014-08-11 10:14   ` Jani Nikula [this message]
2014-08-11 10:26     ` Chris Wilson
2014-08-11 11:25       ` Daniel Vetter
2014-08-11 11:30         ` Chris Wilson
2014-08-11 10:05 ` [PATCH 1/2] drm/i915: Copy PCI device id into the device info block Jani Nikula
2014-08-11 11:26   ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zjfb5o4l.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox