[Nouveau] [PATCH v4 23/33] pmu: add nvkm_pmu_ctor function

Alexandre Courbot acourbot at nvidia.com
Mon Nov 21 08:29:20 UTC 2016


Add a constructor function that can be called by our gm200
implementation.

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

diff --git a/drm/nouveau/nvkm/subdev/pmu/base.c b/drm/nouveau/nvkm/subdev/pmu/base.c
index e611ce80f8ef..c7f432ca79ca 100644
--- a/drm/nouveau/nvkm/subdev/pmu/base.c
+++ b/drm/nouveau/nvkm/subdev/pmu/base.c
@@ -128,6 +128,15 @@ nvkm_pmu = {
 	.intr = nvkm_pmu_intr,
 };
 
+void nvkm_pmu_ctor(const struct nvkm_pmu_func *func, struct nvkm_device *device,
+		   int index, struct nvkm_pmu *pmu)
+{
+	nvkm_subdev_ctor(&nvkm_pmu, device, index, &pmu->subdev);
+	pmu->func = func;
+	INIT_WORK(&pmu->recv.work, nvkm_pmu_recv);
+	init_waitqueue_head(&pmu->recv.wait);
+}
+
 int
 nvkm_pmu_new_(const struct nvkm_pmu_func *func, struct nvkm_device *device,
 	      int index, struct nvkm_pmu **ppmu)
@@ -135,9 +144,6 @@ nvkm_pmu_new_(const struct nvkm_pmu_func *func, struct nvkm_device *device,
 	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);
-	init_waitqueue_head(&pmu->recv.wait);
+	nvkm_pmu_ctor(func, device, index, pmu);
 	return 0;
 }
diff --git a/drm/nouveau/nvkm/subdev/pmu/priv.h b/drm/nouveau/nvkm/subdev/pmu/priv.h
index 2e2179a4ad17..12b81ae1b114 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,
+		   struct nvkm_pmu *);
 int nvkm_pmu_new_(const struct nvkm_pmu_func *, struct nvkm_device *,
 		  int index, struct nvkm_pmu **);
 
-- 
git-series 0.8.10


More information about the Nouveau mailing list