From patchwork Wed Jan 29 14:01:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 3551251 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8D756C02DC for ; Wed, 29 Jan 2014 14:03:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DCE4F201B4 for ; Wed, 29 Jan 2014 14:03:20 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8234A20170 for ; Wed, 29 Jan 2014 14:03:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D784643700; Wed, 29 Jan 2014 06:02:52 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ea0-f174.google.com (mail-ea0-f174.google.com [209.85.215.174]) by gabe.freedesktop.org (Postfix) with ESMTP id 1B543436E5 for ; Wed, 29 Jan 2014 06:02:29 -0800 (PST) Received: by mail-ea0-f174.google.com with SMTP id b10so929570eae.5 for ; Wed, 29 Jan 2014 06:02:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=r6L5Uni5jWKKOWgRrrjOilT6i6ydJnd8rHlweFEJYy8=; b=X1jyLPBBqNxQqRfvHh7Zg2d/UhCybQraJGKL0yqJ/OFl1nFJtBTlpC680tSrqrFNmW X+5plCdkxnWeV9Y/8Q7gEImyLbdGpRkdHO0Nm2o5afSx+RURchKleGbis8qIkLw1RRiA we5p6CyFCYtiRcOmN6TdLYDAPdyU+fvExorKrEGT4aetHTXLXrwh349zC5PUL4mMgdlG NR5A7YMKeChaEtktIvBCEcRg8F8wFWebtXbzG6gBAnD0SVyU3hZzWjiX4mQnroGlO7MN pltz9S+GULcW9azdZJbnAxuKmIYiesgAq7ZkON7FNrW2fcw/pJ2Ljs8QfJWx1aZDrj2Q YRYA== X-Received: by 10.15.54.72 with SMTP id s48mr9716782eew.3.1391004149246; Wed, 29 Jan 2014 06:02:29 -0800 (PST) Received: from david-ub.localdomain (stgt-5f71657e.pool.mediaWays.net. [95.113.101.126]) by mx.google.com with ESMTPSA id o13sm9094881eex.19.2014.01.29.06.02.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Jan 2014 06:02:28 -0800 (PST) From: David Herrmann To: dri-devel@lists.freedesktop.org Subject: [PATCH 08/13] drm: move drm_put_minor() to drm_minor_free() Date: Wed, 29 Jan 2014 15:01:55 +0100 Message-Id: <1391004120-687-9-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1391004120-687-1-git-send-email-dh.herrmann@gmail.com> References: <1391004120-687-1-git-send-email-dh.herrmann@gmail.com> Cc: Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP _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 --- drivers/gpu/drm/drm_stub.c | 45 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index 9c2da5f..1634a09 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) return 0; } +static void drm_minor_free(struct drm_device *dev, unsigned int type) +{ + struct drm_minor **slot; + + slot = drm_minor_get_slot(dev, type); + if (*slot) { + kfree(*slot); + *slot = NULL; + } +} + /** * drm_get_minor - Register DRM minor * @dev: DRM device @@ -414,26 +425,6 @@ void drm_minor_release(struct drm_minor *minor) } /** - * drm_put_minor - Destroy DRM minor - * @minor: Minor to destroy - * - * 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. - */ -static void drm_put_minor(struct drm_minor *minor) -{ - if (!minor) - return; - - DRM_DEBUG("release secondary minor %d\n", minor->index); - - drm_unplug_minor(minor); - kfree(minor); -} - -/** * Called via drm_exit() at module unload time or when pci device is * unplugged. * @@ -554,9 +545,9 @@ err_ctxbitmap: err_ht: drm_ht_remove(&dev->map_hash); err_minors: - drm_put_minor(dev->control); - drm_put_minor(dev->render); - drm_put_minor(dev->primary); + drm_minor_free(dev, DRM_MINOR_LEGACY); + drm_minor_free(dev, DRM_MINOR_RENDER); + drm_minor_free(dev, DRM_MINOR_CONTROL); kfree(dev); return NULL; } @@ -572,16 +563,16 @@ EXPORT_SYMBOL(drm_dev_alloc); */ static void drm_dev_free(struct drm_device *dev) { - drm_put_minor(dev->control); - drm_put_minor(dev->render); - drm_put_minor(dev->primary); - if (dev->driver->driver_features & DRIVER_GEM) drm_gem_destroy(dev); drm_ctxbitmap_cleanup(dev); drm_ht_remove(&dev->map_hash); + drm_minor_free(dev, DRM_MINOR_LEGACY); + drm_minor_free(dev, DRM_MINOR_RENDER); + drm_minor_free(dev, DRM_MINOR_CONTROL); + kfree(dev->devname); kfree(dev); }