dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: David Herrmann <dh.herrmann@gmail.com>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH 5/5] drm: move device unregistration into drm_dev_unregister()
Date: Wed,  2 Oct 2013 11:23:38 +0200	[thread overview]
Message-ID: <1380705818-4065-6-git-send-email-dh.herrmann@gmail.com> (raw)
In-Reply-To: <1380705818-4065-1-git-send-email-dh.herrmann@gmail.com>

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>
---
 drivers/gpu/drm/drm_stub.c | 61 +++++++++++++++++++++++++++-------------------
 include/drm/drmP.h         |  1 +
 2 files changed, 37 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 397ab90..a5290b7 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -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);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index f4ec6b3..7516d22 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1649,6 +1649,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);
+void drm_dev_unregister(struct drm_device *dev);
 int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type);
 /*@}*/
 
-- 
1.8.4

  parent reply	other threads:[~2013-10-02  9:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-02  9:23 [PATCH 0/5] DRM device-alloc cleanup David Herrmann
2013-10-02  9:23 ` [PATCH 1/5] drm: add drm_dev_alloc() helper David Herrmann
2013-10-02  9:23 ` [PATCH 2/5] drm: merge device setup into drm_dev_register() David Herrmann
2013-10-03 13:15   ` Daniel Vetter
2013-10-03 13:19     ` David Herrmann
2013-10-03 13:21       ` Daniel Vetter
2013-10-02  9:23 ` [PATCH 3/5] drm: move drm_lastclose() to drm_fops.c David Herrmann
2013-10-02  9:23 ` [PATCH 4/5] drm: introduce drm_dev_free() to fix error paths David Herrmann
2013-10-02  9:23 ` David Herrmann [this message]
2013-10-03 13:18   ` [PATCH 5/5] drm: move device unregistration into drm_dev_unregister() Daniel Vetter
2013-10-09  5:31 ` [PATCH 0/5] DRM device-alloc cleanup Dave Airlie
2013-10-09  6:00   ` Dave Airlie
2013-10-09  8:05     ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1380705818-4065-6-git-send-email-dh.herrmann@gmail.com \
    --to=dh.herrmann@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).