drm/nouveau/mc: allow construction of subclassed device

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
This commit is contained in:
Ben Skeggs 2016-05-30 09:23:06 +10:00
parent 3560e1703f
commit d6adbe949d
2 changed files with 11 additions and 4 deletions

View File

@ -148,16 +148,21 @@ nvkm_mc = {
.fini = nvkm_mc_fini,
};
void
nvkm_mc_ctor(const struct nvkm_mc_func *func, struct nvkm_device *device,
int index, struct nvkm_mc *mc)
{
nvkm_subdev_ctor(&nvkm_mc, device, index, &mc->subdev);
mc->func = func;
}
int
nvkm_mc_new_(const struct nvkm_mc_func *func, struct nvkm_device *device,
int index, struct nvkm_mc **pmc)
{
struct nvkm_mc *mc;
if (!(mc = *pmc = kzalloc(sizeof(*mc), GFP_KERNEL)))
return -ENOMEM;
nvkm_subdev_ctor(&nvkm_mc, device, index, &mc->subdev);
mc->func = func;
nvkm_mc_ctor(func, device, index, *pmc);
return 0;
}

View File

@ -3,6 +3,8 @@
#define nvkm_mc(p) container_of((p), struct nvkm_mc, subdev)
#include <subdev/mc.h>
void nvkm_mc_ctor(const struct nvkm_mc_func *, struct nvkm_device *,
int index, struct nvkm_mc *);
int nvkm_mc_new_(const struct nvkm_mc_func *, struct nvkm_device *,
int index, struct nvkm_mc **);