From 63e6e8ee3ee9ce01b1f7d4c0014bb589df105d71 Mon Sep 17 00:00:00 2001 From: Srirangan Date: Wed, 1 Aug 2018 13:02:14 +0530 Subject: gpu: nvgpu: common: Fix MISRA 15.6 violations This fixes errors due to single statement loop bodies without braces, which is part of Rule 15.6 of MISRA. This patch covers in gpu/nvgpu/common/ JIRA NVGPU-989 Change-Id: Ic6a98a1cd04e4524dabf650e2f6e73c6b5a1db9d Signed-off-by: Srirangan Reviewed-on: https://git-master.nvidia.com/r/1786207 Reviewed-by: svc-misra-checker Reviewed-by: Adeel Raza GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/mm/buddy_allocator.c | 11 +++++++---- drivers/gpu/nvgpu/common/mm/gmmu.c | 3 ++- drivers/gpu/nvgpu/common/mm/lockless_allocator.c | 5 +++-- drivers/gpu/nvgpu/common/mm/vm.c | 12 ++++++++---- 4 files changed, 20 insertions(+), 11 deletions(-) (limited to 'drivers/gpu/nvgpu/common/mm') diff --git a/drivers/gpu/nvgpu/common/mm/buddy_allocator.c b/drivers/gpu/nvgpu/common/mm/buddy_allocator.c index b986b29f..5a0a28cb 100644 --- a/drivers/gpu/nvgpu/common/mm/buddy_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/buddy_allocator.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -214,8 +214,9 @@ static int balloc_init_lists(struct nvgpu_buddy_allocator *a) bend = a->end; /* First make sure the LLs are valid. */ - for (i = 0; i < GPU_BALLOC_ORDER_LIST_LEN; i++) + for (i = 0; i < GPU_BALLOC_ORDER_LIST_LEN; i++) { nvgpu_init_list_node(balloc_get_order_list(a, i)); + } while (bstart < bend) { order = __balloc_max_order_in(a, bstart, bend); @@ -505,8 +506,9 @@ static u64 __balloc_do_alloc(struct nvgpu_buddy_allocator *a, split_order = order; while (split_order <= a->max_order && - !(bud = __balloc_find_buddy(a, split_order, pte_size))) + !(bud = __balloc_find_buddy(a, split_order, pte_size))) { split_order++; + } /* Out of memory! */ if (!bud) @@ -885,8 +887,9 @@ static u64 __nvgpu_balloc_fixed_buddy(struct nvgpu_allocator *__a, balloc_alloc_fixed(a, falloc); nvgpu_list_for_each_entry(bud, &falloc->buddies, - nvgpu_buddy, buddy_entry) + nvgpu_buddy, buddy_entry) { real_bytes += (bud->end - bud->start); + } a->bytes_alloced += len; a->bytes_alloced_real += real_bytes; diff --git a/drivers/gpu/nvgpu/common/mm/gmmu.c b/drivers/gpu/nvgpu/common/mm/gmmu.c index 78b30850..4e723e2e 100644 --- a/drivers/gpu/nvgpu/common/mm/gmmu.c +++ b/drivers/gpu/nvgpu/common/mm/gmmu.c @@ -861,8 +861,9 @@ static int __nvgpu_locate_pte(struct gk20a *g, struct vm_gk20a *vm, pte_size = (u32)(l->entry_size / sizeof(u32)); if (data) { - for (i = 0; i < pte_size; i++) + for (i = 0; i < pte_size; i++) { data[i] = nvgpu_mem_rd32(g, pd->mem, pte_base + i); + } } if (pd_out) diff --git a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c index 5f48d606..4a3d6c9d 100644 --- a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -194,8 +194,9 @@ int nvgpu_lockless_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, /* chain the elements together to form the initial free list */ nr_nodes = (int)count; - for (i = 0; i < nr_nodes; i++) + for (i = 0; i < nr_nodes; i++) { a->next[i] = i + 1; + } a->next[nr_nodes - 1] = -1; a->base = base; diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c index 3d9dd174..3b682e28 100644 --- a/drivers/gpu/nvgpu/common/mm/vm.c +++ b/drivers/gpu/nvgpu/common/mm/vm.c @@ -75,8 +75,9 @@ int nvgpu_vm_pde_coverage_bit_count(struct vm_gk20a *vm) * heirarchy: the last level is PTEs so we really want the level * before that which is the last level of PDEs. */ - while (vm->mmu_levels[final_pde_level + 2].update_entry) + while (vm->mmu_levels[final_pde_level + 2].update_entry) { final_pde_level++; + } return vm->mmu_levels[final_pde_level].lo_bit[0]; } @@ -93,9 +94,10 @@ static void __nvgpu_vm_free_entries(struct vm_gk20a *vm, } if (pd->entries) { - for (i = 0; i < pd->num_entries; i++) + for (i = 0; i < pd->num_entries; i++) { __nvgpu_vm_free_entries(vm, &pd->entries[i], level + 1); + } nvgpu_vfree(vm->mm->g, pd->entries); pd->entries = NULL; } @@ -112,8 +114,9 @@ static void nvgpu_vm_free_entries(struct vm_gk20a *vm, if (!pdb->entries) return; - for (i = 0; i < pdb->num_entries; i++) + for (i = 0; i < pdb->num_entries; i++) { __nvgpu_vm_free_entries(vm, &pdb->entries[i], 1); + } nvgpu_vfree(g, pdb->entries); pdb->entries = NULL; @@ -750,8 +753,9 @@ void nvgpu_vm_put_buffers(struct vm_gk20a *vm, nvgpu_vm_mapping_batch_start(&batch); vm->kref_put_batch = &batch; - for (i = 0; i < num_buffers; ++i) + for (i = 0; i < num_buffers; ++i) { nvgpu_ref_put(&mapped_buffers[i]->ref, __nvgpu_vm_unmap_ref); + } vm->kref_put_batch = NULL; nvgpu_vm_mapping_batch_finish_locked(vm, &batch); -- cgit v1.2.2