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;
};
/* Note that the (struct drm_i915_private *) cast is just to shut up gcc. */
-#define __I915__(p) ((sizeof(*(p)) == sizeof(struct drm_i915_private)) ? \
- (struct drm_i915_private *)(p) : to_i915(p))
+#define __I915__(p) ({ \
+ struct drm_i915_private *__p; \
+ if (__builtin_types_compatible_p(typeof(*p), struct drm_i915_private)) \
+ __p = (struct drm_i915_private *)p; \
+ else if (__builtin_types_compatible_p(typeof(*p), struct drm_device)) \
+ __p = to_i915((struct drm_device *)p); \
+ else \
+ BUILD_BUG(); \
+ __p; \
+})
#define INTEL_INFO(p) (&__I915__(p)->info)
#define INTEL_DEVID(p) (INTEL_INFO(p)->device_id)