[v2,5/15] pmu: add nvkm_pmu_ctor() function

Submitted by Alexandre Courbot on Dec. 13, 2016, 8:11 a.m.

Details

Message ID d6c74c1648af7e38cb7092d2098c34ec6c7b92d3.1481616662.git-series.acourbot@nvidia.com
State New
Headers show
Series "Falcon library" ( rev: 3 ) in Nouveau

Not browsing as part of any series.

Commit Message

Alexandre Courbot Dec. 13, 2016, 8:11 a.m.
Add a PMU constructor so implementations that extend the nvkm_pmu
structure can have all base members properly initialized.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drm/nouveau/nvkm/subdev/pmu/base.c | 21 +++++++++++++++------
 drm/nouveau/nvkm/subdev/pmu/priv.h |  2 ++
 2 files changed, 17 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drm/nouveau/nvkm/subdev/pmu/base.c b/drm/nouveau/nvkm/subdev/pmu/base.c
index 1e645eec1951..6db1ee45e610 100644
--- a/drm/nouveau/nvkm/subdev/pmu/base.c
+++ b/drm/nouveau/nvkm/subdev/pmu/base.c
@@ -128,13 +128,10 @@  nvkm_pmu = {
 	.intr = nvkm_pmu_intr,
 };
 
-int
-nvkm_pmu_new_(const struct nvkm_pmu_func *func, struct nvkm_device *device,
-	      int index, struct nvkm_pmu **ppmu)
+void
+nvkm_pmu_ctor(const struct nvkm_pmu_func *func, struct nvkm_device *device,
+	      int index, struct nvkm_pmu *pmu)
 {
-	struct nvkm_pmu *pmu;
-	if (!(pmu = *ppmu = kzalloc(sizeof(*pmu), GFP_KERNEL)))
-		return -ENOMEM;
 	nvkm_subdev_ctor(&nvkm_pmu, device, index, &pmu->subdev);
 	pmu->func = func;
 	INIT_WORK(&pmu->recv.work, nvkm_pmu_recv);
@@ -143,5 +140,17 @@  nvkm_pmu_new_(const struct nvkm_pmu_func *func, struct nvkm_device *device,
 	nvkm_falcon_ctor(&pmu->subdev, &nvkm_falcon_v1_func, "PMU", 0x10a000,
 			 &pmu->falcon);
 
+}
+
+int
+nvkm_pmu_new_(const struct nvkm_pmu_func *func, struct nvkm_device *device,
+	      int index, struct nvkm_pmu **ppmu)
+{
+	struct nvkm_pmu *pmu;
+	if (!(pmu = *ppmu = kzalloc(sizeof(*pmu), GFP_KERNEL)))
+		return -ENOMEM;
+
+	nvkm_pmu_ctor(func, device, index, *ppmu);
+
 	return 0;
 }
diff --git a/drm/nouveau/nvkm/subdev/pmu/priv.h b/drm/nouveau/nvkm/subdev/pmu/priv.h
index 2e2179a4ad17..1eda37b787f7 100644
--- a/drm/nouveau/nvkm/subdev/pmu/priv.h
+++ b/drm/nouveau/nvkm/subdev/pmu/priv.h
@@ -4,6 +4,8 @@ 
 #include <subdev/pmu.h>
 #include <subdev/pmu/fuc/os.h>
 
+void nvkm_pmu_ctor(const struct nvkm_pmu_func *, struct nvkm_device *,
+		   int index, struct nvkm_pmu *);
 int nvkm_pmu_new_(const struct nvkm_pmu_func *, struct nvkm_device *,
 		  int index, struct nvkm_pmu **);