[Intel-gfx] [PATCH] drm/i915/gem: Promote 'remain' to unsigned long
Chris Wilson
chris at chris-wilson.co.uk
Tue Apr 7 08:59:30 UTC 2020
Tidy the code by casting remain to unsigned long once for the duration
of eb_relocate_vma()
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index d9ab517bbce9..c95dc09c4c93 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -1508,11 +1508,11 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
struct drm_i915_gem_relocation_entry stack[N_RELOC(512)];
struct drm_i915_gem_relocation_entry __user *urelocs;
const struct drm_i915_gem_exec_object2 *entry = ev->exec;
- unsigned int remain;
+ unsigned long remain;
urelocs = u64_to_user_ptr(entry->relocs_ptr);
remain = entry->relocation_count;
- if (unlikely((unsigned long)remain > N_RELOC(ULONG_MAX)))
+ if (unlikely(remain > N_RELOC(ULONG_MAX)))
return -EINVAL;
/*
@@ -1520,13 +1520,12 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
* to read. However, if the array is not writable the user loses
* the updated relocation values.
*/
- if (unlikely(!access_ok(urelocs, remain*sizeof(*urelocs))))
+ if (unlikely(!access_ok(urelocs, remain * sizeof(*urelocs))))
return -EFAULT;
do {
struct drm_i915_gem_relocation_entry *r = stack;
- unsigned int count =
- min_t(unsigned int, remain, ARRAY_SIZE(stack));
+ unsigned int count = min(remain, ARRAY_SIZE(stack));
unsigned int copied;
/*
--
2.20.1
More information about the Intel-gfx
mailing list