dri-devel Archive on 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 09/13] drm: rename drm_unplug/get_minor() to drm_minor_register/unregister()
Date: Wed, 29 Jan 2014 15:01:56 +0100	[thread overview]
Message-ID: <1391004120-687-10-git-send-email-dh.herrmann@gmail.com> (raw)
In-Reply-To: <1391004120-687-1-git-send-email-dh.herrmann@gmail.com>

drm_get_minor() no longer allocates objects, and drm_unplug_minor() is now
the exact reverse of it. Rename it to _register/unregister() so their
name actually says what they do.

Furthermore, remove the direct minor-ptr and instead pass the minor-type.
This way we know the actualy slot of the minor and can reset it if
required.

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

diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 1634a09..853026a 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -302,18 +302,7 @@ static void drm_minor_free(struct drm_device *dev, unsigned int type)
 	}
 }
 
-/**
- * drm_get_minor - Register DRM minor
- * @dev: DRM device
- * @type: Type of minor
- *
- * Register minor of given type.
- * Caller must hold the global DRM mutex.
- *
- * RETURNS:
- * 0 on success, negative error code on failure.
- */
-static int drm_get_minor(struct drm_device *dev, unsigned int type)
+static int drm_minor_register(struct drm_device *dev, unsigned int type)
 {
 	struct drm_minor *new_minor;
 	int ret;
@@ -362,18 +351,11 @@ err_mem:
 	return ret;
 }
 
-/**
- * drm_unplug_minor - Unplug DRM minor
- * @minor: Minor to unplug
- *
- * Unplugs the given DRM minor but keeps the object. So after this returns,
- * minor->dev is still valid so existing open-files can still access it to get
- * device information from their drm_file ojects.
- * If the minor is already unplugged or if @minor is NULL, nothing is done.
- * The global DRM mutex must be held by the caller.
- */
-static void drm_unplug_minor(struct drm_minor *minor)
+static void drm_minor_unregister(struct drm_device *dev, unsigned int type)
 {
+	struct drm_minor *minor;
+
+	minor = *drm_minor_get_slot(dev, type);
 	if (!minor || !minor->kdev)
 		return;
 
@@ -448,11 +430,9 @@ EXPORT_SYMBOL(drm_put_dev);
 void drm_unplug_dev(struct drm_device *dev)
 {
 	/* for a USB device */
-	if (drm_core_check_feature(dev, DRIVER_MODESET))
-		drm_unplug_minor(dev->control);
-	if (dev->render)
-		drm_unplug_minor(dev->render);
-	drm_unplug_minor(dev->primary);
+	drm_minor_unregister(dev, DRM_MINOR_LEGACY);
+	drm_minor_unregister(dev, DRM_MINOR_RENDER);
+	drm_minor_unregister(dev, DRM_MINOR_CONTROL);
 
 	mutex_lock(&drm_global_mutex);
 
@@ -634,15 +614,15 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
 
 	mutex_lock(&drm_global_mutex);
 
-	ret = drm_get_minor(dev, DRM_MINOR_CONTROL);
+	ret = drm_minor_register(dev, DRM_MINOR_CONTROL);
 	if (ret)
 		goto err_minors;
 
-	ret = drm_get_minor(dev, DRM_MINOR_RENDER);
+	ret = drm_minor_register(dev, DRM_MINOR_RENDER);
 	if (ret)
 		goto err_minors;
 
-	ret = drm_get_minor(dev, DRM_MINOR_LEGACY);
+	ret = drm_minor_register(dev, DRM_MINOR_LEGACY);
 	if (ret)
 		goto err_minors;
 
@@ -667,9 +647,9 @@ err_unload:
 	if (dev->driver->unload)
 		dev->driver->unload(dev);
 err_minors:
-	drm_unplug_minor(dev->control);
-	drm_unplug_minor(dev->render);
-	drm_unplug_minor(dev->primary);
+	drm_minor_unregister(dev, DRM_MINOR_LEGACY);
+	drm_minor_unregister(dev, DRM_MINOR_RENDER);
+	drm_minor_unregister(dev, DRM_MINOR_CONTROL);
 out_unlock:
 	mutex_unlock(&drm_global_mutex);
 	return ret;
@@ -701,8 +681,8 @@ void drm_dev_unregister(struct drm_device *dev)
 	list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
 		drm_rmmap(dev, r_list->map);
 
-	drm_unplug_minor(dev->control);
-	drm_unplug_minor(dev->render);
-	drm_unplug_minor(dev->primary);
+	drm_minor_unregister(dev, DRM_MINOR_LEGACY);
+	drm_minor_unregister(dev, DRM_MINOR_RENDER);
+	drm_minor_unregister(dev, DRM_MINOR_CONTROL);
 }
 EXPORT_SYMBOL(drm_dev_unregister);
-- 
1.8.5.3

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

Thread overview: 32+ 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:40         ` Greg KH
2014-02-12 17:48           ` David Herrmann
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 ` [PATCH 08/13] drm: move drm_put_minor() to drm_minor_free() David Herrmann
2014-01-29 14:01 ` David Herrmann [this message]
2014-02-21  7:21   ` [PATCH 09/13] drm: rename drm_unplug/get_minor() to drm_minor_register/unregister() 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-10-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox