In function amdgpu_cs_parser_bos, declare the variables in the beginning
of the function and not during the initialization.

Signed-off-by: Sunil Khatri <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 31eea1c7dac3..a9bdc368c981 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -854,6 +854,9 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
        struct amdgpu_vm *vm = &fpriv->vm;
        struct amdgpu_bo_list_entry *e;
        struct drm_gem_object *obj;
+       struct amdgpu_bo *bo;
+       struct mm_struct *usermm;
+       bool userpage_invalidated;
        unsigned long index;
        unsigned int i;
        int r;
@@ -882,14 +885,12 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser 
*p,
         * amdgpu_ttm_backend_bind() to flush and invalidate new pages
         */
        amdgpu_bo_list_for_each_userptr_entry(e, p->bo_list) {
-               bool userpage_invalidated = false;
-               struct amdgpu_bo *bo = e->bo;
+               userpage_invalidated = false;
+               bo = e->bo;
                e->range = kzalloc(sizeof(*e->range), GFP_KERNEL);
                if (unlikely(!e->range))
                        return -ENOMEM;
 
-               int i;
-
                r = amdgpu_ttm_tt_get_user_pages(bo, e->range);
                if (r)
                        goto out_free_user_pages;
@@ -930,8 +931,6 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
        }
 
        amdgpu_bo_list_for_each_userptr_entry(e, p->bo_list) {
-               struct mm_struct *usermm;
-
                usermm = amdgpu_ttm_tt_get_usermm(e->bo->tbo.ttm);
                if (usermm && usermm != current->mm) {
                        r = -EPERM;
-- 
2.34.1

Reply via email to