Commit 2d751415 authored by Tvrtko Ursulin's avatar Tvrtko Ursulin

drm/i915: Warn in debug builds of incorrect usages of ptr_pack_bits

GEM_BUG_ON if the packed bits do not fit into the specified width.

v2: Avoid using the macro argument twice.
v3: Drop unnecessary braces. (Joonas)
Signed-off-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> (v1)
Reviewed-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20171103090538.14474-1-tvrtko.ursulin@linux.intel.com
parent ebcaa1ff
...@@ -83,8 +83,11 @@ ...@@ -83,8 +83,11 @@
(typeof(ptr))(__v & -BIT(n)); \ (typeof(ptr))(__v & -BIT(n)); \
}) })
#define ptr_pack_bits(ptr, bits, n) \ #define ptr_pack_bits(ptr, bits, n) ({ \
((typeof(ptr))((unsigned long)(ptr) | (bits))) unsigned long __bits = (bits); \
GEM_BUG_ON(__bits & -BIT(n)); \
((typeof(ptr))((unsigned long)(ptr) | __bits)); \
})
#define page_mask_bits(ptr) ptr_mask_bits(ptr, PAGE_SHIFT) #define page_mask_bits(ptr) ptr_mask_bits(ptr, PAGE_SHIFT)
#define page_unmask_bits(ptr) ptr_unmask_bits(ptr, PAGE_SHIFT) #define page_unmask_bits(ptr) ptr_unmask_bits(ptr, PAGE_SHIFT)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment