Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe52e597 authored by Joonas Lahtinen's avatar Joonas Lahtinen
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: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
Reviewed-by: default avatarChris 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
parent 0d0c2794
Loading
Loading
Loading
Loading
+10 −12
Original line number Original line Diff line number Diff line
@@ -2881,23 +2881,21 @@ intel_info(const struct drm_i915_private *dev_priv)
#define INTEL_REVID(dev_priv)	((dev_priv)->drm.pdev->revision)
#define INTEL_REVID(dev_priv)	((dev_priv)->drm.pdev->revision)


#define GEN_FOREVER (0)
#define GEN_FOREVER (0)

#define INTEL_GEN_MASK(s, e) ( \
	BUILD_BUG_ON_ZERO(!__builtin_constant_p(s)) + \
	BUILD_BUG_ON_ZERO(!__builtin_constant_p(e)) + \
	GENMASK((e) != GEN_FOREVER ? (e) - 1 : BITS_PER_LONG - 1, \
		(s) != GEN_FOREVER ? (s) - 1 : 0) \
)

/*
/*
 * Returns true if Gen is in inclusive range [Start, End].
 * Returns true if Gen is in inclusive range [Start, End].
 *
 *
 * Use GEN_FOREVER for unbound start and or end.
 * Use GEN_FOREVER for unbound start and or end.
 */
 */
#define IS_GEN(dev_priv, s, e) ({ \
#define IS_GEN(dev_priv, s, e) \
	unsigned int __s = (s), __e = (e); \
	(!!((dev_priv)->info.gen_mask & INTEL_GEN_MASK((s), (e))))
	BUILD_BUG_ON(!__builtin_constant_p(s)); \
	BUILD_BUG_ON(!__builtin_constant_p(e)); \
	if ((__s) != GEN_FOREVER) \
		__s = (s) - 1; \
	if ((__e) == GEN_FOREVER) \
		__e = BITS_PER_LONG - 1; \
	else \
		__e = (e) - 1; \
	!!((dev_priv)->info.gen_mask & GENMASK((__e), (__s))); \
})


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