Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp927964pxb; Fri, 22 Apr 2022 14:33:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw25wguSPmHhPjuYCtkbM6dMM2/teZrl0ivEa5T7ItT5H2x2qmMmP3bzAi9EV6+Fu3E7pcH X-Received: by 2002:a17:902:f789:b0:156:5f56:ddff with SMTP id q9-20020a170902f78900b001565f56ddffmr6629338pln.116.1650663188761; Fri, 22 Apr 2022 14:33:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650663188; cv=none; d=google.com; s=arc-20160816; b=hHLo+Z4JI+1+FU3qkDykvEijj++k486smo7Y0HME+k7ldRY3Txce48swSMajDhE09P MH5bnD2+8f7Nepkb1FXwlr2Ip5/e9uzoTq8prDxMCdNSZB5i1bcH1YrAYvNPg1I2ynSK +uUTZBne6NjTeymUfmJOToi/NamFz/WdGvfZ4pGwhgpGIYWVMq8IIx8a2xaZbHf2+z8e V7ZstX+Jn2aEZ5ta1OKi48XtFrHjBllO+AX9OS6nhDJvXlApeR776cPhpHRVg2N3WgbR 7TSgZzOx5RjO2sIRtetLyoZAueWvjyP5hSBoE+/fqt3X/nRzQNj9ZPGefTlNm9Gt8RB5 v1hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=P9Al3tNq9A6MMeOWm1tBjYMEjQXzg/zzljHAbch3uHE=; b=O/9EzFEqX74RobH/Ww/vv4I0evafY1BOez1A1MuBLMYqkg1DlDw45ZAMcNNRxZD5DN E8Nq0+5h45HXI/rwiJTsguTbpHga0FcsXE5yDqIXF9gi0jTrJLYC0UmcoCo0N42dF1OS /UY0drMnWfn2v5WMNRDejfkj519rdV3E9faiRbzXddEipnR8YTTAE0eSTJ2dkDf5ydUc Q82yMgydSPYI0admnb1F6ToWMBOvd8l77lINzSyE9tM6oblXBF7ftRrZLKULAjr2bjaj O+NPqnmhKC9y4QE8qbBvdddhw+3G6OkdCk6bjYNv7nUTIPdBoX/8aUmZR03xfa3JHuws 1zRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=exjIFcmC; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l64-20020a638843000000b003aa7751c597si7971179pgd.418.2022.04.22.14.33.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 14:33:08 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=exjIFcmC; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D3C412EFF3D; Fri, 22 Apr 2022 12:40:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1445493AbiDVIMS (ORCPT + 99 others); Fri, 22 Apr 2022 04:12:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380772AbiDVIMQ (ORCPT ); Fri, 22 Apr 2022 04:12:16 -0400 Received: from m15111.mail.126.com (m15111.mail.126.com [220.181.15.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6C45952E45; Fri, 22 Apr 2022 01:09:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=P9Al3 tNq9A6MMeOWm1tBjYMEjQXzg/zzljHAbch3uHE=; b=exjIFcmCrLsMuwFfGTt9Q kqgmOWPJhpQ78BytXMC3CG9OY89HALmf9gZArLHuwa6aEjxAbJQVjrucwkGtNXoV Ohlrp7saaaGgkiiTqXl120CiG0WfCdbAlor/3DjMA0a8vdHU8+4uCSMer2FjrAnB Xrx4LbHTV+1QoAW4mWB1zI= Received: from ubuntu.localdomain (unknown [58.213.83.157]) by smtp1 (Coremail) with SMTP id C8mowAA3n9+aYmJic1AdBA--.42425S4; Fri, 22 Apr 2022 16:08:59 +0800 (CST) From: Bernard Zhao To: Jakub Kicinski , Kalle Valo , "David S. Miller" , Paolo Abeni , Matthias Brugger , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Cc: bernard@vivo.com, Bernard Zhao Subject: [PATCH v2] mediatek/mt7601u: add debugfs exit function Date: Fri, 22 Apr 2022 01:08:54 -0700 Message-Id: <20220422080854.490379-1-zhaojunkui2008@126.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: C8mowAA3n9+aYmJic1AdBA--.42425S4 X-Coremail-Antispam: 1Uf129KBjvJXoWxCr1xWF18Ar45GFy8KFWruFg_yoWrXrWUpa yDKa4Ykw18Zr15G3yfCF1UZryrGas3Wr17JF95Z345Z3y8Ar1Fq3WjqFy7ZasxXFZ8A3Wj qF45tF47GryI9FJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zikR67UUUUU= X-Originating-IP: [58.213.83.157] X-CM-SenderInfo: p2kd0y5xqn3xasqqmqqrswhudrp/1tbiuQPqqlpD8lH33AACsp X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When mt7601u loaded, there are two cases: First when mt7601u is loaded, in function mt7601u_probe, if function mt7601u_probe run into error lable err_hw, mt7601u_cleanup didn`t cleanup the debugfs node. Second when the module disconnect, in function mt7601u_disconnect, mt7601u_cleanup didn`t cleanup the debugfs node. This patch add debugfs exit function and try to cleanup debugfs node when mt7601u loaded fail or unloaded. Signed-off-by: Bernard Zhao Changes since V1: *Remove CONFIG_DEBUG_FS check. --- .../net/wireless/mediatek/mt7601u/debugfs.c | 23 +++++++++++-------- drivers/net/wireless/mediatek/mt7601u/init.c | 1 + .../net/wireless/mediatek/mt7601u/mt7601u.h | 3 +++ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt7601u/debugfs.c b/drivers/net/wireless/mediatek/mt7601u/debugfs.c index 20669eacb66e..efc575a1147c 100644 --- a/drivers/net/wireless/mediatek/mt7601u/debugfs.c +++ b/drivers/net/wireless/mediatek/mt7601u/debugfs.c @@ -124,17 +124,20 @@ DEFINE_SHOW_ATTRIBUTE(mt7601u_eeprom_param); void mt7601u_init_debugfs(struct mt7601u_dev *dev) { - struct dentry *dir; - - dir = debugfs_create_dir("mt7601u", dev->hw->wiphy->debugfsdir); - if (!dir) + dev->root_dir = debugfs_create_dir("mt7601u", dev->hw->wiphy->debugfsdir); + if (!dev->root_dir) return; - debugfs_create_u8("temperature", 0400, dir, &dev->raw_temp); - debugfs_create_u32("temp_mode", 0400, dir, &dev->temp_mode); + debugfs_create_u8("temperature", 0400, dev->root_dir, &dev->raw_temp); + debugfs_create_u32("temp_mode", 0400, dev->root_dir, &dev->temp_mode); + + debugfs_create_u32("regidx", 0600, dev->root_dir, &dev->debugfs_reg); + debugfs_create_file("regval", 0600, dev->root_dir, dev, &fops_regval); + debugfs_create_file("ampdu_stat", 0400, dev->root_dir, dev, &mt7601u_ampdu_stat_fops); + debugfs_create_file("eeprom_param", 0400, dev->root_dir, dev, &mt7601u_eeprom_param_fops); +} - debugfs_create_u32("regidx", 0600, dir, &dev->debugfs_reg); - debugfs_create_file("regval", 0600, dir, dev, &fops_regval); - debugfs_create_file("ampdu_stat", 0400, dir, dev, &mt7601u_ampdu_stat_fops); - debugfs_create_file("eeprom_param", 0400, dir, dev, &mt7601u_eeprom_param_fops); +void mt7601u_exit_debugfs(struct mt7601u_dev *dev) +{ + debugfs_remove(dev->root_dir); } diff --git a/drivers/net/wireless/mediatek/mt7601u/init.c b/drivers/net/wireless/mediatek/mt7601u/init.c index 5d9e952b2966..eacdd5785fa6 100644 --- a/drivers/net/wireless/mediatek/mt7601u/init.c +++ b/drivers/net/wireless/mediatek/mt7601u/init.c @@ -427,6 +427,7 @@ void mt7601u_cleanup(struct mt7601u_dev *dev) mt7601u_stop_hardware(dev); mt7601u_dma_cleanup(dev); mt7601u_mcu_cmd_deinit(dev); + mt7601u_exit_debugfs(dev); } struct mt7601u_dev *mt7601u_alloc_device(struct device *pdev) diff --git a/drivers/net/wireless/mediatek/mt7601u/mt7601u.h b/drivers/net/wireless/mediatek/mt7601u/mt7601u.h index a122f1dd38f6..06c190a3f54c 100644 --- a/drivers/net/wireless/mediatek/mt7601u/mt7601u.h +++ b/drivers/net/wireless/mediatek/mt7601u/mt7601u.h @@ -242,6 +242,8 @@ struct mt7601u_dev { u32 rf_pa_mode[2]; struct mac_stats stats; + + struct dentry *root_dir; }; struct mt7601u_tssi_params { @@ -279,6 +281,7 @@ struct mt7601u_rxwi; extern const struct ieee80211_ops mt7601u_ops; void mt7601u_init_debugfs(struct mt7601u_dev *dev); +void mt7601u_exit_debugfs(struct mt7601u_dev *dev); u32 mt7601u_rr(struct mt7601u_dev *dev, u32 offset); void mt7601u_wr(struct mt7601u_dev *dev, u32 offset, u32 val); -- 2.33.1