diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2015-08-20 14:54:15 +1000 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2015-08-28 12:40:30 +1000 |
commit | e781dc8f6cebf69bd410eb652a13e0a3797d71fe (patch) | |
tree | f7ad33f3f2b7d8d8bb0396e338113d5ef4c64d28 /drivers/gpu/drm/nouveau/nvkm/engine/device/base.c | |
parent | 76ecea5b4b9383edde2bfe49e59e76fec4e21aa4 (diff) | |
download | lwn-e781dc8f6cebf69bd410eb652a13e0a3797d71fe.tar.gz lwn-e781dc8f6cebf69bd410eb652a13e0a3797d71fe.zip |
drm/nouveau/device: tidy ctor/dtor interfaces
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nvkm/engine/device/base.c')
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/engine/device/base.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c index e08418436e0c..c943a2ad26c7 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c @@ -666,23 +666,6 @@ fail: return ret; } -static void -nvkm_device_dtor(struct nvkm_object *object) -{ - struct nvkm_device *device = (void *)object; - - nvkm_event_fini(&device->event); - - mutex_lock(&nv_devices_mutex); - list_del(&device->head); - mutex_unlock(&nv_devices_mutex); - - if (device->pri) - iounmap(device->pri); - - nvkm_engine_destroy(&device->engine); -} - resource_size_t nv_device_resource_start(struct nvkm_device *device, unsigned int bar) { @@ -728,16 +711,34 @@ static struct nvkm_oclass nvkm_device_oclass = { .handle = NV_ENGINE(DEVICE, 0x00), .ofuncs = &(struct nvkm_ofuncs) { - .dtor = nvkm_device_dtor, .init = nvkm_device_init, .fini = nvkm_device_fini, }, }; +void +nvkm_device_del(struct nvkm_device **pdevice) +{ + struct nvkm_device *device = *pdevice; + if (device) { + nvkm_event_fini(&device->event); + + mutex_lock(&nv_devices_mutex); + list_del(&device->head); + mutex_unlock(&nv_devices_mutex); + + if (device->pri) + iounmap(device->pri); + + nvkm_engine_destroy(&device->engine); + *pdevice = NULL; + } +} + int -nvkm_device_create_(void *dev, enum nv_bus_type type, u64 name, - const char *sname, const char *cfg, const char *dbg, - int length, void **pobject) +nvkm_device_new(void *dev, enum nv_bus_type type, u64 name, + const char *sname, const char *cfg, const char *dbg, + struct nvkm_device **pdevice) { struct nvkm_device *device; int ret = -EEXIST; @@ -748,9 +749,9 @@ nvkm_device_create_(void *dev, enum nv_bus_type type, u64 name, goto done; } - ret = nvkm_engine_create_(NULL, NULL, &nvkm_device_oclass, true, - "DEVICE", "device", length, pobject); - device = *pobject; + ret = nvkm_engine_create(NULL, NULL, &nvkm_device_oclass, true, + "DEVICE", "device", &device); + *pdevice = device; if (ret) goto done; |