On Thu, 2026-03-12 at 10:33 +0200, Jani Nikula wrote: > 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.
Yeah, I'm not sure either. But you commented, I implemented. :) I made some test with bloat-o-meter and, removing only the const char *name argument as you suggested, doesn't help much, we only gain 2 bytes somehow. But, with this patch, I can remove the warn at runtime (because it wouldn't even compile then) and we can gain 49 bytes total. LOL Anyway, nice exercise. It's your call, if you want I can send the patch to remove the const char and the warn at runtime to go on top of this one. -- Cheers, Luca.
