All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Herrmann <dh.herrmann@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH 08/13] drm: move drm_put_minor() to drm_minor_free()
Date: Wed, 29 Jan 2014 15:01:55 +0100	[thread overview]
Message-ID: <1391004120-687-9-git-send-email-dh.herrmann@gmail.com> (raw)
In-Reply-To: <1391004120-687-1-git-send-email-dh.herrmann@gmail.com>

_put/get() are used for ref-counting, which we clearly don't do here.
Rename it to _free() and also use the common drm_minor_* prefix.
Furthermore, avoid passing the minor directly but instead use the type
like the other functions do, this allows us to reset the slot.

We also drop the redundant call to drm_unplug_minor() as drm_minor_free()
is only used from paths were that has already be called.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_stub.c | 45 ++++++++++++++++++---------------------------
 1 file changed, 18 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 9c2da5f..1634a09 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -291,6 +291,17 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type)
 	return 0;
 }
 
+static void drm_minor_free(struct drm_device *dev, unsigned int type)
+{
+	struct drm_minor **slot;
+
+	slot = drm_minor_get_slot(dev, type);
+	if (*slot) {
+		kfree(*slot);
+		*slot = NULL;
+	}
+}
+
 /**
  * drm_get_minor - Register DRM minor
  * @dev: DRM device
@@ -414,26 +425,6 @@ void drm_minor_release(struct drm_minor *minor)
 }
 
 /**
- * drm_put_minor - Destroy DRM minor
- * @minor: Minor to destroy
- *
- * This calls drm_unplug_minor() on the given minor and then frees it. Nothing
- * is done if @minor is NULL. It is fine to call this on already unplugged
- * minors.
- * The global DRM mutex must be held by the caller.
- */
-static void drm_put_minor(struct drm_minor *minor)
-{
-	if (!minor)
-		return;
-
-	DRM_DEBUG("release secondary minor %d\n", minor->index);
-
-	drm_unplug_minor(minor);
-	kfree(minor);
-}
-
-/**
  * Called via drm_exit() at module unload time or when pci device is
  * unplugged.
  *
@@ -554,9 +545,9 @@ err_ctxbitmap:
 err_ht:
 	drm_ht_remove(&dev->map_hash);
 err_minors:
-	drm_put_minor(dev->control);
-	drm_put_minor(dev->render);
-	drm_put_minor(dev->primary);
+	drm_minor_free(dev, DRM_MINOR_LEGACY);
+	drm_minor_free(dev, DRM_MINOR_RENDER);
+	drm_minor_free(dev, DRM_MINOR_CONTROL);
 	kfree(dev);
 	return NULL;
 }
@@ -572,16 +563,16 @@ EXPORT_SYMBOL(drm_dev_alloc);
  */
 static void drm_dev_free(struct drm_device *dev)
 {
-	drm_put_minor(dev->control);
-	drm_put_minor(dev->render);
-	drm_put_minor(dev->primary);
-
 	if (dev->driver->driver_features & DRIVER_GEM)
 		drm_gem_destroy(dev);
 
 	drm_ctxbitmap_cleanup(dev);
 	drm_ht_remove(&dev->map_hash);
 
+	drm_minor_free(dev, DRM_MINOR_LEGACY);
+	drm_minor_free(dev, DRM_MINOR_RENDER);
+	drm_minor_free(dev, DRM_MINOR_CONTROL);
+
 	kfree(dev->devname);
 	kfree(dev);
 }
-- 
1.8.5.3

  parent reply	other threads:[~2014-01-29 14:02 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-29 14:01 [PATCH 00/13] DRM Reliable Minor-IDs David Herrmann
2014-01-29 14:01 ` [PATCH 01/13] drm: group dev-lifetime related members David Herrmann
2014-01-29 14:01 ` [PATCH 02/13] drm: skip redundant minor-lookup in open path David Herrmann
2014-01-29 14:01 ` [PATCH 03/13] drm: remove unused DRM_MINOR_UNASSIGNED David Herrmann
2014-01-29 14:01 ` [PATCH 04/13] drm: turn DRM_MINOR_* into enum David Herrmann
2014-01-29 14:01 ` [PATCH 05/13] drm: provide device-refcount David Herrmann
2014-02-12 13:25   ` Daniel Vetter
2014-02-12 14:44     ` David Herrmann
2014-02-12 16:26       ` Daniel Vetter
2014-02-12 16:26         ` Daniel Vetter
2014-02-12 16:40         ` Greg KH
2014-02-12 17:48           ` David Herrmann
2014-02-12 17:48             ` David Herrmann
2014-02-12 18:31             ` Daniel Vetter
2014-02-12 18:31               ` Daniel Vetter
2014-02-12 18:38             ` Greg KH
2014-02-21  7:01   ` Thierry Reding
2014-02-24 13:51     ` David Herrmann
2014-01-29 14:01 ` [PATCH 06/13] drm: add minor-lookup/release helpers David Herrmann
2014-02-21  7:09   ` Thierry Reding
2014-02-21  7:34     ` David Herrmann
2014-02-21  7:37       ` Thierry Reding
2014-01-29 14:01 ` [PATCH 07/13] drm: allocate minors early David Herrmann
2014-01-29 14:01 ` David Herrmann [this message]
2014-01-29 14:01 ` [PATCH 09/13] drm: rename drm_unplug/get_minor() to drm_minor_register/unregister() David Herrmann
2014-02-21  7:21   ` Thierry Reding
2014-02-24 13:52     ` David Herrmann
2014-01-29 14:01 ` [PATCH 10/13] drm: remove unneeded #ifdef CONFIG_DEBUGFS David Herrmann
2014-01-29 14:01 ` [PATCH 11/13] drm: remove redundant minor->device field David Herrmann
2014-02-12 13:36   ` Daniel Vetter
2014-02-21  7:30     ` Thierry Reding
2014-02-21 20:07       ` David Herrmann
2014-01-29 14:01 ` [PATCH 12/13] drm: make minor-IDs reliable David Herrmann
2014-01-29 14:02 ` [PATCH 13/13] drm: remove redundant minor->index David Herrmann
2014-02-21  7:30 ` [PATCH 00/13] DRM Reliable Minor-IDs Thierry Reding

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=1391004120-687-9-git-send-email-dh.herrmann@gmail.com \
    --to=dh.herrmann@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.