From patchwork Tue May 29 15:30:47 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: 10436239 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 84C14601C7 for ; Tue, 29 May 2018 15:31:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75F0C28889 for ; Tue, 29 May 2018 15:31:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AA7A28893; Tue, 29 May 2018 15:31:49 +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 B055E28889 for ; Tue, 29 May 2018 15:31:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935022AbeE2Pbr (ORCPT ); Tue, 29 May 2018 11:31:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:39706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934867AbeE2Pbr (ORCPT ); Tue, 29 May 2018 11:31:47 -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 0224F20849; Tue, 29 May 2018 15:31:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527607906; bh=oboPQUvopK9ny5VniyWJKTL5C07XeEGTdaqpo+yb8tk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1/w1F9C5KPQb83Ecavv1wyh9svsXXXLynH9Wil2OzKIsGpmqzs/qI/GWEZwJfS4gZ 2TcPNyezbcirsmWvkmEBwzpbCdX+AkDTDD+IMH5ScWoliUWUaSSYWy/BOaGf+je9sG nwnqdm3ACkBtWzdlEmqeR/piW6AOR3nLNmBgoDls= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman , Heikki Krogerus , Guenter Roeck , Hans de Goede , Andy Shevchenko , Adam Thomson Subject: [PATCH 02/22] USB: typec: fsusb302: no need to check return value of debugfs_create_dir() Date: Tue, 29 May 2018 17:30:47 +0200 Message-Id: <20180529153107.12791-2-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. Clean up the fsusb302 driver to not care about the dentry being created, or if the root directory was created, as the code should work properly either way. We do not need to save the dentry anymore as things are properly cleaned up when we remove the root directory. Note, this driver seems to only work for one device per system, otherwise the debugfs directories are going to get confused when a device is removed. Cc: Heikki Krogerus Cc: Guenter Roeck Cc: Hans de Goede Cc: Andy Shevchenko Cc: Adam Thomson Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/fusb302/fusb302.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c index 9c1eba9ea004..07b07ddf6af0 100644 --- a/drivers/usb/typec/fusb302/fusb302.c +++ b/drivers/usb/typec/fusb302/fusb302.c @@ -117,7 +117,6 @@ struct fusb302_chip { u32 snk_pdo[PDO_MAX_OBJECTS]; #ifdef CONFIG_DEBUG_FS - struct dentry *dentry; /* lock for log buffer access */ struct mutex logbuffer_lock; int logbuffer_head; @@ -215,33 +214,26 @@ DEFINE_SHOW_ATTRIBUTE(fusb302_debug); static struct dentry *rootdir; -static int fusb302_debugfs_init(struct fusb302_chip *chip) +static void fusb302_debugfs_init(struct fusb302_chip *chip) { mutex_init(&chip->logbuffer_lock); - if (!rootdir) { + if (!rootdir) rootdir = debugfs_create_dir("fusb302", NULL); - if (!rootdir) - return -ENOMEM; - } - - chip->dentry = debugfs_create_file(dev_name(chip->dev), - S_IFREG | 0444, rootdir, - chip, &fusb302_debug_fops); - return 0; + debugfs_create_file(dev_name(chip->dev), S_IFREG | 0444, rootdir, chip, + &fusb302_debug_fops); } static void fusb302_debugfs_exit(struct fusb302_chip *chip) { - debugfs_remove(chip->dentry); - debugfs_remove(rootdir); + debugfs_remove_recursive(rootdir); } #else static void fusb302_log(const struct fusb302_chip *chip, const char *fmt, ...) { } -static int fusb302_debugfs_init(const struct fusb302_chip *chip) { return 0; } +static void fusb302_debugfs_init(const struct fusb302_chip *chip) { } static void fusb302_debugfs_exit(const struct fusb302_chip *chip) { } #endif @@ -1773,9 +1765,7 @@ static int fusb302_probe(struct i2c_client *client, return -EPROBE_DEFER; } - ret = fusb302_debugfs_init(chip); - if (ret < 0) - return ret; + fusb302_debugfs_init(chip); chip->wq = create_singlethread_workqueue(dev_name(chip->dev)); if (!chip->wq) {