diff options
author | 2008-11-28 13:43:47 +1000 | |
---|---|---|
committer | 2008-12-29 17:47:21 +1000 | |
commit | e7f7ab45ebcb54fd5f814ea15ea079e079662f67 (patch) | |
tree | 53e8206501c0b7a00831ea084b52664f7899d1c0 /drivers/gpu/drm/drm_drv.c | |
parent | Linux 2.6.28 (diff) | |
download | linux-e7f7ab45ebcb54fd5f814ea15ea079e079662f67.tar.gz linux-e7f7ab45ebcb54fd5f814ea15ea079e079662f67.tar.bz2 linux-e7f7ab45ebcb54fd5f814ea15ea079e079662f67.zip |
drm: cleanup exit path for module unload
The current sub-module unload exit path is a mess, it tries
to abuse the idr. Just keep a list of devices per driver struct
and free them in-order on rmmod.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_drv.c')
-rw-r--r-- | drivers/gpu/drm/drm_drv.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 996097acb5e7..3cb87a932b33 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -263,6 +263,8 @@ int drm_init(struct drm_driver *driver) DRM_DEBUG("\n"); + INIT_LIST_HEAD(&driver->device_list); + for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) { pid = (struct pci_device_id *)&driver->pci_driver.id_table[i]; @@ -334,30 +336,13 @@ static void drm_cleanup(struct drm_device * dev) DRM_ERROR("Cannot unload module\n"); } -static int drm_minors_cleanup(int id, void *ptr, void *data) -{ - struct drm_minor *minor = ptr; - struct drm_device *dev; - struct drm_driver *driver = data; - - dev = minor->dev; - if (minor->dev->driver != driver) - return 0; - - if (minor->type != DRM_MINOR_LEGACY) - return 0; - - if (dev) - pci_dev_put(dev->pdev); - drm_cleanup(dev); - return 1; -} - void drm_exit(struct drm_driver *driver) { + struct drm_device *dev, *tmp; DRM_DEBUG("\n"); - idr_for_each(&drm_minors_idr, &drm_minors_cleanup, driver); + list_for_each_entry_safe(dev, tmp, &driver->device_list, driver_item) + drm_cleanup(dev); DRM_INFO("Module unloaded\n"); } |