aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-10-20 12:55:41 -0400
committerDave Airlie <airlied@redhat.com>2013-11-05 23:53:23 -0500
commit4ac387f516bd3e5356cdb25266e244fa8a062281 (patch)
treef50c08aa8fdad6ff571711ba5b202ac11b5a58e3
parentf73aca50b7f6e0f3e04d887f852b9f8b0e108fa7 (diff)
drm: simplify drm_put_minor()
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> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/drm/drm_stub.c31
-rw-r--r--include/drm/drmP.h1
2 files changed, 13 insertions, 19 deletions
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index ae3f293229ae..dd0cb02830f4 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)
343 343
344/** 344/**
345 * drm_put_minor - Destroy DRM minor 345 * drm_put_minor - Destroy DRM minor
346 * @minor_p: Double pointer to DRM minor 346 * @minor: Minor to destroy
347 * 347 *
348 * This calls drm_unplug_minor() on the given minor and then frees it. The minor 348 * This calls drm_unplug_minor() on the given minor and then frees it. Nothing
349 * pointer is reset to NULL before this returns. 349 * is done if @minor is NULL. It is fine to call this on already unplugged
350 * minors.
350 * The global DRM mutex must be held by the caller. 351 * The global DRM mutex must be held by the caller.
351 */ 352 */
352int drm_put_minor(struct drm_minor **minor_p) 353static void drm_put_minor(struct drm_minor *minor)
353{ 354{
354 struct drm_minor *minor = *minor_p; 355 if (!minor)
356 return;
355 357
356 DRM_DEBUG("release secondary minor %d\n", minor->index); 358 DRM_DEBUG("release secondary minor %d\n", minor->index);
357 359
@@ -364,10 +366,7 @@ int drm_put_minor(struct drm_minor **minor_p)
364 idr_remove(&drm_minors_idr, minor->index); 366 idr_remove(&drm_minors_idr, minor->index);
365 367
366 kfree(minor); 368 kfree(minor);
367 *minor_p = NULL;
368 return 0;
369} 369}
370EXPORT_SYMBOL(drm_put_minor);
371 370
372/** 371/**
373 * Called via drm_exit() at module unload time or when pci device is 372 * Called via drm_exit() at module unload time or when pci device is
@@ -562,13 +561,11 @@ err_unload:
562 if (dev->driver->unload) 561 if (dev->driver->unload)
563 dev->driver->unload(dev); 562 dev->driver->unload(dev);
564err_primary_node: 563err_primary_node:
565 drm_put_minor(&dev->primary); 564 drm_put_minor(dev->primary);
566err_render_node: 565err_render_node:
567 if (dev->render) 566 drm_put_minor(dev->render);
568 drm_put_minor(&dev->render);
569err_control_node: 567err_control_node:
570 if (dev->control) 568 drm_put_minor(dev->control);
571 drm_put_minor(&dev->control);
572err_agp: 569err_agp:
573 if (dev->driver->bus->agp_destroy) 570 if (dev->driver->bus->agp_destroy)
574 dev->driver->bus->agp_destroy(dev); 571 dev->driver->bus->agp_destroy(dev);
@@ -603,11 +600,9 @@ void drm_dev_unregister(struct drm_device *dev)
603 list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) 600 list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
604 drm_rmmap(dev, r_list->map); 601 drm_rmmap(dev, r_list->map);
605 602
606 if (dev->control) 603 drm_put_minor(dev->control);
607 drm_put_minor(&dev->control); 604 drm_put_minor(dev->render);
608 if (dev->render) 605 drm_put_minor(dev->primary);
609 drm_put_minor(&dev->render);
610 drm_put_minor(&dev->primary);
611 606
612 list_del(&dev->driver_item); 607 list_del(&dev->driver_item);
613} 608}
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index b3e4fa213000..62da57e914f8 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1436,7 +1436,6 @@ extern struct drm_master *drm_master_get(struct drm_master *master);
1436extern void drm_master_put(struct drm_master **master); 1436extern void drm_master_put(struct drm_master **master);
1437 1437
1438extern void drm_put_dev(struct drm_device *dev); 1438extern void drm_put_dev(struct drm_device *dev);
1439extern int drm_put_minor(struct drm_minor **minor);
1440extern void drm_unplug_dev(struct drm_device *dev); 1439extern void drm_unplug_dev(struct drm_device *dev);
1441extern unsigned int drm_debug; 1440extern unsigned int drm_debug;
1442extern unsigned int drm_rnodes; 1441extern unsigned int drm_rnodes;