On Thu, 12 Mar 2026, Luca Coelho <[email protected]> wrote:
> In a previous commit, the intel_display_wa() was changed so it
> wouldn't receive an integer as the workaround number, but the enum
> value itself.  This caused compilation not to fail anymore when the
> enum passed didn't exist.
>
> Bring this back by using BUILD_BUG_ON() to check that the enum passed
> sits within the range of defined enums.
>
> Cc: Jani Nikula <[email protected]>
> Signed-off-by: Luca Coelho <[email protected]>
> ---
>  drivers/gpu/drm/i915/display/intel_display_wa.h | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_display_wa.h 
> b/drivers/gpu/drm/i915/display/intel_display_wa.h
> index 15fec843f15e..4239e4295ec7 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_wa.h
> +++ b/drivers/gpu/drm/i915/display/intel_display_wa.h
> @@ -60,11 +60,14 @@ enum intel_display_wa {
>       INTEL_DISPLAY_WA_22012358565,
>       INTEL_DISPLAY_WA_22014263786,
>       INTEL_DISPLAY_WA_22021048059,
> +
> +     INTEL_DISPLAY_WA_COUNT
>  };
>  
>  bool __intel_display_wa(struct intel_display *display, enum intel_display_wa 
> wa, const char *name);
>  
> -#define intel_display_wa(__display, __wa) \
> -     __intel_display_wa((__display), __wa, __stringify(__wa))
> -
> +#define intel_display_wa(__display, __wa) ({                           \
> +             BUILD_BUG_ON(__wa >= INTEL_DISPLAY_WA_COUNT);             \
> +             __intel_display_wa((__display), __wa, __stringify(__wa)); \
> +     })
>  #endif

I'm not sure if this is worth it to be honest. We'll get the runtime
warn anyway.

BR,
Jani.


-- 
Jani Nikula, Intel

Reply via email to