From patchwork Thu May 2 07:27:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 10926107 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 533651515 for ; Thu, 2 May 2019 07:27:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D1F228FE1 for ; Thu, 2 May 2019 07:27:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 305D028FEF; Thu, 2 May 2019 07:27:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 72D2028FE1 for ; Thu, 2 May 2019 07:27:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2589E89256; Thu, 2 May 2019 07:27:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id 81A2289269 for ; Thu, 2 May 2019 07:27:36 +0000 (UTC) Received: by mail-ed1-x541.google.com with SMTP id w11so1201177edl.5 for ; Thu, 02 May 2019 00:27:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sJBn7OhxYZbK1Jdu1mmSELFdE7q95THJbAIrKtUxTh0=; b=dH89VB0je1gyR9qEgNqEo6CwpVc3W1mVCJGrdbhcNBGkHQyU5RUQMWkx7gVXqKrYlK qhXYyG5w5XFJBlFXWVWUeFQIb/IydTOlIsITz8425MxrVLE9K3EBjdN40Z88Sxpov9mH 4udrtDdNhRpruHkBTMFZx1VF4fPOyuIrmTGKd6Z7F69ndWFK0JeMwM4vxXXvl8xDzbEk Up6LD+ckFD0Tx8Osm9NfRYO4eayIbbflrio9wmLFPss9fzp1sSUQF6CIgEh/ztWmjyNt G8Ie0mrtSjRxF/GecuJl7G3DHrhZMmX6oJXjmak4jNsgBBmzNiwnwM3lPwrGKvh7iC1h OqiA== X-Gm-Message-State: APjAAAUI6K1tb+/zOlz1887iykrLKMkT46JY3MJXaBWUguHpkSFeQL5N 7TWCXD5HIlBHaoZuLVlidUOgYDGxI84= X-Google-Smtp-Source: APXvYqwZRmiB/rJCIBLTKJt7XLqzb5LclGHvbWEWWy+qTNGI86abWvGufqQRXgpJvMWN8AGMDU425Q== X-Received: by 2002:a17:906:7c12:: with SMTP id t18mr1030971ejo.59.1556782054351; Thu, 02 May 2019 00:27:34 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id t9sm6980458ejg.54.2019.05.02.00.27.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 May 2019 00:27:33 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH] drm: Some ocd in drm_file.c Date: Thu, 2 May 2019 09:27:27 +0200 Message-Id: <20190502072727.32159-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sJBn7OhxYZbK1Jdu1mmSELFdE7q95THJbAIrKtUxTh0=; b=Qhso0MPyh4cbPNZPu4Ii2eXtXnmRqTHxc0+2+KOESBeZSKLZkroShAaAtGizeh08xl +GHuGb2qQj9vRthf6GbOYm63wwtxS/OYks/JYYkNQNGMtGITwlzBL4YwnwbQrlrE6hd8 J/nGfaA9+LlaCaOyHxOR2HkS7VokWhbGDd9Jw= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Move the open helper around to avoid the forward decl, and give drm_setup a drm_legacy_ prefix since it's all legacy stuff in there. Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_file.c | 142 ++++++++++++++++++------------------- 1 file changed, 70 insertions(+), 72 deletions(-) diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index 233f114d2186..8437aa834245 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -100,8 +100,6 @@ DEFINE_MUTEX(drm_global_mutex); * :ref:`IOCTL support in the userland interfaces chapter`. */ -static int drm_open_helper(struct file *filp, struct drm_minor *minor); - /** * drm_file_alloc - allocate file context * @minor: minor to allocate on @@ -273,76 +271,6 @@ static void drm_close_helper(struct file *filp) drm_file_free(file_priv); } -static int drm_setup(struct drm_device * dev) -{ - int ret; - - if (dev->driver->firstopen && - drm_core_check_feature(dev, DRIVER_LEGACY)) { - ret = dev->driver->firstopen(dev); - if (ret != 0) - return ret; - } - - ret = drm_legacy_dma_setup(dev); - if (ret < 0) - return ret; - - - DRM_DEBUG("\n"); - return 0; -} - -/** - * drm_open - open method for DRM file - * @inode: device inode - * @filp: file pointer. - * - * This function must be used by drivers as their &file_operations.open method. - * It looks up the correct DRM device and instantiates all the per-file - * resources for it. It also calls the &drm_driver.open driver callback. - * - * RETURNS: - * - * 0 on success or negative errno value on falure. - */ -int drm_open(struct inode *inode, struct file *filp) -{ - struct drm_device *dev; - struct drm_minor *minor; - int retcode; - int need_setup = 0; - - minor = drm_minor_acquire(iminor(inode)); - if (IS_ERR(minor)) - return PTR_ERR(minor); - - dev = minor->dev; - if (!dev->open_count++) - need_setup = 1; - - /* share address_space across all char-devs of a single device */ - filp->f_mapping = dev->anon_inode->i_mapping; - - retcode = drm_open_helper(filp, minor); - if (retcode) - goto err_undo; - if (need_setup) { - retcode = drm_setup(dev); - if (retcode) { - drm_close_helper(filp); - goto err_undo; - } - } - return 0; - -err_undo: - dev->open_count--; - drm_minor_release(minor); - return retcode; -} -EXPORT_SYMBOL(drm_open); - /* * Check whether DRI will run on this CPU. * @@ -424,6 +352,76 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor) return 0; } +static int drm_legacy_setup(struct drm_device * dev) +{ + int ret; + + if (dev->driver->firstopen && + drm_core_check_feature(dev, DRIVER_LEGACY)) { + ret = dev->driver->firstopen(dev); + if (ret != 0) + return ret; + } + + ret = drm_legacy_dma_setup(dev); + if (ret < 0) + return ret; + + + DRM_DEBUG("\n"); + return 0; +} + +/** + * drm_open - open method for DRM file + * @inode: device inode + * @filp: file pointer. + * + * This function must be used by drivers as their &file_operations.open method. + * It looks up the correct DRM device and instantiates all the per-file + * resources for it. It also calls the &drm_driver.open driver callback. + * + * RETURNS: + * + * 0 on success or negative errno value on falure. + */ +int drm_open(struct inode *inode, struct file *filp) +{ + struct drm_device *dev; + struct drm_minor *minor; + int retcode; + int need_setup = 0; + + minor = drm_minor_acquire(iminor(inode)); + if (IS_ERR(minor)) + return PTR_ERR(minor); + + dev = minor->dev; + if (!dev->open_count++) + need_setup = 1; + + /* share address_space across all char-devs of a single device */ + filp->f_mapping = dev->anon_inode->i_mapping; + + retcode = drm_open_helper(filp, minor); + if (retcode) + goto err_undo; + if (need_setup) { + retcode = drm_legacy_setup(dev); + if (retcode) { + drm_close_helper(filp); + goto err_undo; + } + } + return 0; + +err_undo: + dev->open_count--; + drm_minor_release(minor); + return retcode; +} +EXPORT_SYMBOL(drm_open); + void drm_lastclose(struct drm_device * dev) { DRM_DEBUG("\n");