[Intel-gfx] [PATCH] drm/i915: Check mask/bit helper functions
Daniel Vetter
daniel.vetter at ffwll.ch
Mon Dec 8 07:20:00 PST 2014
On Mon, Dec 8, 2014 at 4:18 PM, Jani Nikula <jani.nikula at linux.intel.com> wrote:
> On Mon, 08 Dec 2014, Daniel Vetter <daniel.vetter at ffwll.ch> wrote:
>> After a bit of irc discussion we've concluded that it would be prudent
>> to check that callers use the mask/enable paramters correctly. So add
>> a WARN_ON.
>>
>> Now most callers have static parameters, so even better would be if we
>> could bug at compile-time. Hence improve the i915 WARN_ON to
>> BUILD_BUG_ON if the condition can be statically determined. Thanks to
>> Chris for this suggestion.
>>
>> All this spurred by Damien's bugfix which added _MASKED_FIELD.
>>
>> Cc: Damien Lespiau <damien.lespiau at intel.com>
>> Cc: Chris Wilson <chris at chris-wilson.co.uk>
>> Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
>> ---
>> drivers/gpu/drm/i915/i915_drv.h | 9 ++++++++-
>> drivers/gpu/drm/i915/i915_irq.c | 6 ++++++
>> 2 files changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
>> index 95dfa2dd35b9..e5d9d6642b09 100644
>> --- a/drivers/gpu/drm/i915/i915_drv.h
>> +++ b/drivers/gpu/drm/i915/i915_drv.h
>> @@ -57,8 +57,15 @@
>> #define DRIVER_DESC "Intel Graphics"
>> #define DRIVER_DATE "20141205"
>>
>> +static inline bool __i915_warn_on(bool cond, const char *str)
>> +{
>> + if (__builtin_constant_p(cond))
>> + BUILD_BUG_ON(cond);
>> + return WARN(cond, str);
>
> Won't this screw up the __FILE__ and __LINE__ in the backtrace
It will. Back to the drawing board :(
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
More information about the Intel-gfx
mailing list