From 44a28012deed402f2f55f8b296b883424a868db5 Mon Sep 17 00:00:00 2001 From: Scott Long Date: Mon, 18 Nov 2019 11:19:36 -0800 Subject: [PATCH] gpu: nvgpu: fix MISRA 5.9 violation MISRA Advisory Rule 5.9 states that identifiers that define objects or functions with internal linkage should be unique. While it is permissible for an inline function with internal linkage to be defined in a single header file the same is not true for data objects. This change moves the aperture_name[] string table to within the nvgpu_aperture_str() function to comply with this advisory rule. Because the size of the table is relatively small (< 40 bytes for the strings) the storage class is changed to automatic. Jira NVGPU-3178 Change-Id: I9efedc083511a8ecb0ca7e5fbf577030cddfd76b Signed-off-by: Scott Long Reviewed-on: https://git-master.nvidia.com/r/2241807 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h index 5ddad109b..a8344c7ee 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h @@ -205,14 +205,6 @@ nvgpu_mem_from_clear_list_entry(struct nvgpu_list_node *node) }; #endif -static const char *aperture_name[APERTURE_MAX_ENUM + 1] = { - [APERTURE_INVALID] = "INVAL", - [APERTURE_SYSMEM] = "SYSTEM", - [APERTURE_SYSMEM_COH] = "SYSCOH", - [APERTURE_VIDMEM] = "VIDMEM", - [APERTURE_MAX_ENUM] = "UNKNOWN", -}; - /** * @brief Convert aperture type to string. * @@ -222,6 +214,14 @@ static const char *aperture_name[APERTURE_MAX_ENUM + 1] = { */ static inline const char *nvgpu_aperture_str(enum nvgpu_aperture aperture) { + const char *aperture_name[APERTURE_MAX_ENUM + 1] = { + [APERTURE_INVALID] = "INVAL", + [APERTURE_SYSMEM] = "SYSTEM", + [APERTURE_SYSMEM_COH] = "SYSCOH", + [APERTURE_VIDMEM] = "VIDMEM", + [APERTURE_MAX_ENUM] = "UNKNOWN", + }; + if ((aperture < APERTURE_INVALID) || (aperture >= APERTURE_MAX_ENUM)) { return aperture_name[APERTURE_MAX_ENUM]; }