[Nouveau] [PATCH v2 5/15] pmu: add nvkm_pmu_ctor() function
Alexandre Courbot
acourbot at nvidia.com
Tue Dec 13 08:11:21 UTC 2016
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 at 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(-)
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 **);
--
git-series 0.8.10
More information about the Nouveau
mailing list