Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp281272pxb; Mon, 13 Sep 2021 19:18:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyu8psp6U6Y/rhhA8FmGjde2s4xrc5cm7eL9osD/X/jQuz/alfZ9rtGFu4/rCNMsaj7VFfY X-Received: by 2002:a05:6e02:110f:: with SMTP id u15mr6132693ilk.6.1631585895683; Mon, 13 Sep 2021 19:18:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631585895; cv=none; d=google.com; s=arc-20160816; b=cot7xLWjKdCyv1LPPnJBPqfPqQInlM9xAMVnBNCksDcdFvoGBUdShFMfOE5AOuUA+1 3TWqjSoAUNMUri2UK4IgiUJ9V/S1PxctNeV7bokzUzO0khsTi98W7UgxOplSUmz4zVws Wzf3daBX7sWMvCfYad6SvGr0esUhzCMr1QEYrO18xOiqq3q6NSj9GW35xtyKi2xNJSo9 AGPnmrmXRKTr0q9sjjOPShRT7jxo/r3nwTSC4GIfgIsoGvIJGBlGzLK0I8xMh+fOLtMa lMDA+5kgTangpS7C2WBfjhYJ3g7fvHe0VNkx4isf0xJndV+sveEig8gYliQZa5zmvke7 FCwQ== 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; bh=4XsEO9IAbYBlfFEQcrbqDEyUfOVupjYi+DRBmZnOAb4=; b=Zd3+h0BQ1Aezo+0NYCEqn3DBAkJ2znP46XjkSZsfHjxdsacZs5mgpNbkERrvPOHZop v5UTJFd8/VbCdFaKnlPULsKkTXQ/j67JZ/J0RebGWJcyc/dilFlgJadfQ9HGn9vPP6lL rUBDI2w8+Fl6WldYthzcIU1uNP4RMYb8D1o1QEJ0By+9VXL50E6tck3YClZUZH8be+77 JlVxoEpiEJrTtChvhzYmRTMSDA0QcDlngXrw97UvnWQHH52GqPwT4HzvljQ7C7/PQx0j iddytCIbiUd3Gt7yjwCuV5KFudBL0GI2vGnVa9UZeNvWMhfocQ6Nu+A+S0/azmAVxbz/ ImVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f5si8448981ion.100.2021.09.13.19.18.04; Mon, 13 Sep 2021 19:18:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237590AbhINCSX (ORCPT + 99 others); Mon, 13 Sep 2021 22:18:23 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:33506 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S237553AbhINCSR (ORCPT ); Mon, 13 Sep 2021 22:18:17 -0400 X-UUID: 2f35a480fcb04505a875a5bb0bd4b748-20210914 X-UUID: 2f35a480fcb04505a875a5bb0bd4b748-20210914 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 312948156; Tue, 14 Sep 2021 10:16:57 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 14 Sep 2021 10:16:56 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 14 Sep 2021 10:16:56 +0800 From: Chun-Jie Chen To: Matthias Brugger , Stephen Boyd , Nicolas Boichat , Rob Herring CC: , , , , , , , Chun-Jie Chen Subject: [v3 04/24] clk: mediatek: Add API for clock resource recycle Date: Tue, 14 Sep 2021 10:16:13 +0800 Message-ID: <20210914021633.26377-5-chun-jie.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210914021633.26377-1-chun-jie.chen@mediatek.com> References: <20210914021633.26377-1-chun-jie.chen@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to avoid resource leak when fail clock registration appears, so adds the common interface to handle it. Signed-off-by: Chun-Jie Chen Reviewed-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mtk.c | 9 +++++++++ drivers/clk/mediatek/clk-mtk.h | 1 + 2 files changed, 10 insertions(+) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 4b6096c44d74..c3d385c0cfcb 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -43,6 +43,15 @@ struct clk_onecell_data *mtk_alloc_clk_data(unsigned int clk_num) return NULL; } +void mtk_free_clk_data(struct clk_onecell_data *clk_data) +{ + if (!clk_data) + return; + + kfree(clk_data->clks); + kfree(clk_data); +} + void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num, struct clk_onecell_data *clk_data) { diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index 7de41c3b3206..0ff289d93452 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -202,6 +202,7 @@ void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, struct clk_onecell_data *clk_data); struct clk_onecell_data *mtk_alloc_clk_data(unsigned int clk_num); +void mtk_free_clk_data(struct clk_onecell_data *clk_data); #define HAVE_RST_BAR BIT(0) #define PLL_AO BIT(1) -- 2.18.0