From patchwork Sun Oct 20 16:55:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 3073461 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3AE1F9F396 for ; Sun, 20 Oct 2013 16:57:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6215D2021C for ; Sun, 20 Oct 2013 16:57:03 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 75A962021B for ; Sun, 20 Oct 2013 16:57:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6310DE7188 for ; Sun, 20 Oct 2013 09:57:02 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ea0-f178.google.com (mail-ea0-f178.google.com [209.85.215.178]) by gabe.freedesktop.org (Postfix) with ESMTP id C8731E715C for ; Sun, 20 Oct 2013 09:55:58 -0700 (PDT) Received: by mail-ea0-f178.google.com with SMTP id a15so3053375eae.9 for ; Sun, 20 Oct 2013 09:55:57 -0700 (PDT) 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=2dE5nZpelsKUZ7aUAA1Pvf+XW0KDKFx6E6YChCpsLQI=; b=QlbX60VqZTo1fZ9r2XZvBZu2jikN2Kdj4D8K9YX0eiIBZzvbORK5a/xEdPaDQw7Q14 7JMBIs6kPl5fgP1tm5EWsxeyMJ1zCWe8FnVNWVgWIalx48Nmg4h4by4bMQHcSsVIRVE/ ge6shLb0ZWTaGM4+H4c45XbgeFGsgwA+FEn3jybHvwdfd5EnUISlHAeyLLxWjj93MH7j SQQtLtrtqvhrLYwEyH4z7dL+gopz/aQXu64T8y7ZjP/P+msSaPVgJVYMoHyhyX0fPvS7 sr8rjOP3j+dFlaZcIr3sVhLxUl/klDxtOBwoaF12RNXmDtLjbetTe+xgS7iYeZUKtSDb ZzoA== X-Received: by 10.15.93.204 with SMTP id w52mr318952eez.69.1382288157893; Sun, 20 Oct 2013 09:55:57 -0700 (PDT) Received: from localhost.localdomain (stgt-5f71a68b.pool.mediaWays.net. [95.113.166.139]) by mx.google.com with ESMTPSA id e13sm32704479eeu.4.2013.10.20.09.55.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Oct 2013 09:55:57 -0700 (PDT) From: David Herrmann To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/6] drm: simplify drm_put_minor() Date: Sun, 20 Oct 2013 18:55:41 +0200 Message-Id: <1382288145-1776-2-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.4.1 In-Reply-To: <1382288145-1776-1-git-send-email-dh.herrmann@gmail.com> References: <1382288145-1776-1-git-send-email-dh.herrmann@gmail.com> 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+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.5 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 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 --- drivers/gpu/drm/drm_stub.c | 31 +++++++++++++------------------ include/drm/drmP.h | 1 - 2 files changed, 13 insertions(+), 19 deletions(-) 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;