From nobody Thu Nov 14 20:15:17 2024 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 04BA4C433F5 for ; Tue, 8 Feb 2022 13:22:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377203AbiBHNWQ (ORCPT ); Tue, 8 Feb 2022 08:22:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358510AbiBHMl3 (ORCPT ); Tue, 8 Feb 2022 07:41:29 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F006C03FECA for ; Tue, 8 Feb 2022 04:41:28 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id i17so18617692pfq.13 for ; Tue, 08 Feb 2022 04:41:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rLQw4RJqDZVMPw30M9uz1PhQpXBhvEj1u6VLau9OtwY=; b=jL2a5QDyajKzOUAWV5B0Nd19HhIgfINHJvM9WNEn6b+LxDB4bDUyKQZLkDZMB1szH8 sSKODHRSvOsJrGymmMHci7fr5tCxsmLXcZm38aNquOg8tvsqskd0Of82WHAiGSpdjBVg LJb7i6DxEMHHloBmjgN+29AbkGYR//LBVbPzo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rLQw4RJqDZVMPw30M9uz1PhQpXBhvEj1u6VLau9OtwY=; b=JREbFeKkeP8nDlt3cHoHH9C9XjJRzdsUik6UxYeZ19C922zU2akRLM0596+rWKepak IRMUNNDVSmv2d6LBy5sHVZWaTSxKxkDIf/DaPyXIb72rHGIo7GIuCAAt6W2P9PTmrEUK m0R1MxGiDXjNUdYYi+8cCCYvFwhqDDmh5suvUgLo4GdBmyuKvp7Ngf1K/Ikw0eh2v0ju rSo1pzHEfoRv/mLjhTaz7rPZpWf7p8vRz6PVYpcU2+TV8mSWrFBXqMWPBca5XFst7nUu WAk6wvrcCTNazFpn45a0nxxxvzzZYfBFV2ytiQWfU4wjmGMuzn/4GjNfj02R5WCsBw7N CPDg== X-Gm-Message-State: AOAM530vUttPJYed5q3E1Cg9nurJSsjdPrrlvlz/MSXVuoBcTQy9vnVb bmqzlGZBQpMu2Mq2iQWtsiTluA== X-Google-Smtp-Source: ABdhPJyoH//QGDvsw16k4jMFINHEtKQ6bLu2VPWjf6rsSG2qmmitjA3mxEh+PsT2umh3po921k0HrQ== X-Received: by 2002:a63:2f82:: with SMTP id v124mr3314490pgv.139.1644324088094; Tue, 08 Feb 2022 04:41:28 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:41b6:813e:c823:609c]) by smtp.gmail.com with ESMTPSA id h11sm15056939pfe.214.2022.02.08.04.41.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:27 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , AngeloGioacchino Del Regno , Miles Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 18/31] clk: mediatek: Implement mtk_clk_unregister_composites() API Date: Tue, 8 Feb 2022 20:40:21 +0800 Message-Id: <20220208124034.414635-19-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208124034.414635-1-wenst@chromium.org> References: <20220208124034.414635-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" mtk_clk_register_composites(), as the name suggests, is used to register a given list of composite clks. However it is lacking a counterpart unregister API. Implement said unregister API so that the various clock platform drivers can utilize it to do proper unregistration, cleanup and removal. In the header file, the register function's declaration is also reformatted to fit code style guidelines. Signed-off-by: Chen-Yu Tsai Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Miles Chen Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-mtk.c | 46 ++++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 2 ++ 2 files changed, 48 insertions(+) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 3a6dfe445e63..869e6ae55c82 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -233,6 +233,32 @@ struct clk *mtk_clk_register_composite(const struct mt= k_composite *mc, return ERR_PTR(ret); } =20 +static void mtk_clk_unregister_composite(struct clk *clk) +{ + struct clk_hw *hw; + struct clk_composite *composite; + struct clk_mux *mux =3D NULL; + struct clk_gate *gate =3D NULL; + struct clk_divider *div =3D NULL; + + hw =3D __clk_get_hw(clk); + if (!hw) + return; + + composite =3D to_clk_composite(hw); + if (composite->mux_hw) + mux =3D to_clk_mux(composite->mux_hw); + if (composite->gate_hw) + gate =3D to_clk_gate(composite->gate_hw); + if (composite->rate_hw) + div =3D to_clk_divider(composite->rate_hw); + + clk_unregister_composite(clk); + kfree(div); + kfree(gate); + kfree(mux); +} + void mtk_clk_register_composites(const struct mtk_composite *mcs, int num, void __iomem *base, spinlock_t *lock, struct clk_onecell_data *clk_data) @@ -259,6 +285,26 @@ void mtk_clk_register_composites(const struct mtk_comp= osite *mcs, } EXPORT_SYMBOL_GPL(mtk_clk_register_composites); =20 +void mtk_clk_unregister_composites(const struct mtk_composite *mcs, int nu= m, + struct clk_onecell_data *clk_data) +{ + int i; + + if (!clk_data) + return; + + for (i =3D num; i > 0; i--) { + const struct mtk_composite *mc =3D &mcs[i - 1]; + + if (IS_ERR_OR_NULL(clk_data->clks[mc->id])) + continue; + + mtk_clk_unregister_composite(clk_data->clks[mc->id]); + clk_data->clks[mc->id] =3D ERR_PTR(-ENOENT); + } +} +EXPORT_SYMBOL_GPL(mtk_clk_unregister_composites); + void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num, void __iomem *base, spinlock_t *lock, struct clk_onecell_data *clk_data) diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index e3ae22fb0334..3c3a934f53cd 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -153,6 +153,8 @@ struct clk *mtk_clk_register_composite(const struct mtk= _composite *mc, void mtk_clk_register_composites(const struct mtk_composite *mcs, int num, void __iomem *base, spinlock_t *lock, struct clk_onecell_data *clk_data); +void mtk_clk_unregister_composites(const struct mtk_composite *mcs, int nu= m, + struct clk_onecell_data *clk_data); =20 struct mtk_clk_divider { int id; --=20 2.35.0.263.gb82422642f-goog