From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1835C433EF for ; Tue, 15 Feb 2022 06:30:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234424AbiBOGaS (ORCPT ); Tue, 15 Feb 2022 01:30:18 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234416AbiBOGaQ (ORCPT ); Tue, 15 Feb 2022 01:30:16 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 175F411EF05; Mon, 14 Feb 2022 22:30:06 -0800 (PST) X-UUID: 61d3750791e7462cb037c38bacaae792-20220215 X-UUID: 61d3750791e7462cb037c38bacaae792-20220215 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1471671154; Tue, 15 Feb 2022 14:30:02 +0800 Received: from mtkexhb01.mediatek.inc (172.21.101.102) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 15 Feb 2022 14:30:01 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkexhb01.mediatek.inc (172.21.101.102) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 15 Feb 2022 14:30:01 +0800 Received: from mtksdccf07 (172.21.84.99) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 15 Feb 2022 14:30:01 +0800 Message-ID: Subject: Re: [PATCH v3 09/31] clk: mediatek: mux: Implement unregister API From: Chun-Jie Chen To: Chen-Yu Tsai , Stephen Boyd , Michael Turquette , Matthias Brugger CC: AngeloGioacchino Del Regno , Miles Chen , , , , Date: Tue, 15 Feb 2022 14:30:01 +0800 In-Reply-To: <20220208124034.414635-10-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> <20220208124034.414635-10-wenst@chromium.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2022-02-08 at 20:40 +0800, Chen-Yu Tsai wrote: > The mux clk type within the MediaTek clk driver library only has a > register function, and no corresponding unregister function. This > means there is no way for its users to properly implement cleanup > and removal. > > Add a matching unregister function for the mux type clk. > > Signed-off-by: Chen-Yu Tsai > Reviewed-by: Miles Chen > Reviewed-by: AngeloGioacchino Del Regno < > angelogioacchino.delregno@collabora.com> Reviewed-by: Chun-Jie Chen > --- > drivers/clk/mediatek/clk-mux.c | 35 > ++++++++++++++++++++++++++++++++++ > drivers/clk/mediatek/clk-mux.h | 3 +++ > 2 files changed, 38 insertions(+) > > diff --git a/drivers/clk/mediatek/clk-mux.c > b/drivers/clk/mediatek/clk-mux.c > index 89f23e111d91..6f0c22a699c3 100644 > --- a/drivers/clk/mediatek/clk-mux.c > +++ b/drivers/clk/mediatek/clk-mux.c > @@ -164,6 +164,21 @@ static struct clk *mtk_clk_register_mux(const > struct mtk_mux *mux, > return clk; > } > > +static void mtk_clk_unregister_mux(struct clk *clk) > +{ > + struct mtk_clk_mux *mux; > + struct clk_hw *hw; > + > + hw = __clk_get_hw(clk); > + if (!hw) > + return; > + > + mux = to_mtk_clk_mux(hw); > + > + clk_unregister(clk); > + kfree(mux); > +} > + > int mtk_clk_register_muxes(const struct mtk_mux *muxes, > int num, struct device_node *node, > spinlock_t *lock, > @@ -198,4 +213,24 @@ int mtk_clk_register_muxes(const struct mtk_mux > *muxes, > } > EXPORT_SYMBOL_GPL(mtk_clk_register_muxes); > > +void mtk_clk_unregister_muxes(const struct mtk_mux *muxes, int num, > + struct clk_onecell_data *clk_data) > +{ > + int i; > + > + if (!clk_data) > + return; > + > + for (i = num; i > 0; i--) { > + const struct mtk_mux *mux = &muxes[i - 1]; > + > + if (IS_ERR_OR_NULL(clk_data->clks[mux->id])) > + continue; > + > + mtk_clk_unregister_mux(clk_data->clks[mux->id]); > + clk_data->clks[mux->id] = ERR_PTR(-ENOENT); > + } > +} > +EXPORT_SYMBOL_GPL(mtk_clk_unregister_muxes); > + > MODULE_LICENSE("GPL"); > diff --git a/drivers/clk/mediatek/clk-mux.h > b/drivers/clk/mediatek/clk-mux.h > index 27841d649118..cb2ac4f04c58 100644 > --- a/drivers/clk/mediatek/clk-mux.h > +++ b/drivers/clk/mediatek/clk-mux.h > @@ -88,4 +88,7 @@ int mtk_clk_register_muxes(const struct mtk_mux > *muxes, > spinlock_t *lock, > struct clk_onecell_data *clk_data); > > +void mtk_clk_unregister_muxes(const struct mtk_mux *muxes, int num, > + struct clk_onecell_data *clk_data); > + > #endif /* __DRV_CLK_MTK_MUX_H */