[Intel-gfx] [PATCH 2/2] drm/i915: Agnostic INTEL_INFO

Chris Wilson chris at chris-wilson.co.uk
Sat Aug 9 20:18:43 CEST 2014


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 at 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))
+#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




More information about the Intel-gfx mailing list