aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2014-01-29 06:55:48 -0500
committerDavid Herrmann <dh.herrmann@gmail.com>2014-03-16 07:25:18 -0400
commitbd9dfa98187f6cb671e60d9df0801378e8a99ad9 (patch)
tree39e6cc83731019d8e2aa930ba3d3168c90135cc2
parent05b701f6f60201c9906167351cce50db2e9db7ae (diff)
drm: move drm_put_minor() to drm_minor_free()
_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> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/drm_stub.c45
1 files changed, 18 insertions, 27 deletions
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index b595b64291a2..e46c0904a706 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)
291 return 0; 291 return 0;
292} 292}
293 293
294static void drm_minor_free(struct drm_device *dev, unsigned int type)
295{
296 struct drm_minor **slot;
297
298 slot = drm_minor_get_slot(dev, type);
299 if (*slot) {
300 kfree(*slot);
301 *slot = NULL;
302 }
303}
304
294/** 305/**
295 * drm_get_minor - Register DRM minor 306 * drm_get_minor - Register DRM minor
296 * @dev: DRM device 307 * @dev: DRM device
@@ -414,26 +425,6 @@ void drm_minor_release(struct drm_minor *minor)
414} 425}
415 426
416/** 427/**
417 * drm_put_minor - Destroy DRM minor
418 * @minor: Minor to destroy
419 *
420 * This calls drm_unplug_minor() on the given minor and then frees it. Nothing
421 * is done if @minor is NULL. It is fine to call this on already unplugged
422 * minors.
423 * The global DRM mutex must be held by the caller.
424 */
425static void drm_put_minor(struct drm_minor *minor)
426{
427 if (!minor)
428 return;
429
430 DRM_DEBUG("release secondary minor %d\n", minor->index);
431
432 drm_unplug_minor(minor);
433 kfree(minor);
434}
435
436/**
437 * Called via drm_exit() at module unload time or when pci device is 428 * Called via drm_exit() at module unload time or when pci device is
438 * unplugged. 429 * unplugged.
439 * 430 *
@@ -554,9 +545,9 @@ err_ctxbitmap:
554err_ht: 545err_ht:
555 drm_ht_remove(&dev->map_hash); 546 drm_ht_remove(&dev->map_hash);
556err_minors: 547err_minors:
557 drm_put_minor(dev->control); 548 drm_minor_free(dev, DRM_MINOR_LEGACY);
558 drm_put_minor(dev->render); 549 drm_minor_free(dev, DRM_MINOR_RENDER);
559 drm_put_minor(dev->primary); 550 drm_minor_free(dev, DRM_MINOR_CONTROL);
560 kfree(dev); 551 kfree(dev);
561 return NULL; 552 return NULL;
562} 553}
@@ -566,16 +557,16 @@ static void drm_dev_release(struct kref *ref)
566{ 557{
567 struct drm_device *dev = container_of(ref, struct drm_device, ref); 558 struct drm_device *dev = container_of(ref, struct drm_device, ref);
568 559
569 drm_put_minor(dev->control);
570 drm_put_minor(dev->render);
571 drm_put_minor(dev->primary);
572
573 if (dev->driver->driver_features & DRIVER_GEM) 560 if (dev->driver->driver_features & DRIVER_GEM)
574 drm_gem_destroy(dev); 561 drm_gem_destroy(dev);
575 562
576 drm_ctxbitmap_cleanup(dev); 563 drm_ctxbitmap_cleanup(dev);
577 drm_ht_remove(&dev->map_hash); 564 drm_ht_remove(&dev->map_hash);
578 565
566 drm_minor_free(dev, DRM_MINOR_LEGACY);
567 drm_minor_free(dev, DRM_MINOR_RENDER);
568 drm_minor_free(dev, DRM_MINOR_CONTROL);
569
579 kfree(dev->devname); 570 kfree(dev->devname);
580 kfree(dev); 571 kfree(dev);
581} 572}