From nobody Thu Nov 14 11:07:19 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 B70D2C433F5 for ; Sat, 22 Jan 2022 09:19:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233166AbiAVJTQ (ORCPT ); Sat, 22 Jan 2022 04:19:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234211AbiAVJSh (ORCPT ); Sat, 22 Jan 2022 04:18:37 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 187A1C06175C for ; Sat, 22 Jan 2022 01:18:25 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id s2-20020a17090ad48200b001b501977b23so10760056pju.2 for ; Sat, 22 Jan 2022 01:18:25 -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=/W+xKFLd9pAMfBNMVJ4svP7XH9i2778pmii7z75+YJU=; b=gGYae5caEwlDlR3SVSNgX/JX1yhbQuv8yWgfZAa2aQstNGgg3l5EKYMgRQhKmoQSgY hae5FE9AcZC/I7yfenInwQdl6GqU1xGGl44VsdAoRBX4Pzp711KfRxPc7RplsHvYkLiN GRkaRSRjncUeyzOms95i9xiNVQSLxX0+flLBA= 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=/W+xKFLd9pAMfBNMVJ4svP7XH9i2778pmii7z75+YJU=; b=21TR89R73uibsVjh2fd41TAVFrwMszEhgSceDRVcPWcts6z7Tal/EG7DCeeHcTcqAp lQ3Ljvltre+Z75846XkJRBYUyHMhcpZ7Scr4e2ltiwCZsZ9Lyu4QVf9gVLtHQP9qk5Vi WPCf7Oai5eoxU7AiBpSsSr5O/nMqET3Vp3wwa4Ziat+YQjIqE7lEp6pT37xJAZHnKpdM 1FjNSZPA+xtyAomCzVSUhG4AwjVbZnnB5bfyuPTm7JFVMf3xQU/B0i4EUlI9UVaNicgp NeU/xwmXc72iBhV/E0A3LQRL7z4n+NKfPdw6XlyjUy0m71+UNZyF50tfR3oIiZAmi7ZA BS4Q== X-Gm-Message-State: AOAM533VZl1AMFRRYF1PD60lGM2psvcRHQSeM/fuuQvHfXtn6zCOUJ9x HHz2vDJh4RtBliX55jtZS/wXTA== X-Google-Smtp-Source: ABdhPJyv5T92Xosh6p3+LrrmQcfNNuzhflROpfIIbeG/5n22BfU1WA+DYYiAH5puDGFs3fs6pmQlWA== X-Received: by 2002:a17:90a:9488:: with SMTP id s8mr4431625pjo.40.1642843104700; Sat, 22 Jan 2022 01:18:24 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:349f:9373:45d9:eb26]) by smtp.gmail.com with ESMTPSA id s1sm1608100pjn.42.2022.01.22.01.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:24 -0800 (PST) From: Chen-Yu Tsai To: Stephen Boyd , Michael Turquette , Matthias Brugger Cc: Chen-Yu Tsai , Chun-Jie Chen , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 18/31] clk: mediatek: Implement mtk_clk_unregister_composites() API Date: Sat, 22 Jan 2022 17:17:18 +0800 Message-Id: <20220122091731.283592-19-wenst@chromium.org> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog In-Reply-To: <20220122091731.283592-1-wenst@chromium.org> References: <20220122091731.283592-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 --- drivers/clk/mediatek/clk-mtk.c | 41 ++++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 2 ++ 2 files changed, 43 insertions(+) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 3a6dfe445e63..2150ed8678e0 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -233,6 +233,27 @@ 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 =3D __clk_get_hw(clk); + struct clk_composite *composite =3D to_clk_composite(hw); + struct clk_mux *mux =3D NULL; + struct clk_gate *gate =3D NULL; + struct clk_divider *div =3D NULL; + + 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 +280,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.rc0.227.g00780c9af4-goog