On Wed, 17 Apr 2024, Jani Nikula <jani.nikula@xxxxxxxxx> wrote: > On Tue, 16 Apr 2024, Rodrigo Vivi <rodrigo.vivi@xxxxxxxxx> wrote: >> On Tue, Apr 09, 2024 at 03:26:46PM +0300, Jani Nikula wrote: >>> Add generic __to_intel_display() macro that accepts either struct >>> xe_device * 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@xxxxxxxxx> >>> --- >>> drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h | 11 +++++++++++ >>> 1 file changed, 11 insertions(+) >>> >>> diff --git a/drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h b/drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h >>> index 2792a497257e..4448eda8b2a4 100644 >>> --- a/drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h >>> +++ b/drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h >>> @@ -29,6 +29,17 @@ >>> #include "intel_runtime_pm.h" >>> #include <linux/pm_runtime.h> >>> >>> +/* >>> + * Transitional macro to optionally convert struct xe_device * to struct >>> + * intel_display *, also accepting the latter. >>> + */ >>> +#define __to_intel_display(p) \ >>> + _Generic(p, \ >>> + const struct xe_device *: (&((const struct xe_device *)(p))->display), \ >>> + struct xe_device *: (&((struct xe_device *)(p))->display), \ >>> + const struct intel_display *: (p), \ >>> + struct intel_display *: (p)) >> >> hmmm... I thought that with our make magic we didn't need this. >> but well, at least more awareness and trying to get rid of the make magic >> earlier? > > It's needed because in i915 I wanted to put this in i915_drv.h to not > create a extra dependency to/from i915_drv.h. I tried, it gets tricky. > So weed another copy xe side. > > The make magic does convert all struct drm_i915_private to struct > xe_device, so this could have struct drm_i915_private, but the other > copy is not available here. Okay, so in v4 I decided to shove the macro to a header, and this patch and the duplication is no longer needed. BR, Jani. > > BR, > Jani. > >> >> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@xxxxxxxxx> >> >>> + >>> 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 >>> -- Jani Nikula, Intel