From 7fc3c3822db79cc0e44887c73d77c2450efe4b88 Mon Sep 17 00:00:00 2001 From: ajesh Date: Mon, 13 Apr 2020 15:45:07 +0530 Subject: [PATCH] gpu: nvgpu: reduce the ccm for thread unit Reduce the code complexity of function nvgpu_thread_create_priority in Thread unit. Jira NVGPU-4987 Change-Id: I85da527c3d8dbbe37c5428e5bded9ed19b299613 Signed-off-by: ajesh Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2327865 Reviewed-by: automaticguardword Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Alex Waterman Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/posix/thread.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/nvgpu/os/posix/thread.c b/drivers/gpu/nvgpu/os/posix/thread.c index 09bb4f5c2..e971f4221 100644 --- a/drivers/gpu/nvgpu/os/posix/thread.c +++ b/drivers/gpu/nvgpu/os/posix/thread.c @@ -221,36 +221,24 @@ int nvgpu_thread_create_priority(struct nvgpu_thread *thread, ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); if (ret != 0) { - if ((pthread_attr_destroy(&attr)) != 0) { - nvgpu_info(NULL, "Thread attr destroy error"); - } - return ret; + goto attr_destroy; } ret = pthread_attr_setschedpolicy(&attr, SCHED_RR); if (ret != 0) { - if ((pthread_attr_destroy(&attr)) != 0) { - nvgpu_info(NULL, "Thread attr destroy error"); - } - return ret; + goto attr_destroy; } param.sched_priority = priority; ret = pthread_attr_setschedparam(&attr, ¶m); if (ret != 0) { - if ((pthread_attr_destroy(&attr)) != 0) { - nvgpu_info(NULL, "Thread attr destroy error"); - } - return ret; + goto attr_destroy; } ret = pthread_create(&thread->thread, &attr, nvgpu_posix_thread_wrapper, &thread->nvgpu); if (ret != 0) { - if ((pthread_attr_destroy(&attr)) != 0) { - nvgpu_info(NULL, "Thread attr destroy error"); - } - return ret; + goto attr_destroy; } #ifdef _GNU_SOURCE @@ -283,6 +271,13 @@ int nvgpu_thread_create_priority(struct nvgpu_thread *thread, #endif return 0; + +attr_destroy: + if ((pthread_attr_destroy(&attr)) != 0) { + nvgpu_info(NULL, "Thread attr destroy error"); + } + + return ret; } void nvgpu_thread_stop(struct nvgpu_thread *thread)