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
Subject: [PATCH 1/6] drm: call drm_unplug_minor() from drm_put_minor()
Date: Sun, 20 Oct 2013 18:55:40 +0200	[thread overview]
Message-ID: <1382288145-1776-1-git-send-email-dh.herrmann@gmail.com> (raw)

This protects drm_unplug_minor() against repeated calls so we can use it
in drm_put_minor(). This allows us to further simplify it in follow-ups as
we no longer do minor-destruction in both functions but only in
drm_unplug_minor().
Also add kernel-doc comments about what these calls do.

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

diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index c181b71..abc9d49 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -324,10 +324,30 @@ err_idr:
 EXPORT_SYMBOL(drm_get_minor);
 
 /**
- * Put a secondary minor number.
+ * drm_unplug_minor - Unplug DRM minor
+ * @minor: Minor to unplug
  *
- * \param sec_minor - structure to be released
- * \return always zero
+ * 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)
+{
+	if (!minor || !device_is_registered(&minor->kdev))
+		return;
+
+	drm_sysfs_device_remove(minor);
+}
+
+/**
+ * drm_put_minor - Destroy DRM minor
+ * @minor_p: Double pointer to DRM minor
+ *
+ * This calls drm_unplug_minor() on the given minor and then frees it. The minor
+ * pointer is reset to NULL before this returns.
+ * The global DRM mutex must be held by the caller.
  */
 int drm_put_minor(struct drm_minor **minor_p)
 {
@@ -339,7 +359,7 @@ int drm_put_minor(struct drm_minor **minor_p)
 	drm_debugfs_cleanup(minor);
 #endif
 
-	drm_sysfs_device_remove(minor);
+	drm_unplug_minor(minor);
 
 	idr_remove(&drm_minors_idr, minor->index);
 
@@ -349,11 +369,6 @@ int drm_put_minor(struct drm_minor **minor_p)
 }
 EXPORT_SYMBOL(drm_put_minor);
 
-static void drm_unplug_minor(struct drm_minor *minor)
-{
-	drm_sysfs_device_remove(minor);
-}
-
 /**
  * Called via drm_exit() at module unload time or when pci device is
  * unplugged.
-- 
1.8.4.1

             reply	other threads:[~2013-10-20 16:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-20 16:55 David Herrmann [this message]
2013-10-20 16:55 ` [PATCH 2/6] drm: simplify drm_put_minor() David Herrmann
2013-10-20 16:55 ` [PATCH 3/6] drm: make drm_get_minor() static David Herrmann
2013-10-20 16:55 ` [PATCH 4/6] drm: cleanup debugfs in drm_unplug_minor() David Herrmann
2013-10-20 16:55 ` [PATCH 5/6] drm: remove minor-id during unplug David Herrmann
2013-10-20 16:55 ` [PATCH 6/6] drm: delay minor destruction to drm_dev_free() David Herrmann

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=1382288145-1776-1-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