diff mbox series

[v3,3/7] drm/i915: add generic __to_intel_display()

Message ID bb9e39dd03ce14da19ff25c9f1c149bce88238a2.1712665176.git.jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: better high level abstraction for display | expand

Commit Message

Jani Nikula April 9, 2024, 12:26 p.m. UTC
Add generic __to_intel_display() macro that accepts either struct
drm_i915_private * or struct intel_display *. This is to be used for
transitional stuff that eventually needs to be converted to use struct
intel_display *, and therefore is not part of to_intel_display().

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Rodrigo Vivi April 16, 2024, 4:08 p.m. UTC | #1
On Tue, Apr 09, 2024 at 03:26:45PM +0300, Jani Nikula wrote:
> Add generic __to_intel_display() macro that accepts either struct
> drm_i915_private * or struct intel_display *. This is to be used for
> transitional stuff that eventually needs to be converted to use struct
> intel_display *, and therefore is not part of to_intel_display().

I hope this doesn't backfire and end up delaying the conversion
like the dev_priv -> i915...

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_drv.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index ee0d7d5f135d..4819f80942d3 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -357,6 +357,17 @@ struct drm_i915_private {
>  	 */
>  };
>  
> +/*
> + * Transitional macro to optionally convert struct drm_i915_private * to struct
> + * intel_display *, also accepting the latter.
> + */
> +#define __to_intel_display(p)						\
> +	_Generic(p,							\
> +		 const struct drm_i915_private *: (&((const struct drm_i915_private *)(p))->display), \
> +		 struct drm_i915_private *: (&((struct drm_i915_private *)(p))->display), \
> +		 const struct intel_display *: (p),			\
> +		 struct intel_display *: (p))
> +
>  static inline struct drm_i915_private *to_i915(const struct drm_device *dev)
>  {
>  	return container_of(dev, struct drm_i915_private, drm);
> -- 
> 2.39.2
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index ee0d7d5f135d..4819f80942d3 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -357,6 +357,17 @@  struct drm_i915_private {
 	 */
 };
 
+/*
+ * Transitional macro to optionally convert struct drm_i915_private * to struct
+ * intel_display *, also accepting the latter.
+ */
+#define __to_intel_display(p)						\
+	_Generic(p,							\
+		 const struct drm_i915_private *: (&((const struct drm_i915_private *)(p))->display), \
+		 struct drm_i915_private *: (&((struct drm_i915_private *)(p))->display), \
+		 const struct intel_display *: (p),			\
+		 struct intel_display *: (p))
+
 static inline struct drm_i915_private *to_i915(const struct drm_device *dev)
 {
 	return container_of(dev, struct drm_i915_private, drm);