]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
drm: move device unregistration into drm_dev_unregister()
authorDavid Herrmann <dh.herrmann@gmail.com>
Wed, 2 Oct 2013 09:23:38 +0000 (11:23 +0200)
committerDave Airlie <airlied@redhat.com>
Wed, 9 Oct 2013 05:55:27 +0000 (15:55 +1000)
Analog to drm_dev_register(), we now provide drm_dev_unregister() which
does the reverse. drm_dev_put() is still in place and combines the calls
to drm_dev_unregister() and drm_dev_free() so buses don't have to change.

*_get() and *_put() are used for reference-counting in the kernel.
However, drm_dev_put() definitely does not do any kind of ref-counting.
Hence, use the more appropriate *_register(), *_unregister(), *_alloc()
and *_free() names.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_stub.c
include/drm/drmP.h

index 3b5b07482de8e2206a5cff7e2381aadaddc2e398..2badef766d20c62c3be00bb8a1ef81582180173b 100644 (file)
@@ -363,8 +363,6 @@ static void drm_unplug_minor(struct drm_minor *minor)
  */
 void drm_put_dev(struct drm_device *dev)
 {
-       struct drm_map_list *r_list, *list_temp;
-
        DRM_DEBUG("\n");
 
        if (!dev) {
@@ -372,29 +370,7 @@ void drm_put_dev(struct drm_device *dev)
                return;
        }
 
-       drm_lastclose(dev);
-
-       if (dev->driver->unload)
-               dev->driver->unload(dev);
-
-       if (dev->driver->bus->agp_destroy)
-               dev->driver->bus->agp_destroy(dev);
-
-       drm_vblank_cleanup(dev);
-
-       list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
-               drm_rmmap(dev, r_list->map);
-
-       if (drm_core_check_feature(dev, DRIVER_MODESET))
-               drm_put_minor(&dev->control);
-
-       if (dev->render)
-               drm_put_minor(&dev->render);
-
-       drm_put_minor(&dev->primary);
-
-       list_del(&dev->driver_item);
-
+       drm_dev_unregister(dev);
        drm_dev_free(dev);
 }
 EXPORT_SYMBOL(drm_put_dev);
@@ -595,3 +571,38 @@ out_unlock:
        return ret;
 }
 EXPORT_SYMBOL(drm_dev_register);
+
+/**
+ * drm_dev_unregister - Unregister DRM device
+ * @dev: Device to unregister
+ *
+ * Unregister the DRM device from the system. This does the reverse of
+ * drm_dev_register() but does not deallocate the device. The caller must call
+ * drm_dev_free() to free all resources.
+ */
+void drm_dev_unregister(struct drm_device *dev)
+{
+       struct drm_map_list *r_list, *list_temp;
+
+       drm_lastclose(dev);
+
+       if (dev->driver->unload)
+               dev->driver->unload(dev);
+
+       if (dev->driver->bus->agp_destroy)
+               dev->driver->bus->agp_destroy(dev);
+
+       drm_vblank_cleanup(dev);
+
+       list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
+               drm_rmmap(dev, r_list->map);
+
+       if (dev->control)
+               drm_put_minor(&dev->control);
+       if (dev->render)
+               drm_put_minor(&dev->render);
+       drm_put_minor(&dev->primary);
+
+       list_del(&dev->driver_item);
+}
+EXPORT_SYMBOL(drm_dev_unregister);
index 537833c9ab839f8a276500b2c2df02166cad05af..2b9b033efea4435870173c5619adb3fe5b4aaf15 100644 (file)
@@ -1644,6 +1644,7 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
                                 struct device *parent);
 void drm_dev_free(struct drm_device *dev);
 int drm_dev_register(struct drm_device *dev, unsigned long flags);
+void drm_dev_unregister(struct drm_device *dev);
 int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type);
 /*@}*/