From 06dadf216e97f4ec5d6ccdad1179a32ad6acb2e8 Mon Sep 17 00:00:00 2001 From: Scott Long Date: Wed, 21 Nov 2018 09:09:46 -0800 Subject: [PATCH] gpu: nvgpu: MISRA 11.8 fix to gk20a_from_pmu() MISRA Rule 11.8 states that a cast shall not remove any const or volatile qualification from the type pointed to by a pointer. The linux kernel's container_of() macro contains such a violation as it generates a pointer to a caller-specified (and so possibly non-const qualified) type by casting an internally declared const pointer. The gk20a_from_pmu() uses the container_of() macro to convert from a struct nvgpu_pmu pointer to a struct gk20a pointer. The struct nvgpu_pmu has a back pointer to struct gk20a already however and so this change modifies gk20a_from_gpu() to just return this back pointer rather than use container_of(). JIRA NVGPU-862 Change-Id: If0e2481c1cf104c2fa6b89334e20e75705bf9c44 Signed-off-by: Scott Long Reviewed-on: https://git-master.nvidia.com/r/1955540 Reviewed-by: svc-mobile-coverity Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/pmu/pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/common/pmu/pmu.c b/drivers/gpu/nvgpu/common/pmu/pmu.c index f39d1da6e..593d52b36 100644 --- a/drivers/gpu/nvgpu/common/pmu/pmu.c +++ b/drivers/gpu/nvgpu/common/pmu/pmu.c @@ -665,7 +665,7 @@ void nvgpu_pmu_surface_free(struct gk20a *g, struct nvgpu_mem *mem) struct gk20a *gk20a_from_pmu(struct nvgpu_pmu *pmu) { - return container_of(pmu, struct gk20a, pmu); + return pmu->g; } int nvgpu_pmu_wait_ready(struct gk20a *g)