mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 02:22:34 +03:00
gpu: nvgpu: container_of() changes to clk arb code
The container_of() macro used in nvgpu produces the following
set of MISRA required rule violations:
* Rule 11.3 : A cast shall not be performed between a pointer to
object type and a pointer to a different object type.
* Rule 11.8 : A cast shall not remove any const or volatile
qualification from the type pointed to be a pointer.
* Rule 20.7 : Expressions resulting from the expansion of macro
parameters shall be enclosed in parentheses.
Using the same modified implementation of container_of() as that
used in the nvgpu_list_node/nvgpu_rbtree_node routines eliminates
the Rule 11.8 and Rule 20.7 violations and exchanges the Rule 11.3
violation with an advisory Rule 11.4 violation.
This patch uses that same equivalent implementation in two new
(static) functions that are used to replace references to
container_of() references in clk arb code:
* nvgpu_clk_dev_from_refcount
* nvgpu_clk_session_from_refcount
It should be noted that replacement functions still contain
potentially dangerous (and non-MISRA compliant code) and that it is
expected that deviation requests will be filed for the new advisory
rule violations accordingly.
JIRA NVGPU-782
Change-Id: I612990e9c27f10d0ce3ac76729529aa1eb15d42a
Signed-off-by: Scott Long <scottl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1993796
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Adeel Raza <araza@nvidia.com>
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:
committed by
mobile promotions
parent
35ea60fe80
commit
0837b6988c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2016-2019, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -669,10 +669,16 @@ int nvgpu_clk_arb_init_session(struct gk20a *g,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct nvgpu_clk_dev *
|
||||
nvgpu_clk_dev_from_refcount(struct nvgpu_ref *refcount)
|
||||
{
|
||||
return (struct nvgpu_clk_dev *)
|
||||
((uintptr_t)refcount - offsetof(struct nvgpu_clk_dev, refcount));
|
||||
};
|
||||
|
||||
void nvgpu_clk_arb_free_fd(struct nvgpu_ref *refcount)
|
||||
{
|
||||
struct nvgpu_clk_dev *dev = container_of(refcount,
|
||||
struct nvgpu_clk_dev, refcount);
|
||||
struct nvgpu_clk_dev *dev = nvgpu_clk_dev_from_refcount(refcount);
|
||||
struct nvgpu_clk_session *session = dev->session;
|
||||
struct gk20a *g = session->g;
|
||||
|
||||
@@ -682,10 +688,17 @@ void nvgpu_clk_arb_free_fd(struct nvgpu_ref *refcount)
|
||||
nvgpu_kfree(g, dev);
|
||||
}
|
||||
|
||||
static struct nvgpu_clk_session *
|
||||
nvgpu_clk_session_from_refcount(struct nvgpu_ref *refcount)
|
||||
{
|
||||
return (struct nvgpu_clk_session *)
|
||||
((uintptr_t)refcount - offsetof(struct nvgpu_clk_session, refcount));
|
||||
};
|
||||
|
||||
void nvgpu_clk_arb_free_session(struct nvgpu_ref *refcount)
|
||||
{
|
||||
struct nvgpu_clk_session *session = container_of(refcount,
|
||||
struct nvgpu_clk_session, refcount);
|
||||
struct nvgpu_clk_session *session =
|
||||
nvgpu_clk_session_from_refcount(refcount);
|
||||
struct nvgpu_clk_arb *arb = session->g->clk_arb;
|
||||
struct gk20a *g = session->g;
|
||||
struct nvgpu_clk_dev *dev, *tmp;
|
||||
|
||||
Reference in New Issue
Block a user