drm/nouveau/pmu: add nvkm_pmu_ctor() function
authorAlexandre Courbot <acourbot@nvidia.com>
Tue, 13 Dec 2016 08:11:21 +0000 (17:11 +0900)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 17 Feb 2017 05:14:30 +0000 (15:14 +1000)
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>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/base.c
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/priv.h

index e611ce8..b7edde4 100644 (file)
@@ -129,15 +129,22 @@ nvkm_pmu = {
 };
 
 int
-nvkm_pmu_new_(const struct nvkm_pmu_func *func, struct nvkm_device *device,
-             int index, struct nvkm_pmu **ppmu)
+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);
        init_waitqueue_head(&pmu->recv.wait);
        return 0;
 }
+
+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;
+       return nvkm_pmu_ctor(func, device, index, *ppmu);
+}
index 2e2179a..096cba0 100644 (file)
@@ -4,6 +4,8 @@
 #include <subdev/pmu.h>
 #include <subdev/pmu/fuc/os.h>
 
+int 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 **);