From 19d99a71014d7a6d446623957f3fc87fc41fd0c4 Mon Sep 17 00:00:00 2001 From: Philip Elcan Date: Wed, 8 May 2019 10:16:46 -0400 Subject: [PATCH] gpu: nvgpu: init: fix MISRA 13.5 violation MISRA Rule 13.5 states that the right hand operand of a logical && or || operator shall not have persistent side effects. Update the while loop in gk20a_wait_for_idle() to comply. JIRA NVGPU-3318 Change-Id: I3e51361914c298416bab1f2f7500d743ce409c8b Signed-off-by: Philip Elcan Reviewed-on: https://git-master.nvidia.com/r/2114658 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/init/nvgpu_init.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/nvgpu/common/init/nvgpu_init.c b/drivers/gpu/nvgpu/common/init/nvgpu_init.c index d68b2ed9b..834d4bebb 100644 --- a/drivers/gpu/nvgpu/common/init/nvgpu_init.c +++ b/drivers/gpu/nvgpu/common/init/nvgpu_init.c @@ -514,15 +514,21 @@ int gk20a_wait_for_idle(struct gk20a *g) { int wait_length = 150; /* 3 second overall max wait. */ int target_usage_count = 0; + bool done = false; if (g == NULL) { return -ENODEV; } - while ((nvgpu_atomic_read(&g->usage_count) != target_usage_count) - && (wait_length-- >= 0)) { - nvgpu_msleep(20); - } + do { + if (nvgpu_atomic_read(&g->usage_count) == target_usage_count) { + done = true; + } else if (wait_length-- < 0) { + done = true; + } else { + nvgpu_msleep(20); + } + } while (!done); if (wait_length < 0) { nvgpu_warn(g, "Timed out waiting for idle (%d)!\n",