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 <scottl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2241807
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Scott Long
2019-11-18 11:19:36 -08:00
committed by Alex Waterman
parent 0984189be4
commit 44a28012de

View File

@@ -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];
}