From patchwork Sun Oct 20 16:55:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 3073451 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 4F4D79F396 for ; Sun, 20 Oct 2013 16:56:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4AEF3201DE for ; Sun, 20 Oct 2013 16:56:15 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 29562200BE for ; Sun, 20 Oct 2013 16:56:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 40935E7199 for ; Sun, 20 Oct 2013 09:56:13 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ea0-f180.google.com (mail-ea0-f180.google.com [209.85.215.180]) by gabe.freedesktop.org (Postfix) with ESMTP id DC439E715C for ; Sun, 20 Oct 2013 09:55:57 -0700 (PDT) Received: by mail-ea0-f180.google.com with SMTP id h10so2947030eaj.25 for ; Sun, 20 Oct 2013 09:55:56 -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; bh=3T9j0OBqYMJJtPL8aucAVCNez77ldnxxva5F7894CDY=; b=nmrtIXOgMx879Iik0mflTNp9KkaYi8BzUGvFoU9F1m5rogpI+o4dJQgWtQ1KQBW8oi 2el9RNhvsNaSSP/K06jc7oVxdz3mMR4n+pEc3DXS/5PlpSvrbUNzf1S8toFEfh08QUMV CTgXPXB9owoPK+isTGjkM8JHA3F9fgUXNAxv7N14Yx9jIjRamqkWD7Y/sL1V+rKcQMUb ofkLrwi6jM0mGWqMyJbDBosYu1lOu/P0q6malChScf1I5p7e3rCinyjey0uQqeMXh0Mi uYw8EMU5RzkkWQ/a3wWw8/Bbl5zXVFj+qlaZchmqp/ab7MlPcdnIV1a6taXo8rcUmTxR 9M5A== X-Received: by 10.15.65.14 with SMTP id p14mr303058eex.96.1382288156358; Sun, 20 Oct 2013 09:55:56 -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.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Oct 2013 09:55:55 -0700 (PDT) From: David Herrmann To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/6] drm: call drm_unplug_minor() from drm_put_minor() Date: Sun, 20 Oct 2013 18:55:40 +0200 Message-Id: <1382288145-1776-1-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.4.1 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 This protects drm_unplug_minor() against repeated calls so we can use it in drm_put_minor(). This allows us to further simplify it in follow-ups as we no longer do minor-destruction in both functions but only in drm_unplug_minor(). Also add kernel-doc comments about what these calls do. Signed-off-by: David Herrmann --- drivers/gpu/drm/drm_stub.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index c181b71..abc9d49 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c @@ -324,10 +324,30 @@ err_idr: EXPORT_SYMBOL(drm_get_minor); /** - * Put a secondary minor number. + * drm_unplug_minor - Unplug DRM minor + * @minor: Minor to unplug * - * \param sec_minor - structure to be released - * \return always zero + * Unplugs the given DRM minor but keeps the object. So after this returns, + * minor->dev is still valid so existing open-files can still access it to get + * device information from their drm_file ojects. + * If the minor is already unplugged or if @minor is NULL, nothing is done. + * The global DRM mutex must be held by the caller. + */ +static void drm_unplug_minor(struct drm_minor *minor) +{ + if (!minor || !device_is_registered(&minor->kdev)) + return; + + drm_sysfs_device_remove(minor); +} + +/** + * drm_put_minor - Destroy DRM minor + * @minor_p: Double pointer to DRM minor + * + * This calls drm_unplug_minor() on the given minor and then frees it. The minor + * pointer is reset to NULL before this returns. + * The global DRM mutex must be held by the caller. */ int drm_put_minor(struct drm_minor **minor_p) { @@ -339,7 +359,7 @@ int drm_put_minor(struct drm_minor **minor_p) drm_debugfs_cleanup(minor); #endif - drm_sysfs_device_remove(minor); + drm_unplug_minor(minor); idr_remove(&drm_minors_idr, minor->index); @@ -349,11 +369,6 @@ int drm_put_minor(struct drm_minor **minor_p) } EXPORT_SYMBOL(drm_put_minor); -static void drm_unplug_minor(struct drm_minor *minor) -{ - drm_sysfs_device_remove(minor); -} - /** * Called via drm_exit() at module unload time or when pci device is * unplugged.