Skip to content

Commit

Permalink
drm/nouveau/core: add nvkm_subdev_new_() for bare subdevs
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
  • Loading branch information
Ben Skeggs committed May 22, 2020
1 parent fa4f4c2 commit f02ca84
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h
Original file line number Diff line number Diff line change
@@ -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 **);
11 changes: 11 additions & 0 deletions drivers/gpu/drm/nouveau/nvkm/core/subdev.c
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit f02ca84

Please sign in to comment.