Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2178632rwd; Fri, 26 May 2023 03:00:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7dTqR/ove2+VOEiF6x5gmfbKjJFO35/02ld/DkmCZ7cA417uKes+GvDoMh26HkH+t5h4cA X-Received: by 2002:a05:6a00:179c:b0:64d:277c:77c3 with SMTP id s28-20020a056a00179c00b0064d277c77c3mr2722762pfg.23.1685095223783; Fri, 26 May 2023 03:00:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685095223; cv=none; d=google.com; s=arc-20160816; b=m9a/2nZBbZHprFnFU6EqBKpfvbnRd/TQ18wXgr+iUaBTrhFyl1vy3Ah1XjqJ8zXB8+ GyN0TXM3uGwetRtVcvK/spF9ihqWkUnpV5M1wia4PLl60DFJSQjFili+AUz+G1pGgWYO lI/tY5aiRaAZrksUrFtcHDAitDem7sReK4wemNVHKp836xcpnD/0Cz7P8v3ju8skd3MM b7fAffmMn+oopWMCUQlAGi7QBV7DZTpDiUHFxgQXPLmXXcYz55VCqmm6gnlInRHSwwxl VHjwgInQXkFIkwaXnZK6PdiPjTuwsAZRA5DJeCxQJULwejIwBrFkw1yk3H+7mBXg/XEJ Z/9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=VLn1nwa0TPSZxy0/Uqf/fSCYjrakDuOkiQdrMrFOV3c=; b=JMA5KkDRU4VBsvPBdSUiAOzbM+AKLUDV66BvfWlx7natinS+UypId/6KY18s1juEzX VNRZ7EwdaogiHT4/rVOOrkDgcKw2VG/c2XfhF2NIK6oSWQrMO0Dm43To/wBxzlVYN57z YlXTNLIBxu37cot9cVVGBdNXwhz1hOR8QpmfA8VsoCLgVE6W1EKVv0g3vaYwpBJ0m/Wa aHB18iqiptLDf4/jj0alYgVqZUzmFShqvzEmUdAMW87I68NLZnbbvBxDV6GlWfATlUQA Zc6ytpERcGi2q5OwAp+cCA2z/aZNC8ETZuDD2fNkyhvhQOGBQBX4O1AK4ls2IV/7rloO 7pcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=LeWDVB5V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 19-20020a631553000000b005348977b5c5si1306403pgv.97.2023.05.26.03.00.11; Fri, 26 May 2023 03:00:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=LeWDVB5V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243137AbjEZJcJ (ORCPT + 99 others); Fri, 26 May 2023 05:32:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242710AbjEZJcF (ORCPT ); Fri, 26 May 2023 05:32:05 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F702F3; Fri, 26 May 2023 02:31:59 -0700 (PDT) X-UUID: 262b3a22fba811edb20a276fd37b9834-20230526 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=VLn1nwa0TPSZxy0/Uqf/fSCYjrakDuOkiQdrMrFOV3c=; b=LeWDVB5Vk6iBYSnb9TttkV6cPrH89kV6/SUP0kywQGz2tGUGhZnc6v9Y23B4AcdttSgewp0hvkDyIoOqNZCSFXsaYgN2WjOA4pvKnA5U2adVpf2oKkC749JOxGrVzjtSIlJyavEYjIk0QG1kRRPUL1dNKX/T/H3SVwg/apFpYnw=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.25,REQID:a917842d-f9a4-4869-8b5d-380b4b6d680a,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:d5b0ae3,CLOUDID:390e1a6d-2f20-4998-991c-3b78627e4938,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: 262b3a22fba811edb20a276fd37b9834-20230526 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 31816285; Fri, 26 May 2023 17:31:53 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 26 May 2023 17:31:52 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 26 May 2023 17:31:52 +0800 From: Trevor Wu To: , , , , , , , , CC: , , , , , , Subject: [PATCH v3 5/7] ASoC: soc-dapm.c: clean up debugfs for freed widget Date: Fri, 26 May 2023 17:31:48 +0800 Message-ID: <20230526093150.22923-6-trevor.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230526093150.22923-1-trevor.wu@mediatek.com> References: <20230526093150.22923-1-trevor.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham 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 a widget is added to dapm via snd_soc_dapm_new_widgets, dapm_debugfs_add_widget is also called to create a corresponding debugfs file. However, when a widget is freed by snd_soc_dapm_free_widget, the corresponding debugfs is not cleared. As a result, the freed widget is still seen in the dapm directory. This patch adds dapm_debugfs_free_widget to free the debugfs of a specified widget, and it's called at snd_soc_dapm_free_widget to clean up the debugfs for freed widget. Signed-off-by: Trevor Wu Reviewed-by: Alexandre Mergnat --- sound/soc/soc-dapm.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index f2f04ce693a1..c65cc374bb3f 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -2216,6 +2216,16 @@ static void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w) &dapm_widget_power_fops); } +static void dapm_debugfs_free_widget(struct snd_soc_dapm_widget *w) +{ + struct snd_soc_dapm_context *dapm = w->dapm; + + if (!dapm->debugfs_dapm || !w->name) + return; + + debugfs_lookup_and_remove(w->name, dapm->debugfs_dapm); +} + static void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm) { debugfs_remove_recursive(dapm->debugfs_dapm); @@ -2232,6 +2242,10 @@ static inline void dapm_debugfs_add_widget(struct snd_soc_dapm_widget *w) { } +static inline void dapm_debugfs_free_widget(struct snd_soc_dapm_widget *w) +{ +} + static inline void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm) { } @@ -2495,6 +2509,8 @@ void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w) dapm_free_path(p); } + dapm_debugfs_free_widget(w); + kfree(w->kcontrols); kfree_const(w->name); kfree_const(w->sname); -- 2.18.0