[Intel-gfx] [PATCH] drm/i915: Simplify mmio_reg_cmp
Tvrtko Ursulin
tursulin at ursulin.net
Fri Nov 3 13:10:42 UTC 2017
From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
If we remove one condition from the comparison mmio_reg_cmp becomes
smaller and compiler can fully inline it. This grows the text a little
bit but avoids the function call.
We depend, and verify, on the fact that addresses of mmio registers fit
in a signed integer.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
drivers/gpu/drm/i915/intel_uncore.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
index 0a6d952a2df1..a68a9960c928 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -865,12 +865,9 @@ static int mmio_reg_cmp(u32 key, const i915_reg_t *reg)
{
u32 offset = i915_mmio_reg_offset(*reg);
- if (key < offset)
- return -1;
- else if (key > offset)
- return 1;
- else
- return 0;
+ GEM_BUG_ON(key > (u32)INT_MAX || offset > (u32)INT_MAX);
+
+ return (int)key - (int)offset;
}
static bool is_gen8_shadowed(u32 offset)
--
2.9.5
More information about the Intel-gfx
mailing list