Skip to content

Commit fe52e59

Browse files
drm/i915: Introduce INTEL_GEN_MASK
Split INTEL_GEN_MASK out of IS_GEN macro, and make it usable within static declarations (unlike compound statements). v2: - s/combound/compound/ (Tvrtko) - Fix whitespace (yes, we need automatic checkpatch.pl) Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Jani Nikula <jani.nikula@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20170913115255.13851-1-joonas.lahtinen@linux.intel.com
1 parent 0d0c279 commit fe52e59

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

‎drivers/gpu/drm/i915/i915_drv.h‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2881,23 +2881,21 @@ intel_info(const struct drm_i915_private *dev_priv)
28812881
#define INTEL_REVID(dev_priv) ((dev_priv)->drm.pdev->revision)
28822882

28832883
#define GEN_FOREVER (0)
2884+
2885+
#define INTEL_GEN_MASK(s, e) ( \
2886+
BUILD_BUG_ON_ZERO(!__builtin_constant_p(s)) + \
2887+
BUILD_BUG_ON_ZERO(!__builtin_constant_p(e)) + \
2888+
GENMASK((e) != GEN_FOREVER ? (e) - 1 : BITS_PER_LONG - 1, \
2889+
(s) != GEN_FOREVER ? (s) - 1 : 0) \
2890+
)
2891+
28842892
/*
28852893
* Returns true if Gen is in inclusive range [Start, End].
28862894
*
28872895
* Use GEN_FOREVER for unbound start and or end.
28882896
*/
2889-
#define IS_GEN(dev_priv, s, e) ({ \
2890-
unsigned int __s = (s), __e = (e); \
2891-
BUILD_BUG_ON(!__builtin_constant_p(s)); \
2892-
BUILD_BUG_ON(!__builtin_constant_p(e)); \
2893-
if ((__s) != GEN_FOREVER) \
2894-
__s = (s) - 1; \
2895-
if ((__e) == GEN_FOREVER) \
2896-
__e = BITS_PER_LONG - 1; \
2897-
else \
2898-
__e = (e) - 1; \
2899-
!!((dev_priv)->info.gen_mask & GENMASK((__e), (__s))); \
2900-
})
2897+
#define IS_GEN(dev_priv, s, e) \
2898+
(!!((dev_priv)->info.gen_mask & INTEL_GEN_MASK((s), (e))))
29012899

29022900
/*
29032901
* Return true if revision is in range [since,until] inclusive.

0 commit comments

Comments
 (0)