From patchwork Thu Jun 13 11:44:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10991617 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 9886A1398 for ; Thu, 13 Jun 2019 11:45:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F78028B73 for ; Thu, 13 Jun 2019 11:45:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E1BD28B80; Thu, 13 Jun 2019 11:45:02 +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 CD42228B73 for ; Thu, 13 Jun 2019 11:45:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4D00789294; Thu, 13 Jun 2019 11:44:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0078889294 for ; Thu, 13 Jun 2019 11:44:57 +0000 (UTC) Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3F19521721; Thu, 13 Jun 2019 11:44:57 +0000 (UTC) Date: Thu, 13 Jun 2019 13:44:55 +0200 From: Greg Kroah-Hartman To: Lukas Wunner , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Sean Paul Subject: [PATCH] vga_switcheroo: no need to check return value of debugfs_create functions Message-ID: <20190613114455.GA13119@kroah.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.12.0 (2019-05-25) X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560426297; bh=vs411e2N0uvdhrNJ49hrBF1USqza5mBPHBU1+6hmbC0=; h=Date:From:To:Cc:Subject:From; b=WeuPi/XWsbz3jFaJ/qvK7XbPNQFq9hVNI/lPx7hkRfdYFaRicahMTm6cJ2wDKaUp+ SSCoSbM94bvRyZ1YnMTvhpWz//4+DF912PfyGEFBWYYWnUAnOrs2Nc1Xbs4WZbL7JI 73NfCEOhn1oFg1106Wh6elGzv+nEDECggbVCgCm8= 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: dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Also, because there is no need to save the file dentry, remove the local variable and just recursively delete the whole directory when shutting down. Cc: Lukas Wunner Cc: David Airlie Cc: Daniel Vetter Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Sean Paul Cc: dri-devel@lists.freedesktop.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/vga/vga_switcheroo.c | 34 +++++++------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c index a132c37d7334..a48d810d6ccb 100644 --- a/drivers/gpu/vga/vga_switcheroo.c +++ b/drivers/gpu/vga/vga_switcheroo.c @@ -133,7 +133,6 @@ static DEFINE_MUTEX(vgasr_mutex); * @delayed_switch_active: whether a delayed switch is pending * @delayed_client_id: client to which a delayed switch is pending * @debugfs_root: directory for vga_switcheroo debugfs interface - * @switch_file: file for vga_switcheroo debugfs interface * @registered_clients: number of registered GPUs * (counting only vga clients, not audio clients) * @clients: list of registered clients @@ -152,7 +151,6 @@ struct vgasr_priv { enum vga_switcheroo_client_id delayed_client_id; struct dentry *debugfs_root; - struct dentry *switch_file; int registered_clients; struct list_head clients; @@ -168,7 +166,7 @@ struct vgasr_priv { #define client_is_vga(c) (!client_is_audio(c)) #define client_id(c) ((c)->id & ~ID_BIT_AUDIO) -static int vga_switcheroo_debugfs_init(struct vgasr_priv *priv); +static void vga_switcheroo_debugfs_init(struct vgasr_priv *priv); static void vga_switcheroo_debugfs_fini(struct vgasr_priv *priv); /* only one switcheroo per system */ @@ -914,38 +912,20 @@ static const struct file_operations vga_switcheroo_debugfs_fops = { static void vga_switcheroo_debugfs_fini(struct vgasr_priv *priv) { - debugfs_remove(priv->switch_file); - priv->switch_file = NULL; - - debugfs_remove(priv->debugfs_root); + debugfs_remove_recursive(priv->debugfs_root); priv->debugfs_root = NULL; } -static int vga_switcheroo_debugfs_init(struct vgasr_priv *priv) +static void vga_switcheroo_debugfs_init(struct vgasr_priv *priv) { - static const char mp[] = "/sys/kernel/debug"; - /* already initialised */ if (priv->debugfs_root) - return 0; - priv->debugfs_root = debugfs_create_dir("vgaswitcheroo", NULL); + return; - if (!priv->debugfs_root) { - pr_err("Cannot create %s/vgaswitcheroo\n", mp); - goto fail; - } + priv->debugfs_root = debugfs_create_dir("vgaswitcheroo", NULL); - priv->switch_file = debugfs_create_file("switch", 0644, - priv->debugfs_root, NULL, - &vga_switcheroo_debugfs_fops); - if (!priv->switch_file) { - pr_err("cannot create %s/vgaswitcheroo/switch\n", mp); - goto fail; - } - return 0; -fail: - vga_switcheroo_debugfs_fini(priv); - return -1; + debugfs_create_file("switch", 0644, priv->debugfs_root, NULL, + &vga_switcheroo_debugfs_fops); } /**