drm/nouveau/core: add nvkm_subdev_new_() for bare subdevs
authorBen Skeggs <bskeggs@redhat.com>
Tue, 11 Feb 2020 07:34:58 +0000 (17:34 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 22 May 2020 01:13:48 +0000 (11:13 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h
drivers/gpu/drm/nouveau/nvkm/core/subdev.c

index 1218f28..76288c6 100644 (file)
@@ -24,6 +24,8 @@ struct nvkm_subdev_func {
 };
 
 extern const char *nvkm_subdev_name[NVKM_SUBDEV_NR];
+int nvkm_subdev_new_(const struct nvkm_subdev_func *, struct nvkm_device *,
+                    int index, struct nvkm_subdev **);
 void nvkm_subdev_ctor(const struct nvkm_subdev_func *, struct nvkm_device *,
                      int index, struct nvkm_subdev *);
 void nvkm_subdev_del(struct nvkm_subdev **);
index 79a8f9d..49d468b 100644 (file)
@@ -221,3 +221,14 @@ nvkm_subdev_ctor(const struct nvkm_subdev_func *func,
        __mutex_init(&subdev->mutex, name, &nvkm_subdev_lock_class[index]);
        subdev->debug = nvkm_dbgopt(device->dbgopt, name);
 }
+
+int
+nvkm_subdev_new_(const struct nvkm_subdev_func *func,
+                struct nvkm_device *device, int index,
+                struct nvkm_subdev **psubdev)
+{
+       if (!(*psubdev = kzalloc(sizeof(**psubdev), GFP_KERNEL)))
+               return -ENOMEM;
+       nvkm_subdev_ctor(func, device, index, *psubdev);
+       return 0;
+}