public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Dave Gordon <david.s.gordon@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: Convert dev_priv->dev backpointers to dev_priv->drm
Date: Tue, 5 Jul 2016 14:53:03 +0100	[thread overview]
Message-ID: <577BBBBF.40607@intel.com> (raw)
In-Reply-To: <1467708704-12988-1-git-send-email-chris@chris-wilson.co.uk>

On 05/07/16 09:51, Chris Wilson wrote:
> Since drm_i915_private is now a subclass of drm_device we do not need to
> chase the drm_i915_private->dev backpointer and can instead simply
> access drm_i915_private->drm directly.
>
>     text	   data	    bss	    dec	    hex	filename
> 1068757	   4565	    416	1073738	 10624a	drivers/gpu/drm/i915/i915.ko
> 1066949	   4565	    416	1071930	 105b3a	drivers/gpu/drm/i915/i915.ko
>
> Created by the coccinelle script:
> @@
> struct drm_i915_private *d;
> identifier i;
> @@
> (
> - d->dev->i
> + d->drm.i
> |
> - d->dev
> + &d->drm
> )
>
> and for good measure the dev_priv->dev backpointer was removed entirely.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

How about doing this with a macro, to isolate the users of the 
conversion from the actual layout of the drm/private pair? The caller 
need not know how one actually gets from one to the other, whether it's 
by following a pointer, finding a containing parent, locating a member, 
or just casting the pointer; the conversion macro encapsulates all that.

#define	to_drm(dev_priv)	(&dev_priv->drm)

and thus at the point of use:

-	struct drm_device *dev = dev_priv->dev;
+	struct drm_device *dev = to_drm(dev_priv);

etc. And the even simpler Cocci:

@@
struct drm_i915_private *d;
@@
- d->dev
+ to_drm(d)

.Dave.
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

      parent reply	other threads:[~2016-07-05 13:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-05  8:51 [PATCH] drm/i915: Convert dev_priv->dev backpointers to dev_priv->drm Chris Wilson
2016-07-05  9:01 ` ✗ Ro.CI.BAT: failure for " Patchwork
2016-07-05  9:14 ` [PATCH] " Matthew Auld
2016-07-05  9:23 ` kbuild test robot
2016-07-05 13:53 ` Dave Gordon [this message]

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=577BBBBF.40607@intel.com \
    --to=david.s.gordon@intel.com \
    --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