diff mbox

[2/6] drm: simplify drm_put_minor()

Message ID 1382288145-1776-2-git-send-email-dh.herrmann@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Herrmann Oct. 20, 2013, 4:55 p.m. UTC
Allow passing NULL as minor to simplify DRM destruction paths. Also remove
the double-pointer reset as it is no longer needed. drm_put_minor() is
only called when the underlying object is destroyed. Hence, resetting
minors to NULL is not necessary.

As drm_put_minor() is no longer used by other DRM files, we can make it
static, too.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_stub.c | 31 +++++++++++++------------------
 include/drm/drmP.h         |  1 -
 2 files changed, 13 insertions(+), 19 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index abc9d49..4f606dc 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -343,15 +343,17 @@  static void drm_unplug_minor(struct drm_minor *minor)
 
 /**
  * drm_put_minor - Destroy DRM minor
- * @minor_p: Double pointer to DRM minor
+ * @minor: Minor to destroy
  *
- * This calls drm_unplug_minor() on the given minor and then frees it. The minor
- * pointer is reset to NULL before this returns.
+ * 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.
  */
-int drm_put_minor(struct drm_minor **minor_p)
+static void drm_put_minor(struct drm_minor *minor)
 {
-	struct drm_minor *minor = *minor_p;
+	if (!minor)
+		return;
 
 	DRM_DEBUG("release secondary minor %d\n", minor->index);
 
@@ -364,10 +366,7 @@  int drm_put_minor(struct drm_minor **minor_p)
 	idr_remove(&drm_minors_idr, minor->index);
 
 	kfree(minor);
-	*minor_p = NULL;
-	return 0;
 }
-EXPORT_SYMBOL(drm_put_minor);
 
 /**
  * Called via drm_exit() at module unload time or when pci device is
@@ -556,13 +555,11 @@  err_unload:
 	if (dev->driver->unload)
 		dev->driver->unload(dev);
 err_primary_node:
-	drm_put_minor(&dev->primary);
+	drm_put_minor(dev->primary);
 err_render_node:
-	if (dev->render)
-		drm_put_minor(&dev->render);
+	drm_put_minor(dev->render);
 err_control_node:
-	if (dev->control)
-		drm_put_minor(&dev->control);
+	drm_put_minor(dev->control);
 out_unlock:
 	mutex_unlock(&drm_global_mutex);
 	return ret;
@@ -594,11 +591,9 @@  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);
 
-	if (dev->control)
-		drm_put_minor(&dev->control);
-	if (dev->render)
-		drm_put_minor(&dev->render);
-	drm_put_minor(&dev->primary);
+	drm_put_minor(dev->control);
+	drm_put_minor(dev->render);
+	drm_put_minor(dev->primary);
 
 	list_del(&dev->driver_item);
 }
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 220013d..dc02fb1 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1448,7 +1448,6 @@  extern struct drm_master *drm_master_get(struct drm_master *master);
 extern void drm_master_put(struct drm_master **master);
 
 extern void drm_put_dev(struct drm_device *dev);
-extern int drm_put_minor(struct drm_minor **minor);
 extern void drm_unplug_dev(struct drm_device *dev);
 extern unsigned int drm_debug;
 extern unsigned int drm_rnodes;