Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4768587pxb; Tue, 25 Jan 2022 19:04:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWHaIU7I7ctLx4Y8ANeGO62ax79iq+ijQ3Bg7fSIR2PRfsgeQmyJH9aI2T5Bqv1bbZobRU X-Received: by 2002:a05:6402:298e:: with SMTP id eq14mr22664503edb.195.1643166242192; Tue, 25 Jan 2022 19:04:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643166242; cv=none; d=google.com; s=arc-20160816; b=BInQvIhsqtQgNNawfQestbakK6wxhOQas9870XStjLolWTyDo8FQ7KT/gx9OjfcK2L cK0uhqpWgo+JS2O7j8iL+8YbwymgjPy5cPikaboi/pEQSviPtlswPPUZS5cTBSF49jwn mVa1uRbqOVlq88DmoXfvwP4gOdijxJvzUib2iXhObHFVH1qT43XeONXpJd0rkbyDd3bF 2+9dH17Z5QLP2/yBDQgvU+ZbTGoyeIXiCLaJqG4YYtX7qAGjRPs21ZyKfYSHrp+B/e9H LeXe8mOAA/en16mq/foflAQYarubCdWl0BB+lqxB6Q5v/OvaJBCfGraYaJL1C5ij6mTV KiSA== 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=4OcUk1aI4DBowUgi9FbYRL4icrOozYolDh/xNVpwzAg=; b=Vm7LCSkiWDXjZAkj00ucTcnWc1SuMYpqBjKovC/0Cz6woaGGd4YpVTF2JbRZpOgaJB kEqDn01dXAFl4zjIWQbkFEaJpWVhdsys7CYLskHt2FZJs6sEdMN72atMKe+5fL7B5N2S pNUuUzlXBDDzPszFXW2BG4xPevNZ7yqXycNg6uNOVVc0uCnBfgPl8uxAyvRiVEXBtzYq b/iM3czySr0rhga+mLoQHYJUYlu21Irv2e9WnLjoBL01D6zvAP4be/nOrenw0NRN4kMv 0eTXM6XYGzq86EnoI9CS0TQidK3nRqFSiFCDz44lUqDEJeGk85+sB8NsLS8jo8PCwveC bcsw== 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 h18si13526041ede.435.2022.01.25.19.03.38; Tue, 25 Jan 2022 19:04:02 -0800 (PST) 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 S1351514AbiAYR0m (ORCPT + 99 others); Tue, 25 Jan 2022 12:26:42 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:52228 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1587972AbiAYRUz (ORCPT ); Tue, 25 Jan 2022 12:20:55 -0500 X-UUID: 184af9e70a2e4f999570725a7bbf33c2-20220126 X-UUID: 184af9e70a2e4f999570725a7bbf33c2-20220126 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1183598316; Wed, 26 Jan 2022 01:20:49 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Wed, 26 Jan 2022 01:20:48 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 26 Jan 2022 01:20:48 +0800 From: Miles Chen To: CC: , , , , , , , Subject: Re: [PATCH 09/31] clk: mediatek: mux: Implement unregister API Date: Wed, 26 Jan 2022 01:20:48 +0800 Message-ID: <20220125172048.4239-1-miles.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220122091731.283592-10-wenst@chromium.org> References: <20220122091731.283592-10-wenst@chromium.org> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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 > --- > 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 */ > -- > 2.35.0.rc0.227.g00780c9af4-goog