summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i915/i915_drv.h
diff options
context:
space:
mode:
authorMatthew Auld <matthew.auld@intel.com>2016-12-13 23:32:21 +0300
committerChris Wilson <chris@chris-wilson.co.uk>2016-12-17 00:19:16 +0300
commit86e61735710902535ebd00decc035f5e129a377e (patch)
tree05f21a053245ed8728e903fab750fbfc3f6a8dac /drivers/gpu/drm/i915/i915_drv.h
parent7a0499a4b8c2e6850256b1d86c87d2deddce99b0 (diff)
downloadlinux-86e61735710902535ebd00decc035f5e129a377e.tar.xz
drm/i915: introduce range_overflows utility macros
In a number places we hand-roll the overflow sanity check for ranges, so roll that into single macro, conceived by Chris, along with its typed variant. Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Suggested-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Matthew Auld <matthew.auld@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/20161213203222.32564-3-matthew.auld@intel.com Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_drv.h')
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 20bc04d5e617..085c8ecd09b5 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -218,6 +218,18 @@ static inline const char *enableddisabled(bool v)
return v ? "enabled" : "disabled";
}
+#define range_overflows(start, size, max) ({ \
+ typeof(start) start__ = (start); \
+ typeof(size) size__ = (size); \
+ typeof(max) max__ = (max); \
+ (void)(&start__ == &size__); \
+ (void)(&start__ == &max__); \
+ start__ > max__ || size__ > max__ - start__; \
+})
+
+#define range_overflows_t(type, start, size, max) \
+ range_overflows((type)(start), (type)(size), (type)(max))
+
enum pipe {
INVALID_PIPE = -1,
PIPE_A = 0,