From patchwork Fri Jun 14 09:51:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 10994835 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 94DE114E5 for ; Fri, 14 Jun 2019 09:51:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 852B61FFCD for ; Fri, 14 Jun 2019 09:51:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79452282E8; Fri, 14 Jun 2019 09:51:24 +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 0397F1FFEB for ; Fri, 14 Jun 2019 09:51:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B9AE9896C4; Fri, 14 Jun 2019 09:51:21 +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 694FE896C4 for ; Fri, 14 Jun 2019 09:51:20 +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 C2DA621721; Fri, 14 Jun 2019 09:51:19 +0000 (UTC) From: Greg Kroah-Hartman To: David Airlie , Daniel Vetter Subject: [PATCH 1/2] drm: debugfs: make drm_debugfs_remove_files() a void function Date: Fri, 14 Jun 2019 11:51:09 +0200 Message-Id: <20190614095110.3716-1-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560505880; bh=iOpdFvSH3lQnymOzypBokmI9+g0uhnAJnYe9Fi4ro2I=; h=From:To:Cc:Subject:Date:From; b=Qz6OWEbwkcwaAtDrHO0CYPAjYe8odHg7WsKojXC+SMmH80SRV5lCnBZ6+tzazxX+x /Fzt8Ldt/QoDHQ5qq5kKxXfTvXBpbKdGpTJ7BzADZ4J6Spscq9k8lN4K8iHbOdWFkQ fZlQDxN4Hr1X0hYD4Kxh07r/bEAvKK8a4tsIW1qE= 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: Maxime Ripard , Greg Kroah-Hartman , Sean Paul , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The function can not fail, and no one checks the current return value, so just mark it as a void function so no one gets confused. Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Sean Paul Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel@lists.freedesktop.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/drm_debugfs.c | 5 ++--- include/drm/drm_debugfs.h | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 6f2802e9bfb5..515569002c86 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -270,8 +270,8 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id, } -int drm_debugfs_remove_files(const struct drm_info_list *files, int count, - struct drm_minor *minor) +void drm_debugfs_remove_files(const struct drm_info_list *files, int count, + struct drm_minor *minor) { struct list_head *pos, *q; struct drm_info_node *tmp; @@ -289,7 +289,6 @@ int drm_debugfs_remove_files(const struct drm_info_list *files, int count, } } mutex_unlock(&minor->debugfs_lock); - return 0; } EXPORT_SYMBOL(drm_debugfs_remove_files); diff --git a/include/drm/drm_debugfs.h b/include/drm/drm_debugfs.h index ac0f75df1ac9..422d0d201c0a 100644 --- a/include/drm/drm_debugfs.h +++ b/include/drm/drm_debugfs.h @@ -81,8 +81,8 @@ struct drm_info_node { int drm_debugfs_create_files(const struct drm_info_list *files, int count, struct dentry *root, struct drm_minor *minor); -int drm_debugfs_remove_files(const struct drm_info_list *files, - int count, struct drm_minor *minor); +void drm_debugfs_remove_files(const struct drm_info_list *files, + int count, struct drm_minor *minor); #else static inline int drm_debugfs_create_files(const struct drm_info_list *files, int count, struct dentry *root, @@ -91,10 +91,9 @@ static inline int drm_debugfs_create_files(const struct drm_info_list *files, return 0; } -static inline int drm_debugfs_remove_files(const struct drm_info_list *files, - int count, struct drm_minor *minor) +static inline void drm_debugfs_remove_files(const struct drm_info_list *files, + int count, struct drm_minor *minor) { - return 0; } #endif From patchwork Fri Jun 14 09:51:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 10994837 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 CB58014BB for ; Fri, 14 Jun 2019 09:51:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBA351FFCD for ; Fri, 14 Jun 2019 09:51:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFC81283F9; Fri, 14 Jun 2019 09:51:31 +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 44C0427F8C for ; Fri, 14 Jun 2019 09:51:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3FA4A896DD; Fri, 14 Jun 2019 09:51:30 +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 EA629896DD for ; Fri, 14 Jun 2019 09:51:28 +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 564DE21773; Fri, 14 Jun 2019 09:51:28 +0000 (UTC) From: Greg Kroah-Hartman To: David Airlie , Daniel Vetter Subject: [PATCH 2/2] drm: debugfs: make drm_debugfs_create_files() never fail Date: Fri, 14 Jun 2019 11:51:10 +0200 Message-Id: <20190614095110.3716-2-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190614095110.3716-1-gregkh@linuxfoundation.org> References: <20190614095110.3716-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560505888; bh=xYF0jYvwFqoTUXDgFBnhu44KysgxToBxAJJsBkqliCg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oHzJAALIO7AcBSzeUSsFe0LW48S7BxkM6v0w3/dPrv0ijblQ/Febvn4kLH9Y6sMn2 XYHaS4As6ys/6u5sWtfEWHwveu4ELKTKnBrzqnFHKNs6g5Hr5r1HZjP6nrGQ4Um1Sx QeDf062aUGJon7pRSq9+tA4LcI6Z7b93TCK56dE0= 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: Maxime Ripard , Greg Kroah-Hartman , Sean Paul , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP As stated before, there is no need to care if a debugfs function succeeds or not, and no code logic in the kernel should ever change based on a debugfs function return value, so make drm_debugfs_create_files() never fail. If it encounters an odd/rare/impossible error (i.e. out of memory, or a duplicate debugfs filename to be created), just keep on moving as if nothing improper had happened. Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Sean Paul Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel@lists.freedesktop.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/drm_debugfs.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 515569002c86..009e1c0ac7b4 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -173,9 +173,8 @@ int drm_debugfs_create_files(const struct drm_info_list *files, int count, struct dentry *root, struct drm_minor *minor) { struct drm_device *dev = minor->dev; - struct dentry *ent; struct drm_info_node *tmp; - int i, ret; + int i; for (i = 0; i < count; i++) { u32 features = files[i].driver_features; @@ -185,22 +184,13 @@ int drm_debugfs_create_files(const struct drm_info_list *files, int count, continue; tmp = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL); - if (tmp == NULL) { - ret = -1; - goto fail; - } - ent = debugfs_create_file(files[i].name, S_IFREG | S_IRUGO, - root, tmp, &drm_debugfs_fops); - if (!ent) { - DRM_ERROR("Cannot create /sys/kernel/debug/dri/%pd/%s\n", - root, files[i].name); - kfree(tmp); - ret = -1; - goto fail; - } + if (tmp == NULL) + continue; tmp->minor = minor; - tmp->dent = ent; + tmp->dent = debugfs_create_file(files[i].name, + S_IFREG | S_IRUGO, root, tmp, + &drm_debugfs_fops); tmp->info_ent = &files[i]; mutex_lock(&minor->debugfs_lock); @@ -208,10 +198,6 @@ int drm_debugfs_create_files(const struct drm_info_list *files, int count, mutex_unlock(&minor->debugfs_lock); } return 0; - -fail: - drm_debugfs_remove_files(files, count, minor); - return ret; } EXPORT_SYMBOL(drm_debugfs_create_files);