From patchwork Tue May 29 15:30:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 10436267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 76972602BF for ; Tue, 29 May 2018 15:32:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 678A628782 for ; Tue, 29 May 2018 15:32:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C2DE2888E; Tue, 29 May 2018 15:32:32 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57D4C28782 for ; Tue, 29 May 2018 15:32:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964811AbeE2Pc3 (ORCPT ); Tue, 29 May 2018 11:32:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:40130 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935207AbeE2Pc3 (ORCPT ); Tue, 29 May 2018 11:32:29 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 286C620899; Tue, 29 May 2018 15:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527607948; bh=5HB1N+b2rJnGsDbqcKI03ZqF1/B3IKls8MG2vwkJqN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zIxD2ZC1Yd6vOCQ9Pf7qRTWGVyXEgrOu5vIgWarfWcL2MW+hk/Vx9M8DF0efiIM/7 PZY+2t0jFZ3iLerL0Ri/50A/JXvwyFw7nDx51XFVMl04htgIw/o4dwOCmPs5gx4ml6 mT7R9LNbFP04By9RvBsdS3v64iLUrDyB/egz2kJ0= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman , Pete Zaitcev , Philippe Ombredanne , Fredrik Noring , Kate Stewart Subject: [PATCH 05/22] USB: mon: no need to check return value of debugfs_create functions Date: Tue, 29 May 2018 17:30:50 +0200 Message-Id: <20180529153107.12791-5-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153107.12791-1-gregkh@linuxfoundation.org> References: <20180529153107.12791-1-gregkh@linuxfoundation.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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. We do need to save the dentries for these files, so keep them around, but no need to check if they are "valid" or not, as the code works just as well either way. Cc: Pete Zaitcev Cc: Philippe Ombredanne Cc: Fredrik Noring Cc: Kate Stewart Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mon/mon_text.c | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c index 984f7e12a6a5..bc5ecd5ff565 100644 --- a/drivers/usb/mon/mon_text.c +++ b/drivers/usb/mon/mon_text.c @@ -700,7 +700,6 @@ static const struct file_operations mon_fops_text_u = { int mon_text_add(struct mon_bus *mbus, const struct usb_bus *ubus) { - struct dentry *d; enum { NAMESZ = 10 }; char name[NAMESZ]; int busnum = ubus? ubus->busnum: 0; @@ -713,42 +712,32 @@ int mon_text_add(struct mon_bus *mbus, const struct usb_bus *ubus) rc = snprintf(name, NAMESZ, "%dt", busnum); if (rc <= 0 || rc >= NAMESZ) goto err_print_t; - d = debugfs_create_file(name, 0600, mon_dir, mbus, + mbus->dent_t = debugfs_create_file(name, 0600, mon_dir, mbus, &mon_fops_text_t); - if (d == NULL) - goto err_create_t; - mbus->dent_t = d; } rc = snprintf(name, NAMESZ, "%du", busnum); if (rc <= 0 || rc >= NAMESZ) goto err_print_u; - d = debugfs_create_file(name, 0600, mon_dir, mbus, &mon_fops_text_u); - if (d == NULL) - goto err_create_u; - mbus->dent_u = d; + mbus->dent_u = debugfs_create_file(name, 0600, mon_dir, mbus, + &mon_fops_text_u); rc = snprintf(name, NAMESZ, "%ds", busnum); if (rc <= 0 || rc >= NAMESZ) goto err_print_s; - d = debugfs_create_file(name, 0600, mon_dir, mbus, &mon_fops_stat); - if (d == NULL) - goto err_create_s; - mbus->dent_s = d; + mbus->dent_s = debugfs_create_file(name, 0600, mon_dir, mbus, + &mon_fops_stat); return 1; -err_create_s: err_print_s: debugfs_remove(mbus->dent_u); mbus->dent_u = NULL; -err_create_u: err_print_u: if (ubus != NULL) { debugfs_remove(mbus->dent_t); mbus->dent_t = NULL; } -err_create_t: err_print_t: return 0; } @@ -756,8 +745,7 @@ int mon_text_add(struct mon_bus *mbus, const struct usb_bus *ubus) void mon_text_del(struct mon_bus *mbus) { debugfs_remove(mbus->dent_u); - if (mbus->dent_t != NULL) - debugfs_remove(mbus->dent_t); + debugfs_remove(mbus->dent_t); debugfs_remove(mbus->dent_s); } @@ -775,18 +763,7 @@ static void mon_text_ctor(void *mem) int __init mon_text_init(void) { - struct dentry *mondir; - - mondir = debugfs_create_dir("usbmon", usb_debug_root); - if (IS_ERR(mondir)) { - /* debugfs not available, but we can use usbmon without it */ - return 0; - } - if (mondir == NULL) { - printk(KERN_NOTICE TAG ": unable to create usbmon directory\n"); - return -ENOMEM; - } - mon_dir = mondir; + mon_dir = debugfs_create_dir("usbmon", usb_debug_root); return 0; }