From nobody Thu Nov 14 20:15:47 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 34835C433F5 for ; Tue, 8 Feb 2022 13:19:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347564AbiBHNTV (ORCPT ); Tue, 8 Feb 2022 08:19:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358457AbiBHMlY (ORCPT ); Tue, 8 Feb 2022 07:41:24 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 215AFC03FEC0 for ; Tue, 8 Feb 2022 04:41:24 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id x65so4132102pfx.12 for ; Tue, 08 Feb 2022 04:41:24 -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=0jvgrG3Dmpy1I6S7Dz5gEHIA3LIp2Xa/xR1uXh6G5dU=; b=OO1r4dxadJOGLUSOKAN0tmHzPQa1/FnX57PE28Fw2+knHtrP1i77Wg2a5G/AUHfj7F XJe4SgQaXUtNYtLJaaI40p7JgRIe15fGPHDGLYG3xHdNTVULkjQ59t51I+2PyOThCt2P 5n4cgfYK6ehEyeCRKJw4xyfPqumGi9TgdpYyk= 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=0jvgrG3Dmpy1I6S7Dz5gEHIA3LIp2Xa/xR1uXh6G5dU=; b=fwh+zWxs8XHXPmWCOUDs+9tZKEjWQ4y90di6Rhwr2Ia402miU2BwLx9Bz9Xug6U7c6 78STHaDeFpuxY2pCDJF5vgZhoUE0leF5VCcW3nYsG/O4LdUuqQqpyYiT40cJ9vN44lT/ ZlNnBxfGE5aLrfnjRb45b0H2MFdUZsW1dnLDAFKKIdyO6/HgYNCnZEofegr4vJ+t5po6 YhbQmxwWcis1MDEknu81eb/b0NVqO1YFzafateKwmMSCho7SUPgsvEQC36NQWfpfI7CX 3FIDnck19P9SyXs9EYGEK+H/HG38ZG1ZiSA6p6Qa0zCybJSqcE4qfYfTzBSBR0JoCozK CIgA== X-Gm-Message-State: AOAM5325ABS7a6ja2kmq8lU35QYrM8/YVR8oJ1TU90eBUHCakfifwZNK 3FfPvvRwM1SHLUaE59xbJ0nQM9VlrxFmtw== X-Google-Smtp-Source: ABdhPJxlQ6xRfe3jgexdVmS/BecwJ0yJF53+WUSqv5aNmcGH8QFSxeRwNVd6B/u1PMoMOp5zWvGwTA== X-Received: by 2002:a63:9307:: with SMTP id b7mr3353508pge.291.1644324083669; Tue, 08 Feb 2022 04:41:23 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 04:41:23 -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 16/31] clk: mediatek: Implement mtk_clk_unregister_factors() API Date: Tue, 8 Feb 2022 20:40:19 +0800 Message-Id: <20220208124034.414635-17-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_factors(), as the name suggests, is used to register a given list of fixed factor 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: Miles Chen Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-mtk.c | 20 ++++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 6 ++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 7c0d5706eed7..b267b2f04b84 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -126,6 +126,26 @@ void mtk_clk_register_factors(const struct mtk_fixed_f= actor *clks, } EXPORT_SYMBOL_GPL(mtk_clk_register_factors); =20 +void mtk_clk_unregister_factors(const struct mtk_fixed_factor *clks, int n= um, + struct clk_onecell_data *clk_data) +{ + int i; + + if (!clk_data) + return; + + for (i =3D num; i > 0; i--) { + const struct mtk_fixed_factor *ff =3D &clks[i - 1]; + + if (IS_ERR_OR_NULL(clk_data->clks[ff->id])) + continue; + + clk_unregister_fixed_factor(clk_data->clks[ff->id]); + clk_data->clks[ff->id] =3D ERR_PTR(-ENOENT); + } +} +EXPORT_SYMBOL_GPL(mtk_clk_unregister_factors); + struct clk *mtk_clk_register_composite(const struct mtk_composite *mc, void __iomem *base, spinlock_t *lock) { diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index cc7f920eabb4..4db1a97c1250 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -55,8 +55,10 @@ struct mtk_fixed_factor { .div =3D _div, \ } =20 -void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, - int num, struct clk_onecell_data *clk_data); +void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, int num, + struct clk_onecell_data *clk_data); +void mtk_clk_unregister_factors(const struct mtk_fixed_factor *clks, int n= um, + struct clk_onecell_data *clk_data); =20 struct mtk_composite { int id; --=20 2.35.0.263.gb82422642f-goog