diff mbox

drm/i915: Make sure the base lives at offset 0 of all kms objects

Message ID 1476271991-21666-1-git-send-email-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ville Syrjala Oct. 12, 2016, 11:33 a.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

We occasionally depend on eg. to_intel_crtc(NULL) being NULL as
well. Sprinkle in some BUILD_BUG_ON()s to make sure we don't
accidentally change things in a way that would violate this
assumption.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Chris Wilson Oct. 12, 2016, 1:55 p.m. UTC | #1
On Wed, Oct 12, 2016 at 02:33:11PM +0300, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> We occasionally depend on eg. to_intel_crtc(NULL) being NULL as
> well. Sprinkle in some BUILD_BUG_ON()s to make sure we don't
> accidentally change things in a way that would violate this
> assumption.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

bikeshed would be to convert the macros into typechecking inlines and
place the BUILD_BUG_ON there.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index e4bdd3a6a6e3..724a982bbb05 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -16331,6 +16331,15 @@  void intel_modeset_init(struct drm_device *dev)
 	enum pipe pipe;
 	struct intel_crtc *crtc;
 
+	BUILD_BUG_ON(to_intel_plane(NULL) != NULL);
+	BUILD_BUG_ON(to_intel_crtc(NULL) != NULL);
+	BUILD_BUG_ON(to_intel_encoder(NULL) != NULL);
+	BUILD_BUG_ON(to_intel_connector(NULL) != NULL);
+
+	BUILD_BUG_ON(to_intel_plane_state(NULL) != NULL);
+	BUILD_BUG_ON(to_intel_crtc_state(NULL) != NULL);
+	BUILD_BUG_ON(to_intel_atomic_state(NULL) != NULL);
+
 	drm_mode_config_init(dev);
 
 	dev->mode_config.min_width = 0;