From nobody Wed Nov 13 15:09:40 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 B09F2C433FE for ; Sat, 22 Jan 2022 09:17:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233973AbiAVJRv (ORCPT ); Sat, 22 Jan 2022 04:17:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233957AbiAVJRr (ORCPT ); Sat, 22 Jan 2022 04:17:47 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50670C06173D for ; Sat, 22 Jan 2022 01:17:47 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id i1so1220100pla.0 for ; Sat, 22 Jan 2022 01:17:47 -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=cKhWG1UlZ1wmUfPV0n39xCAO+4j4+uvVlQIR68vv/e4=; b=DykrC2EFeANQsQVnVW4/ohuox0aeS5K+ZzQ1uNXadn0yUKbkohFjVmkJyce7NXleiV 3YiJS4JglUP6TPz9Kh+yPXtyBt1Q8SaCr+tiHYvM+i0i+8BMGzrzE4HJy/Bmlu2NLAtl JzKF8/zsI3047BtH7bx5csKm1PrYyylE3FzPE= 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=cKhWG1UlZ1wmUfPV0n39xCAO+4j4+uvVlQIR68vv/e4=; b=60BjwmtQ3m9RQ2PXABm070BQjWgSXMTKFFyc5xAtfvMOl4UWXiVEnWbEOLtBX3/1Ox HTTqxxkmYVhvjiSDBWGJa7B9bgHOyR4bJTQgse1/3gKor6XYj2Ajnc3FP+jRh4KqEL4U R3W+6Pqzw83Z8qnps71iPysF3FCVfjSL71Vd/VqXtDw/JBhrSDeA851LBtjjP8QaS+ov UkIEGk64DQfOR3Evp+Ra/ASnTNGeIF31dml/yi+MflJRyBsVeie0AIy5UcMTOBTFHK74 4hOFei7dyA2OLe8xJnEiJN8y5ghQ4B2S71tww17xImwA0rv2ttYVE3CFn223XOd7D/KH Aieg== X-Gm-Message-State: AOAM533JBxfb7IwsIYlm7kCf1i4p+tH//Abob98kH9EQhsvh9feqnrxL hHRaIrI8ZWXzjieeKlxKtNaEW/+NP92ipg== X-Google-Smtp-Source: ABdhPJwsOZbFGXu/nP9ymuPfgGkL2eYRhlwXkc/6m/4AM7H2Snn11NfFQ3CnBQ/MwQdKOi6J4JuWOw== X-Received: by 2002:a17:902:7c93:b0:14a:ec87:5044 with SMTP id y19-20020a1709027c9300b0014aec875044mr7118525pll.31.1642843066874; Sat, 22 Jan 2022 01:17:46 -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.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:17:46 -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 01/31] clk: mediatek: Use %pe to print errors Date: Sat, 22 Jan 2022 17:17:01 +0800 Message-Id: <20220122091731.283592-2-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" If %pe is used to print errors, a string representation of the error would be printed instead of a number as with %ld. Also, all the sites printing errors are deriving the error code from a pointer. Using %pe is more straightforward. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-apmixed.c | 2 +- drivers/clk/mediatek/clk-cpumux.c | 6 ++---- drivers/clk/mediatek/clk-mtk.c | 18 ++++++------------ drivers/clk/mediatek/clk-mux.c | 6 ++---- drivers/clk/mediatek/clk-pll.c | 3 +-- drivers/clk/mediatek/reset.c | 3 +-- 6 files changed, 13 insertions(+), 25 deletions(-) diff --git a/drivers/clk/mediatek/clk-apmixed.c b/drivers/clk/mediatek/clk-= apmixed.c index caa9119413f1..a29339cc26c4 100644 --- a/drivers/clk/mediatek/clk-apmixed.c +++ b/drivers/clk/mediatek/clk-apmixed.c @@ -92,7 +92,7 @@ struct clk * __init mtk_clk_register_ref2usb_tx(const cha= r *name, clk =3D clk_register(NULL, &tx->hw); =20 if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", name, clk); kfree(tx); } =20 diff --git a/drivers/clk/mediatek/clk-cpumux.c b/drivers/clk/mediatek/clk-c= pumux.c index e188018bc906..cab5095416b6 100644 --- a/drivers/clk/mediatek/clk-cpumux.c +++ b/drivers/clk/mediatek/clk-cpumux.c @@ -87,8 +87,7 @@ int mtk_clk_register_cpumuxes(struct device_node *node, =20 regmap =3D device_node_to_regmap(node); if (IS_ERR(regmap)) { - pr_err("Cannot find regmap for %pOF: %ld\n", node, - PTR_ERR(regmap)); + pr_err("Cannot find regmap for %pOF: %pe\n", node, regmap); return PTR_ERR(regmap); } =20 @@ -97,8 +96,7 @@ int mtk_clk_register_cpumuxes(struct device_node *node, =20 clk =3D mtk_clk_register_cpumux(mux, regmap); if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", - mux->name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", mux->name, clk); continue; } =20 diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 8d5791b3f460..519a461cbb6f 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -70,8 +70,7 @@ void mtk_clk_register_fixed_clks(const struct mtk_fixed_c= lk *clks, rc->rate); =20 if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", - rc->name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", rc->name, clk); continue; } =20 @@ -97,8 +96,7 @@ void mtk_clk_register_factors(const struct mtk_fixed_fact= or *clks, CLK_SET_RATE_PARENT, ff->mult, ff->div); =20 if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", - ff->name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", ff->name, clk); continue; } =20 @@ -122,8 +120,7 @@ int mtk_clk_register_gates_with_dev(struct device_node = *node, =20 regmap =3D device_node_to_regmap(node); if (IS_ERR(regmap)) { - pr_err("Cannot find regmap for %pOF: %ld\n", node, - PTR_ERR(regmap)); + pr_err("Cannot find regmap for %pOF: %pe\n", node, regmap); return PTR_ERR(regmap); } =20 @@ -141,8 +138,7 @@ int mtk_clk_register_gates_with_dev(struct device_node = *node, gate->shift, gate->ops, gate->flags, dev); =20 if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", - gate->name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", gate->name, clk); continue; } =20 @@ -264,8 +260,7 @@ void mtk_clk_register_composites(const struct mtk_compo= site *mcs, clk =3D mtk_clk_register_composite(mc, base, lock); =20 if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", - mc->name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", mc->name, clk); continue; } =20 @@ -293,8 +288,7 @@ void mtk_clk_register_dividers(const struct mtk_clk_div= ider *mcds, mcd->div_width, mcd->clk_divider_flags, lock); =20 if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", - mcd->name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", mcd->name, clk); continue; } =20 diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c index 6d3a50eb7d6f..89f23e111d91 100644 --- a/drivers/clk/mediatek/clk-mux.c +++ b/drivers/clk/mediatek/clk-mux.c @@ -175,8 +175,7 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, =20 regmap =3D device_node_to_regmap(node); if (IS_ERR(regmap)) { - pr_err("Cannot find regmap for %pOF: %ld\n", node, - PTR_ERR(regmap)); + pr_err("Cannot find regmap for %pOF: %pe\n", node, regmap); return PTR_ERR(regmap); } =20 @@ -187,8 +186,7 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, clk =3D mtk_clk_register_mux(mux, regmap, lock); =20 if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", - mux->name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", mux->name, clk); continue; } =20 diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c index 60d7ffa0b924..f04f724e12e5 100644 --- a/drivers/clk/mediatek/clk-pll.c +++ b/drivers/clk/mediatek/clk-pll.c @@ -378,8 +378,7 @@ void mtk_clk_register_plls(struct device_node *node, clk =3D mtk_clk_register_pll(pll, base); =20 if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %ld\n", - pll->name, PTR_ERR(clk)); + pr_err("Failed to register clk %s: %pe\n", pll->name, clk); continue; } =20 diff --git a/drivers/clk/mediatek/reset.c b/drivers/clk/mediatek/reset.c index ffe464ce7ff8..bcec4b89f449 100644 --- a/drivers/clk/mediatek/reset.c +++ b/drivers/clk/mediatek/reset.c @@ -100,8 +100,7 @@ static void mtk_register_reset_controller_common(struct= device_node *np, =20 regmap =3D device_node_to_regmap(np); if (IS_ERR(regmap)) { - pr_err("Cannot find regmap for %pOF: %ld\n", np, - PTR_ERR(regmap)); + pr_err("Cannot find regmap for %pOF: %pe\n", np, regmap); return; } =20 --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:40 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 8CB05C4332F for ; Sat, 22 Jan 2022 09:18:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234012AbiAVJSB (ORCPT ); Sat, 22 Jan 2022 04:18:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233964AbiAVJRt (ORCPT ); Sat, 22 Jan 2022 04:17:49 -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 A4F34C06173B for ; Sat, 22 Jan 2022 01:17:49 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id i65so11048666pfc.9 for ; Sat, 22 Jan 2022 01:17:49 -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=OnlH+02wTY784epgQF/8+qaOubssd1JN7rcUpKc5sdg=; b=IN2wm2XH3BarhBK3YsxYrTPEpo3GPbOh6u1D+ohCgM6749mJYHEreL50ND4arWhV04 CIEwcHWKuub+JbVPxjPTOo0cPp9s/VpE+FQyTj2DvvKEkf7YCZedvklNcZE8G3FS3GyR WAirdrBE3Mj39mWUQ49UgSlxK6799rlJDLGYo= 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=OnlH+02wTY784epgQF/8+qaOubssd1JN7rcUpKc5sdg=; b=GlUNDcHyZCIyiMxrvTfDJseM3+1MtXZ54l2PStX19xH1r6tJ+1R7XT/1+2FsBAikVI 8UukjfgZcYQQXFdxilErqjZ/98s/9LffodIRww2ZoRwhqSaJEFv3ZNdED26aHYV6u9+k BOzb9OBJW5p9Ka7zOIkHwHIXKUjAAswe6tf+XUijdiH/srUvDsyxk4JWKspawKKEQgef wsXk0r5r9/C3uwxsSqOsYkcVn7V+osD0jxVIysgcL1N2RrXCIG+/cSWEwFDhUrS5JkhG CinZAiEUI8EQw24kslN6JoF51W70wGVMkxRbNTfC2rVRsD8BH7sMN0tn9RP5TaZNiz4c kEMg== X-Gm-Message-State: AOAM530Mb7RPyUsho+Pxrf9uqOaT7McmEhKrU1cxaRF7j3FtCYy22cvu i5M1niEQ9p5MCPG0D9he4T3ABA== X-Google-Smtp-Source: ABdhPJyAxtnRfbFm0yvpJVciPEpqwg/fnanW8fcXzIRvKxhJXOmkYyJMlTkEp9XMiARE7xLdzDj0nQ== X-Received: by 2002:a65:4685:: with SMTP id h5mr5535715pgr.14.1642843069126; Sat, 22 Jan 2022 01:17:49 -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.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:17:48 -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 02/31] clk: mediatek: gate: Consolidate gate type clk related code Date: Sat, 22 Jan 2022 17:17:02 +0800 Message-Id: <20220122091731.283592-3-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" Right now some bits of the gate type clk code are in clk-gate.[ch], but other bits are in clk-mtk.[ch]. This is different from the cpumux and mux type clks, for which all of the code are found in the same files. Move the functions that register multiple clks from a given list, mtk_clk_register_gates_with_dev() and mtk_clk_register_gates(), to clk-gate.[ch] to consolidate all the code for the gate type clks. This commit only moves code with minor whitespace fixups to correct the code style. Further improvements, such as internalizing various functions and structures will be done in later commits. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen --- drivers/clk/mediatek/clk-gate.c | 53 ++++++++++++++++++++++++++++++++- drivers/clk/mediatek/clk-gate.h | 25 ++++++++++++++++ drivers/clk/mediatek/clk-mtk.c | 51 ------------------------------- drivers/clk/mediatek/clk-mtk.h | 25 ---------------- 4 files changed, 77 insertions(+), 77 deletions(-) diff --git a/drivers/clk/mediatek/clk-gate.c b/drivers/clk/mediatek/clk-gat= e.c index 5d88b428565b..54921768bfba 100644 --- a/drivers/clk/mediatek/clk-gate.c +++ b/drivers/clk/mediatek/clk-gate.c @@ -11,9 +11,9 @@ #include #include #include +#include #include =20 -#include "clk-mtk.h" #include "clk-gate.h" =20 static u32 mtk_get_clockgating(struct clk_hw *hw) @@ -182,4 +182,55 @@ struct clk *mtk_clk_register_gate( } EXPORT_SYMBOL_GPL(mtk_clk_register_gate); =20 +int mtk_clk_register_gates_with_dev(struct device_node *node, + const struct mtk_gate *clks, int num, + struct clk_onecell_data *clk_data, + struct device *dev) +{ + int i; + struct clk *clk; + struct regmap *regmap; + + if (!clk_data) + return -ENOMEM; + + regmap =3D device_node_to_regmap(node); + if (IS_ERR(regmap)) { + pr_err("Cannot find regmap for %pOF: %pe\n", node, regmap); + return PTR_ERR(regmap); + } + + for (i =3D 0; i < num; i++) { + const struct mtk_gate *gate =3D &clks[i]; + + if (!IS_ERR_OR_NULL(clk_data->clks[gate->id])) + continue; + + clk =3D mtk_clk_register_gate(gate->name, gate->parent_name, + regmap, + gate->regs->set_ofs, + gate->regs->clr_ofs, + gate->regs->sta_ofs, + gate->shift, gate->ops, + gate->flags, dev); + + if (IS_ERR(clk)) { + pr_err("Failed to register clk %s: %pe\n", gate->name, clk); + continue; + } + + clk_data->clks[gate->id] =3D clk; + } + + return 0; +} + +int mtk_clk_register_gates(struct device_node *node, + const struct mtk_gate *clks, int num, + struct clk_onecell_data *clk_data) +{ + return mtk_clk_register_gates_with_dev(node, clks, num, clk_data, NULL); +} +EXPORT_SYMBOL_GPL(mtk_clk_register_gates); + MODULE_LICENSE("GPL"); diff --git a/drivers/clk/mediatek/clk-gate.h b/drivers/clk/mediatek/clk-gat= e.h index 3c3329ec54b7..432b571d23b3 100644 --- a/drivers/clk/mediatek/clk-gate.h +++ b/drivers/clk/mediatek/clk-gate.h @@ -43,6 +43,22 @@ struct clk *mtk_clk_register_gate( unsigned long flags, struct device *dev); =20 +struct mtk_gate_regs { + u32 sta_ofs; + u32 clr_ofs; + u32 set_ofs; +}; + +struct mtk_gate { + int id; + const char *name; + const char *parent_name; + const struct mtk_gate_regs *regs; + int shift; + const struct clk_ops *ops; + unsigned long flags; +}; + #define GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, \ _ops, _flags) { \ .id =3D _id, \ @@ -57,4 +73,13 @@ struct clk *mtk_clk_register_gate( #define GATE_MTK(_id, _name, _parent, _regs, _shift, _ops) \ GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, _ops, 0) =20 +int mtk_clk_register_gates(struct device_node *node, + const struct mtk_gate *clks, int num, + struct clk_onecell_data *clk_data); + +int mtk_clk_register_gates_with_dev(struct device_node *node, + const struct mtk_gate *clks, int num, + struct clk_onecell_data *clk_data, + struct device *dev); + #endif /* __DRV_CLK_GATE_H */ diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 519a461cbb6f..0c5db3c71fdd 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -106,57 +106,6 @@ void mtk_clk_register_factors(const struct mtk_fixed_f= actor *clks, } EXPORT_SYMBOL_GPL(mtk_clk_register_factors); =20 -int mtk_clk_register_gates_with_dev(struct device_node *node, - const struct mtk_gate *clks, - int num, struct clk_onecell_data *clk_data, - struct device *dev) -{ - int i; - struct clk *clk; - struct regmap *regmap; - - if (!clk_data) - return -ENOMEM; - - regmap =3D device_node_to_regmap(node); - if (IS_ERR(regmap)) { - pr_err("Cannot find regmap for %pOF: %pe\n", node, regmap); - return PTR_ERR(regmap); - } - - for (i =3D 0; i < num; i++) { - const struct mtk_gate *gate =3D &clks[i]; - - if (!IS_ERR_OR_NULL(clk_data->clks[gate->id])) - continue; - - clk =3D mtk_clk_register_gate(gate->name, gate->parent_name, - regmap, - gate->regs->set_ofs, - gate->regs->clr_ofs, - gate->regs->sta_ofs, - gate->shift, gate->ops, gate->flags, dev); - - if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %pe\n", gate->name, clk); - continue; - } - - clk_data->clks[gate->id] =3D clk; - } - - return 0; -} - -int mtk_clk_register_gates(struct device_node *node, - const struct mtk_gate *clks, - int num, struct clk_onecell_data *clk_data) -{ - return mtk_clk_register_gates_with_dev(node, - clks, num, clk_data, NULL); -} -EXPORT_SYMBOL_GPL(mtk_clk_register_gates); - 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 0ff289d93452..bdec7dc5e07a 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -150,31 +150,6 @@ void mtk_clk_register_composites(const struct mtk_comp= osite *mcs, int num, void __iomem *base, spinlock_t *lock, struct clk_onecell_data *clk_data); =20 -struct mtk_gate_regs { - u32 sta_ofs; - u32 clr_ofs; - u32 set_ofs; -}; - -struct mtk_gate { - int id; - const char *name; - const char *parent_name; - const struct mtk_gate_regs *regs; - int shift; - const struct clk_ops *ops; - unsigned long flags; -}; - -int mtk_clk_register_gates(struct device_node *node, - const struct mtk_gate *clks, int num, - struct clk_onecell_data *clk_data); - -int mtk_clk_register_gates_with_dev(struct device_node *node, - const struct mtk_gate *clks, - int num, struct clk_onecell_data *clk_data, - struct device *dev); - struct mtk_clk_divider { int id; const char *name; --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 BD03DC43219 for ; Sat, 22 Jan 2022 09:18:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234038AbiAVJSE (ORCPT ); Sat, 22 Jan 2022 04:18:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233975AbiAVJRw (ORCPT ); Sat, 22 Jan 2022 04:17:52 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C89A8C06173D for ; Sat, 22 Jan 2022 01:17:51 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id u11so10872852plh.13 for ; Sat, 22 Jan 2022 01:17:51 -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=IYfVcfmzbfl8NtBT3+EuAhwGblYuELjka3vdiDEtzHI=; b=NgsuzFLRMEqkgAhDepLZDiqZooShEmng/mWpvDvDmJ9MqFWRIrG0WYU51aW3acaBSU lY5MLa8dYgYmA1aGpn8oY7oB89rll/TlYz5usSbFaARxTgJKDJMq8aVSu7GSr4ax1EKF ZlhEMDXNVktStkGp4jg7P8wYoke54GHUoWEwQ= 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=IYfVcfmzbfl8NtBT3+EuAhwGblYuELjka3vdiDEtzHI=; b=y/IKF8HE9reOYBR1+RPbbFeqYhwDQSX0m4yWx0bXs9t2iJCXpRxwkkXSTex0oBTczR u0BSdA5ME3H9DwWOgUEcPdIOFjmY8B3Q9TwdzwAqYecXbvqFzZ5vX6KYb8uCOSpelZsQ qqXpxKv0HXAp9nfNP1a1+N+zwmvwz6yMFkIODTYkRaoGaSLmd+tudMobmTmWPokaXj0Z OHLPN73v9a5IiyrrcgPdDajGVRX2lCUx4VOfmIlG1J17wfXUJoafT+jwCHUsseclIfkn VQzP2qJ2kUvxoPRIsyfNv2vTlHnY5VwCNRm7wlAH90BkGBA6lZLag2Djb0JW6uthzgvZ SyyQ== X-Gm-Message-State: AOAM530temmIUN0+W9YhZBU2k4KQl4nfEK0m79T7Kkn0NF8dWKpp4l6h lsUT+qyffodmOCxznRmKZEKJXA== X-Google-Smtp-Source: ABdhPJyepx5BgVfs2E/KZzdND+69YFZBMR/OAiGeYZ/xGVJtctNBJieEh7MIn+Z/+oV2aVMDwGI7gw== X-Received: by 2002:a17:902:c613:b0:14a:7280:cfd7 with SMTP id r19-20020a170902c61300b0014a7280cfd7mr6903732plr.128.1642843071353; Sat, 22 Jan 2022 01:17:51 -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.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:17:50 -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 03/31] clk: mediatek: gate: Internalize clk implementation Date: Sat, 22 Jan 2022 17:17:03 +0800 Message-Id: <20220122091731.283592-4-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" struct mtk_clk_gate and mtk_clk_register_gate() are not used outside of the gate clk library. Only the API that handles a list of clks is used by the individual platform clk drivers. Internalize the parts that aren't used outside of the implementation. Signed-off-by: Chen-Yu Tsai Reviewed-by: Miles Chen --- drivers/clk/mediatek/clk-gate.c | 35 ++++++++++++++++++++++----------- drivers/clk/mediatek/clk-gate.h | 31 ++--------------------------- 2 files changed, 25 insertions(+), 41 deletions(-) diff --git a/drivers/clk/mediatek/clk-gate.c b/drivers/clk/mediatek/clk-gat= e.c index 54921768bfba..e51cfd8c653c 100644 --- a/drivers/clk/mediatek/clk-gate.c +++ b/drivers/clk/mediatek/clk-gate.c @@ -11,11 +11,28 @@ #include #include #include +#include +#include #include #include +#include =20 #include "clk-gate.h" =20 +struct mtk_clk_gate { + struct clk_hw hw; + struct regmap *regmap; + int set_ofs; + int clr_ofs; + int sta_ofs; + u8 bit; +}; + +static inline struct mtk_clk_gate *to_mtk_clk_gate(struct clk_hw *hw) +{ + return container_of(hw, struct mtk_clk_gate, hw); +} + static u32 mtk_get_clockgating(struct clk_hw *hw) { struct mtk_clk_gate *cg =3D to_mtk_clk_gate(hw); @@ -140,17 +157,12 @@ const struct clk_ops mtk_clk_gate_ops_no_setclr_inv = =3D { }; EXPORT_SYMBOL_GPL(mtk_clk_gate_ops_no_setclr_inv); =20 -struct clk *mtk_clk_register_gate( - const char *name, - const char *parent_name, - struct regmap *regmap, - int set_ofs, - int clr_ofs, - int sta_ofs, - u8 bit, - const struct clk_ops *ops, - unsigned long flags, - struct device *dev) +static struct clk *mtk_clk_register_gate(const char *name, + const char *parent_name, + struct regmap *regmap, int set_ofs, + int clr_ofs, int sta_ofs, u8 bit, + const struct clk_ops *ops, + unsigned long flags, struct device *dev) { struct mtk_clk_gate *cg; struct clk *clk; @@ -180,7 +192,6 @@ struct clk *mtk_clk_register_gate( =20 return clk; } -EXPORT_SYMBOL_GPL(mtk_clk_register_gate); =20 int mtk_clk_register_gates_with_dev(struct device_node *node, const struct mtk_gate *clks, int num, diff --git a/drivers/clk/mediatek/clk-gate.h b/drivers/clk/mediatek/clk-gat= e.h index 432b571d23b3..3d75521ba20c 100644 --- a/drivers/clk/mediatek/clk-gate.h +++ b/drivers/clk/mediatek/clk-gate.h @@ -7,42 +7,15 @@ #ifndef __DRV_CLK_GATE_H #define __DRV_CLK_GATE_H =20 -#include #include - -struct clk; - -struct mtk_clk_gate { - struct clk_hw hw; - struct regmap *regmap; - int set_ofs; - int clr_ofs; - int sta_ofs; - u8 bit; -}; - -static inline struct mtk_clk_gate *to_mtk_clk_gate(struct clk_hw *hw) -{ - return container_of(hw, struct mtk_clk_gate, hw); -} +#include +#include =20 extern const struct clk_ops mtk_clk_gate_ops_setclr; extern const struct clk_ops mtk_clk_gate_ops_setclr_inv; extern const struct clk_ops mtk_clk_gate_ops_no_setclr; extern const struct clk_ops mtk_clk_gate_ops_no_setclr_inv; =20 -struct clk *mtk_clk_register_gate( - const char *name, - const char *parent_name, - struct regmap *regmap, - int set_ofs, - int clr_ofs, - int sta_ofs, - u8 bit, - const struct clk_ops *ops, - unsigned long flags, - struct device *dev); - struct mtk_gate_regs { u32 sta_ofs; u32 clr_ofs; --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 D28A5C43217 for ; Sat, 22 Jan 2022 09:18:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234072AbiAVJSH (ORCPT ); Sat, 22 Jan 2022 04:18:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233982AbiAVJRy (ORCPT ); Sat, 22 Jan 2022 04:17:54 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8931C06173B for ; Sat, 22 Jan 2022 01:17:53 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id i65so11048785pfc.9 for ; Sat, 22 Jan 2022 01:17:53 -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=KtrISZzE0fyOiFLPSAi2/kMw442HF+9pfy36Pe4/Xf0=; b=bUHYjg5d8+RE7Oyrz0Th/IjTPVsgQp2fMYyOe5ITkpZpEeY4GipFThT3+0QJ7LNrcu 34HmkNTRZoTJFGRqdT6ovcQM8cU6kCz2PYRdlNTTNlHzzLxIGWMCQji9Z+O34mxUVtff t1A4FVOMxPgLnnUFmmbL/JDBeS/rEneWjbL9k= 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=KtrISZzE0fyOiFLPSAi2/kMw442HF+9pfy36Pe4/Xf0=; b=jq1LvJIB39nmqlVoqxDpaM8ATFivkmarRX8M5GTV1ql5+RZCS53JkEMkyoTPjQ+Fn8 SmAivdQd7SgsYx1QTWfSfoL8NJ1qFkTv2OVKJOpBASuiOmuGvYCwM+nJqIeHyxWoU9pg y7KG7n2qfM0AN6xRIrrmCQa7JnpevMyp0UyBJboLqd+PhFhgV08HCbH3IGdcryi/Se+F QkJ6O8jM3pdlpuSckiFN/+6WI/cGAaX2zDA5SKKciOka8GvfM2Z3/Azm3vDRA4Ii8QIx D5vGBpR29Sp2O/iPvJSV1TE4PS8HjP222y65SZwgQrjcgclRfRONozJ2Qj/sB4qTcdBY 53CA== X-Gm-Message-State: AOAM532vb+EwdK5GQwh5yPemyU1BnNT+gr4PCMxo9THbVZe6TMrliHhK Qev53VR1vWdSVlSRfFUOwAPheA== X-Google-Smtp-Source: ABdhPJwgCHh5xfiilxhfkgh1LfEmERpWQwhEXhLaMwqsDpTCywBsx/lh+zUVqR5UyUh1HPRGDEAjbw== X-Received: by 2002:a63:3808:: with SMTP id f8mr5460004pga.186.1642843073546; Sat, 22 Jan 2022 01:17:53 -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.17.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:17:53 -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 04/31] clk: mediatek: gate: Implement unregister API Date: Sat, 22 Jan 2022 17:17:04 +0800 Message-Id: <20220122091731.283592-5-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" The gate 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 gate type clk. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-gate.c | 35 +++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-gate.h | 3 +++ 2 files changed, 38 insertions(+) diff --git a/drivers/clk/mediatek/clk-gate.c b/drivers/clk/mediatek/clk-gat= e.c index e51cfd8c653c..ed1ad5535d41 100644 --- a/drivers/clk/mediatek/clk-gate.c +++ b/drivers/clk/mediatek/clk-gate.c @@ -193,6 +193,21 @@ static struct clk *mtk_clk_register_gate(const char *n= ame, return clk; } =20 +static void mtk_clk_unregister_gate(struct clk *clk) +{ + struct mtk_clk_gate *cg; + struct clk_hw *hw; + + hw =3D __clk_get_hw(clk); + if (!hw) + return; + + cg =3D to_mtk_clk_gate(hw); + + clk_unregister(clk); + kfree(cg); +} + int mtk_clk_register_gates_with_dev(struct device_node *node, const struct mtk_gate *clks, int num, struct clk_onecell_data *clk_data, @@ -244,4 +259,24 @@ int mtk_clk_register_gates(struct device_node *node, } EXPORT_SYMBOL_GPL(mtk_clk_register_gates); =20 +void mtk_clk_unregister_gates(const struct mtk_gate *clks, int num, + struct clk_onecell_data *clk_data) +{ + int i; + + if (!clk_data) + return; + + for (i =3D num; i > 0; i--) { + const struct mtk_gate *gate =3D &clks[i - 1]; + + if (IS_ERR_OR_NULL(clk_data->clks[gate->id])) + continue; + + mtk_clk_unregister_gate(clk_data->clks[gate->id]); + clk_data->clks[gate->id] =3D ERR_PTR(-ENOENT); + } +} +EXPORT_SYMBOL_GPL(mtk_clk_unregister_gates); + MODULE_LICENSE("GPL"); diff --git a/drivers/clk/mediatek/clk-gate.h b/drivers/clk/mediatek/clk-gat= e.h index 3d75521ba20c..344adffb6578 100644 --- a/drivers/clk/mediatek/clk-gate.h +++ b/drivers/clk/mediatek/clk-gate.h @@ -55,4 +55,7 @@ int mtk_clk_register_gates_with_dev(struct device_node *n= ode, struct clk_onecell_data *clk_data, struct device *dev); =20 +void mtk_clk_unregister_gates(const struct mtk_gate *clks, int num, + struct clk_onecell_data *clk_data); + #endif /* __DRV_CLK_GATE_H */ --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 089B0C4167B for ; Sat, 22 Jan 2022 09:18:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234091AbiAVJSI (ORCPT ); Sat, 22 Jan 2022 04:18:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233997AbiAVJR4 (ORCPT ); Sat, 22 Jan 2022 04:17:56 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3600EC06173D for ; Sat, 22 Jan 2022 01:17:56 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id s61-20020a17090a69c300b001b4d0427ea2so15446290pjj.4 for ; Sat, 22 Jan 2022 01:17:56 -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=kbKt7ttJEIbn2PG8GXADqtWmeHu+9XOdvvWCDvq3ah8=; b=HNsD0ReKRNDG4ZtQO0GD+qXHMUslr6wilW+RBb24z8L0AosEtrU+AKZV6wZk1k2g5d UDAFJ5iY2XaAbthYJ2P8V+dhnsYtH7/gnu5QJ65OVnxpI1rg7GoU2RG4CPdtmgyNecYK NgI9nutHRuVY/OYbPkUE6pQDesSxO+GaEEcRo= 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=kbKt7ttJEIbn2PG8GXADqtWmeHu+9XOdvvWCDvq3ah8=; b=UCJ04wkoCw5/hmBpoka5du2fcGhogEmkHPLlWutYMzq5/ioLc01nySf0De59jbTUD4 fJ2aHk1NBdQIaq4UBdpLo5SSeN1sB/6WOLHi1LhoRb+taCH3jhtmOHrx+p9tKrClCAT5 88Qv66MnsrmvozPsp6lmcCx0kckSpr364tDv7WgWI6wHQJp52O+syK5Bt6KAvFfmQbUv U+fw4kyTvVJpoz1hJHsiqeE35V8SgkAe8WguybZMp1SylW0RWSRnIqOJPk4bvi0M+3Uj 6F3ViYx+3eDqoEMuQaGcCkcCszCHIAx9Tw0xziFa7SFCl3dyJffN3JsoRI36E07BY1Wf Oxcw== X-Gm-Message-State: AOAM531lYCdJa4wAtnr8FI7xrfBLJ1wTO5X/jdhys6aVmiudju217kLa 1dfLXz4+SQZXd5OpjfsD/QXY5uLN2EKQgA== X-Google-Smtp-Source: ABdhPJz1mN6Vyg0MLeNqvqpKaPRCRA2I5Ia0lsjKPddm7l0OSH/TgsnehVCnbgfVwGDtbynaaYk9iQ== X-Received: by 2002:a17:903:110c:b0:149:9004:4e7c with SMTP id n12-20020a170903110c00b0014990044e7cmr6902111plh.167.1642843075780; Sat, 22 Jan 2022 01:17:55 -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.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:17:55 -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 05/31] clk: mediatek: gate: Clean up included headers Date: Sat, 22 Jan 2022 17:17:05 +0800 Message-Id: <20220122091731.283592-6-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" Some included headers aren't actually used anywhere, while other headers with the declaration of functions and structures aren't directly included. Get rid of the unused ones, and add the ones that should be included directly. On the header side, replace headers that are included purely for data structure definitions with forward declarations. This decreases the amount of preprocessing and compilation effort required for each inclusion. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-gate.c | 11 +++-------- drivers/clk/mediatek/clk-gate.h | 10 +++++++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/clk/mediatek/clk-gate.c b/drivers/clk/mediatek/clk-gat= e.c index ed1ad5535d41..e8881ae1489a 100644 --- a/drivers/clk/mediatek/clk-gate.c +++ b/drivers/clk/mediatek/clk-gate.c @@ -4,18 +4,13 @@ * Author: James Liao */ =20 -#include -#include - -#include -#include -#include -#include #include -#include #include #include +#include #include +#include +#include =20 #include "clk-gate.h" =20 diff --git a/drivers/clk/mediatek/clk-gate.h b/drivers/clk/mediatek/clk-gat= e.h index 344adffb6578..6b5738826a22 100644 --- a/drivers/clk/mediatek/clk-gate.h +++ b/drivers/clk/mediatek/clk-gate.h @@ -7,9 +7,13 @@ #ifndef __DRV_CLK_GATE_H #define __DRV_CLK_GATE_H =20 -#include -#include -#include +#include + +struct clk; +struct clk_onecell_data; +struct clk_ops; +struct device; +struct device_node; =20 extern const struct clk_ops mtk_clk_gate_ops_setclr; extern const struct clk_ops mtk_clk_gate_ops_setclr_inv; --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 24240C433EF for ; Sat, 22 Jan 2022 09:18:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234166AbiAVJS4 (ORCPT ); Sat, 22 Jan 2022 04:18:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234103AbiAVJSK (ORCPT ); Sat, 22 Jan 2022 04:18:10 -0500 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89FACC061749 for ; Sat, 22 Jan 2022 01:18:09 -0800 (PST) Received: by mail-qv1-xf35.google.com with SMTP id t7so13603029qvj.0 for ; Sat, 22 Jan 2022 01:18:09 -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=0spPJqiyNma/JSwRciV7mlMnnEsvRwtK+rQFLo/is08=; b=R5I+rW3l2T7KAn4/rCa8lKm7eS2I2p6sSb3KmPPOSFkb/KVSuHM2ugYPUK2urOucUw c5fT9x7ax3oC7MX6mJoQlM1ax7e3Szh3BjrHbbzk/rFWLszCC+ly912TNdKHd4RpV+7V yJzMESoZicfzqEsL148u85ddGQQPdAixS56Sk= 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=0spPJqiyNma/JSwRciV7mlMnnEsvRwtK+rQFLo/is08=; b=SWNGEcIatpiGQFSkmewMUY10R3MMhu4xo4uElJu5c1wHBq7GSiYVuyN8UQNINxP91F jqOVp3b9adkdYYJPDt7dvaby+ajDPBlO8Qihsl1Fihggv0c0uHo+FAkEJ8npiRTFLHwh h1GglrY+MalKjhLiyf9LlCL/cssrWd5g8SDLsri1WfWuW+l8gFZMCVq7UsvoqV7CK2YN hY4uvYmmM+NEK6YVnvjx8THyVGclN9z/6+lg1ecvVW7C/sOhE70uijBRq0tnZ/X9NfQd jleugvhegAvHiv6FUO5q56SyczCstjpVUQlr5Vpx0KR4pD4ZfxV/VGe0ZkGBT7AjxXTL Tqtg== X-Gm-Message-State: AOAM530dXSwce0tSOu0pW1Z0t1GxBvqPjmwAVRJgEg8XIjjAl0sNjYaP 0uVwjsx18c6Es3Qh8dDVWFK/3U8isuiK+Q== X-Google-Smtp-Source: ABdhPJyVK4Mt3oHJEIY99aJdCQK6gKiDhx4ht4FV9+3LLoe55aexZOXvspZbiR84kJ+rQS5uLuDxzw== X-Received: by 2002:a05:6a00:2151:b0:4a2:5c9a:f0a9 with SMTP id o17-20020a056a00215100b004a25c9af0a9mr6679544pfk.39.1642843077957; Sat, 22 Jan 2022 01:17:57 -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.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:17:57 -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 06/31] clk: mediatek: cpumux: Implement unregister API Date: Sat, 22 Jan 2022 17:17:06 +0800 Message-Id: <20220122091731.283592-7-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" The cpumux 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 cpumux type clk. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-cpumux.c | 31 +++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-cpumux.h | 3 +++ 2 files changed, 34 insertions(+) diff --git a/drivers/clk/mediatek/clk-cpumux.c b/drivers/clk/mediatek/clk-c= pumux.c index cab5095416b6..99a819e3673f 100644 --- a/drivers/clk/mediatek/clk-cpumux.c +++ b/drivers/clk/mediatek/clk-cpumux.c @@ -77,6 +77,21 @@ mtk_clk_register_cpumux(const struct mtk_composite *mux, return clk; } =20 +static void mtk_clk_unregister_cpumux(struct clk *clk) +{ + struct mtk_clk_cpumux *cpumux; + struct clk_hw *hw; + + hw =3D __clk_get_hw(clk); + if (!hw) + return; + + cpumux =3D to_mtk_clk_cpumux(hw); + + clk_unregister(clk); + kfree(cpumux); +} + int mtk_clk_register_cpumuxes(struct device_node *node, const struct mtk_composite *clks, int num, struct clk_onecell_data *clk_data) @@ -106,4 +121,20 @@ int mtk_clk_register_cpumuxes(struct device_node *node, return 0; } =20 +void mtk_clk_unregister_cpumuxes(const struct mtk_composite *clks, int num, + struct clk_onecell_data *clk_data) +{ + int i; + + for (i =3D num; i > 0; i--) { + const struct mtk_composite *mux =3D &clks[i - 1]; + + if (IS_ERR_OR_NULL(clk_data->clks[mux->id])) + continue; + + mtk_clk_unregister_cpumux(clk_data->clks[mux->id]); + clk_data->clks[mux->id] =3D ERR_PTR(-ENOENT); + } +} + MODULE_LICENSE("GPL"); diff --git a/drivers/clk/mediatek/clk-cpumux.h b/drivers/clk/mediatek/clk-c= pumux.h index 2aaf1afd4e5f..fda7770fd803 100644 --- a/drivers/clk/mediatek/clk-cpumux.h +++ b/drivers/clk/mediatek/clk-cpumux.h @@ -19,4 +19,7 @@ int mtk_clk_register_cpumuxes(struct device_node *node, const struct mtk_composite *clks, int num, struct clk_onecell_data *clk_data); =20 +void mtk_clk_unregister_cpumuxes(const struct mtk_composite *clks, int num, + struct clk_onecell_data *clk_data); + #endif /* __DRV_CLK_CPUMUX_H */ --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 5154AC433EF for ; Sat, 22 Jan 2022 09:18:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234142AbiAVJSS (ORCPT ); Sat, 22 Jan 2022 04:18:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234004AbiAVJSA (ORCPT ); Sat, 22 Jan 2022 04:18:00 -0500 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 993C0C061401 for ; Sat, 22 Jan 2022 01:18:00 -0800 (PST) Received: by mail-pg1-x52a.google.com with SMTP id p125so10271904pga.2 for ; Sat, 22 Jan 2022 01:18:00 -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=Nd/CF8vqUX0IATJQuscxS8huseCWfTQmqbhI4UY9O64=; b=KVC2hzrkkazjCViKrnLOLBAg7/PZhZuW5n9ZbxaTdZNc2UauGmE3xhUVMdsM3+gF7P 5BINxyVk+h4ChrIE0lwrtNomRSDTXyw59Ab+fEt2P3Mx9KQwMf7/dy49G5HR1+ZLEFWL Hh+vsa23bWhFlOaOnSJRCnrXlGcXx0JP+09JM= 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=Nd/CF8vqUX0IATJQuscxS8huseCWfTQmqbhI4UY9O64=; b=o+NULH/flaDsEZ9hx+oyOCTTpnKo62p+myXVcAVKwG7/2NtvDtdv0jFXqYNjL6OzqP ZkM/AqxtI23TURy66tl+N/Xi3tHGgjGHWNgEt7GbVvibor4IdF9c2EwmciahbLM9uAxf uc43ib36Iz3z3KTt4ler/kEH+C94oXS0+vnzJ0Thb+sAPZ9HBHRiagldxX6LwGrIjPCQ y84Yjn02twkuO0zms7184wqFQKGT1ZrbP1UifMx18rBojwQycNCDBCbdwZAXLSl3MrA5 oje92th/sy3SlGLCdSM9hdJP/nWfay+d5wB77wSNxRwXUytccxSVxvNEsyWcu+kgcIyY NLuw== X-Gm-Message-State: AOAM533jRXmERIHIF/PI4MhoKDJ1zwdHIVMrx8Dy7HTcy4fepMc3+DHE 2IoPAetaqKl1ueGihg+KVz+39A== X-Google-Smtp-Source: ABdhPJzd4uJC769zjxpDoJj+Uzr12VPezjLug+Z4gJO2U3vcZi3VyPGrSQvRsXfDx9Fr1H4uSYC/1A== X-Received: by 2002:a63:3509:: with SMTP id c9mr5401711pga.332.1642843080226; Sat, 22 Jan 2022 01:18:00 -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.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:17:59 -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 07/31] clk: mediatek: cpumux: Internalize struct mtk_clk_cpumux Date: Sat, 22 Jan 2022 17:17:07 +0800 Message-Id: <20220122091731.283592-8-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" struct mtk_clk_cpumux is an implementation detail of the cpumux clk type, and is not used outside of the implementation. Internalize the definition to minimize leakage of details and shrink the header file. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-cpumux.c | 8 ++++++++ drivers/clk/mediatek/clk-cpumux.h | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/clk/mediatek/clk-cpumux.c b/drivers/clk/mediatek/clk-c= pumux.c index 99a819e3673f..344c6399b22f 100644 --- a/drivers/clk/mediatek/clk-cpumux.c +++ b/drivers/clk/mediatek/clk-cpumux.c @@ -12,6 +12,14 @@ #include "clk-mtk.h" #include "clk-cpumux.h" =20 +struct mtk_clk_cpumux { + struct clk_hw hw; + struct regmap *regmap; + u32 reg; + u32 mask; + u8 shift; +}; + static inline struct mtk_clk_cpumux *to_mtk_clk_cpumux(struct clk_hw *_hw) { return container_of(_hw, struct mtk_clk_cpumux, hw); diff --git a/drivers/clk/mediatek/clk-cpumux.h b/drivers/clk/mediatek/clk-c= pumux.h index fda7770fd803..a538f2bbef0d 100644 --- a/drivers/clk/mediatek/clk-cpumux.h +++ b/drivers/clk/mediatek/clk-cpumux.h @@ -7,14 +7,6 @@ #ifndef __DRV_CLK_CPUMUX_H #define __DRV_CLK_CPUMUX_H =20 -struct mtk_clk_cpumux { - struct clk_hw hw; - struct regmap *regmap; - u32 reg; - u32 mask; - u8 shift; -}; - int mtk_clk_register_cpumuxes(struct device_node *node, const struct mtk_composite *clks, int num, struct clk_onecell_data *clk_data); --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 9F31FC433EF for ; Sat, 22 Jan 2022 09:18:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234282AbiAVJSv (ORCPT ); Sat, 22 Jan 2022 04:18:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234040AbiAVJSE (ORCPT ); Sat, 22 Jan 2022 04:18:04 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5692C06174E for ; Sat, 22 Jan 2022 01:18:02 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id s61-20020a17090a69c300b001b4d0427ea2so15446440pjj.4 for ; Sat, 22 Jan 2022 01:18:02 -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=CMFXap+xL0bvLvySfgNMrXOP9tSLXVuWtG0WsgxxBN8=; b=no9YI2kI8gyzTudRYKHgPiFbPAcXOXr00kj1lm3Q/qLeY4IIWESiil9gsKxq18DvLG mGuKrkF7ZZyQQOddq9+HibOon3iYZ7aJFs12iYxPjSIDscNDS/Kt1h0okxcmKDQO8nuU e4W6Hh7ISgKoKsXRsZBXhN2rOJofin6Xvf5pU= 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=CMFXap+xL0bvLvySfgNMrXOP9tSLXVuWtG0WsgxxBN8=; b=4GIGUtAAhw2yljmb+RU0OWak70XGeRtSahFq87p1tFlK1HlNK9N2oyXSv75CY1Siam +q3WUeyLe1s1FeBgfSkIihuI8n4tuPggp91z/o+rFUbyzz+D+CYmbpxjevsIBGic0yXV gmf0mERsMLqMYWZnm9zmyjrYB5AwgKGLbRge3Hut33tKcyCSTLXh8PgM8Y+GRgHuknSQ jkpjSEYmv3Psw26g+kwLAJ0oO0zngQUvNKRX+fu6hyGx9vtLdBzbQF6dAgFB3E0ovsP9 Y3RrzWX83W5G5Fu7UUa547+NsYxT/ztPorvuyFyLtbpT3EpIQrbEo73VJn9b8KxcqplR 2AVA== X-Gm-Message-State: AOAM530U/jl7uA6EkUV4ZKXo6A8yNyGNCIQBqRDtUU0UiEDfFSuRt9Z3 MfSyRYak89iTmXYMoYFzPHtomg== X-Google-Smtp-Source: ABdhPJxN30OUYMrT52RzBfbw6qmJzTZhPQfO212jPVtLlFlXIYBizp9DWGFMnLERH3nnKeEUo3eQbw== X-Received: by 2002:a17:902:dacf:b0:14b:2225:2f06 with SMTP id q15-20020a170902dacf00b0014b22252f06mr4851994plx.123.1642843082396; Sat, 22 Jan 2022 01:18:02 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:01 -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 08/31] clk: mediatek: cpumux: Clean up included headers Date: Sat, 22 Jan 2022 17:17:08 +0800 Message-Id: <20220122091731.283592-9-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" Some headers with the declaration of functions and structures aren't directly included. Explicitly include them so that future changes to other headers would not result in an unexpected build break. On the header side, add forward declarations for any data structures whose pointers are used in function signatures. No headers are required. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-cpumux.c | 3 +++ drivers/clk/mediatek/clk-cpumux.h | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/drivers/clk/mediatek/clk-cpumux.c b/drivers/clk/mediatek/clk-c= pumux.c index 344c6399b22f..658aee789f44 100644 --- a/drivers/clk/mediatek/clk-cpumux.c +++ b/drivers/clk/mediatek/clk-cpumux.c @@ -5,8 +5,11 @@ */ =20 #include +#include +#include #include #include +#include #include =20 #include "clk-mtk.h" diff --git a/drivers/clk/mediatek/clk-cpumux.h b/drivers/clk/mediatek/clk-c= pumux.h index a538f2bbef0d..b07e89f7c283 100644 --- a/drivers/clk/mediatek/clk-cpumux.h +++ b/drivers/clk/mediatek/clk-cpumux.h @@ -7,6 +7,10 @@ #ifndef __DRV_CLK_CPUMUX_H #define __DRV_CLK_CPUMUX_H =20 +struct clk_onecell_data; +struct device_node; +struct mtk_composite; + int mtk_clk_register_cpumuxes(struct device_node *node, const struct mtk_composite *clks, int num, struct clk_onecell_data *clk_data); --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 9F399C433F5 for ; Sat, 22 Jan 2022 09:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234158AbiAVJSW (ORCPT ); Sat, 22 Jan 2022 04:18:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234067AbiAVJSG (ORCPT ); Sat, 22 Jan 2022 04:18:06 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF57EC06173D for ; Sat, 22 Jan 2022 01:18:05 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id p125so10271981pga.2 for ; Sat, 22 Jan 2022 01:18:05 -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=3QDkw6hKuh9A5bW2X56div0eoUC0aWY4eb0X4EhRe1w=; b=UUTVvh9xTtBDXrtDwIiLvMdkg+B8Tbj/3HJzIjqASRfr6Rbi1x7UfyjSAiJJf/GKxJ nextzHuxXDZCB5RNB3kw6NBl27kC1oIqB6QwWHjnnw+PBXKcNaC8qWcx6FrpfUxDYR4U Zed+yxwix8JIPX7rU2yILjRCGyE8BJiokJXkQ= 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=3QDkw6hKuh9A5bW2X56div0eoUC0aWY4eb0X4EhRe1w=; b=FrLx9pM1pt14Tz6l9hv5sHHF3hOx+JoGA2rczvRPAC7IC7gRpX2vRvXt8+XMEzpkwk xq934iSlSVz42Hivp49PF/UMrLVhzyVz9I9u/b6L6tqyAS46a08LIsL7/4A3pZGWTjhj RmzQwQgFgBg8B2AdB122pfaRyAYnYWl5IdnhDreNG4YaxWNTlmetamNp7jd6Cqcztevk 2SexppBShtG8gG1gOBzUlwRNiD50naRNEkY9NjFDiBfDTLcFJYZXu+3d/aeE8EVinMTm f3y28MsCBvoQHnUmkQ8xWEi9YFcp2xprhoegGusmlmpTUWFvLomQ+AyKd1PfqBIQL7ix 9Q1Q== X-Gm-Message-State: AOAM5321KvaL9M4OgYGAKyPeQ4xsROYcizCfRb4shw8K0QmhJLIAVfZD MZPj4ojXLEKFbiiJVstpHlGagw== X-Google-Smtp-Source: ABdhPJxEsfTKz2/apvu31D0HBDJq0EjZ3iVczEuZeKOKltbSUG6IuziGeOgA3YqrYKwP877YBCdRoA== X-Received: by 2002:a63:5607:: with SMTP id k7mr5583895pgb.190.1642843084589; Sat, 22 Jan 2022 01:18:04 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:04 -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 09/31] clk: mediatek: mux: Implement unregister API Date: Sat, 22 Jan 2022 17:17:09 +0800 Message-Id: <20220122091731.283592-10-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" 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 --- 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 m= tk_mux *mux, return clk; } =20 +static void mtk_clk_unregister_mux(struct clk *clk) +{ + struct mtk_clk_mux *mux; + struct clk_hw *hw; + + hw =3D __clk_get_hw(clk); + if (!hw) + return; + + mux =3D 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); =20 +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 =3D num; i > 0; i--) { + const struct mtk_mux *mux =3D &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] =3D 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); =20 +void mtk_clk_unregister_muxes(const struct mtk_mux *muxes, int num, + struct clk_onecell_data *clk_data); + #endif /* __DRV_CLK_MTK_MUX_H */ --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 A9335C433EF for ; Sat, 22 Jan 2022 09:18:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234019AbiAVJSc (ORCPT ); Sat, 22 Jan 2022 04:18:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234079AbiAVJSH (ORCPT ); Sat, 22 Jan 2022 04:18:07 -0500 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B710C061744 for ; Sat, 22 Jan 2022 01:18:07 -0800 (PST) Received: by mail-pf1-x435.google.com with SMTP id u10so6521798pfg.10 for ; Sat, 22 Jan 2022 01:18:07 -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=14oekTz2jUCC4Rr83R46NSrxudxWdrVi94PXUiSTUWo=; b=GeAKiZ2qXHpjbTDaTxRsRAPhrwtnHAA+bWWAfvB5SGpNEdh8lhBHUGNYuoupKevK1T Y1DokCz7jgKK/gFoPLRlk56KWjfEhKayjq8b46VW1cPzJgdVxvR88PhQMdqcXmxMrtYG msQvy9arKcOZ9bj1HBHL7oTz0Q0jt8ncHRvoM= 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=14oekTz2jUCC4Rr83R46NSrxudxWdrVi94PXUiSTUWo=; b=GqDymcnf/euk/G8wPZdd9Txp/1sG6njC4Li0J2YB+8jiMuGcSpFZ/KZ4wdiLHQL3M2 ehAFGyBIrVn3fTISdwtB4zHeo3zpraOAN5FiJI3ddq7hbbjyGdkGNGi5gy+67IUeC1+W 0LtHgMKIiJfcZx+jQOz3UvuaKNTUsbGT/Cjx+hS3yxdYOj+vUnkyOUcHN1eBilIF/PEx a7EvPBwxMIz/TpjntTK/He0yzhABJ0e+uw5e74lo6s3vYHWrd2kgCrxq/TL2lcT/j2B0 /kkDaAjy+wiJF+ilM8Yr99NKHkkQGiULJZusY7nck8HbZ93v8IVb+QgnK6/6OK/WBT7R p/Wg== X-Gm-Message-State: AOAM532BW56AQ8dOuqAuXGAs9jejKixpmIbvzjTZ568iIwePGawb++Gc t5CH4XssIPxTDfcHsQAKZblbtw== X-Google-Smtp-Source: ABdhPJxBLmizlDghIjkDDcRjYFNdvmbFT8l691jjnPT3Ies6TSVELhgwbCd9IWZYQ6kTQCL8f7D04Q== X-Received: by 2002:a63:6905:: with SMTP id e5mr5462412pgc.543.1642843086828; Sat, 22 Jan 2022 01:18:06 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:06 -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 10/31] clk: mediatek: mux: Internalize struct mtk_clk_mux Date: Sat, 22 Jan 2022 17:17:10 +0800 Message-Id: <20220122091731.283592-11-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" struct mtk_clk_mux is an implementation detail of the mux clk type, and is not used outside of the implementation. Internalize the definition to minimize leakage of details and shrink the header file. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mux.c | 8 ++++++++ drivers/clk/mediatek/clk-mux.h | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c index 6f0c22a699c3..2d4d8dc0120a 100644 --- a/drivers/clk/mediatek/clk-mux.c +++ b/drivers/clk/mediatek/clk-mux.c @@ -13,6 +13,14 @@ #include "clk-mtk.h" #include "clk-mux.h" =20 +struct mtk_clk_mux { + struct clk_hw hw; + struct regmap *regmap; + const struct mtk_mux *data; + spinlock_t *lock; + bool reparent; +}; + static inline struct mtk_clk_mux *to_mtk_clk_mux(struct clk_hw *hw) { return container_of(hw, struct mtk_clk_mux, hw); diff --git a/drivers/clk/mediatek/clk-mux.h b/drivers/clk/mediatek/clk-mux.h index cb2ac4f04c58..38a2b6014b08 100644 --- a/drivers/clk/mediatek/clk-mux.h +++ b/drivers/clk/mediatek/clk-mux.h @@ -9,14 +9,6 @@ =20 #include =20 -struct mtk_clk_mux { - struct clk_hw hw; - struct regmap *regmap; - const struct mtk_mux *data; - spinlock_t *lock; - bool reparent; -}; - struct mtk_mux { int id; const char *name; --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 C04A2C433EF for ; Sat, 22 Jan 2022 09:18:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229546AbiAVJSa (ORCPT ); Sat, 22 Jan 2022 04:18:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234105AbiAVJSK (ORCPT ); Sat, 22 Jan 2022 04:18:10 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94EE0C061751 for ; Sat, 22 Jan 2022 01:18:09 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id my12-20020a17090b4c8c00b001b528ba1cd7so6262726pjb.1 for ; Sat, 22 Jan 2022 01:18:09 -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=vNUxjw49tFByvcP8t/7//e7iEPYHFps9QVk8zZRKtaU=; b=FphTI/EUT+pYQ6+s8N+x8etvO1gp8ydoS32Ye8uTFtcA0dTunlpW4uIwQ8xsAMAxcJ 59qGp9DBrlbRSSwNDb82LSehk5xTkcD/mHbvAFeT676O/lkQPLP6mUPFmHnuvbvCzsH0 CmhrQYDiTI3PF6wwTPqVw2KJy6h1l7YA5ZCvs= 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=vNUxjw49tFByvcP8t/7//e7iEPYHFps9QVk8zZRKtaU=; b=le4TDv1n+VLNQSYidb9jexrc93AM8WUJgcAjr83zBXZacS6UowHx/JArAs+P4Z2Itp cS9Bxk+ix0fdKi2uDrSeZ06cH60QEgDFjq0wMekuUDb0gQscFreQy1tAT4HFEpMLmKsS T4fkY0RA1H8t6LPYQ7xTN6+p14Gn/EYsLbtBU2qOKbgGBNuVsZBYosf8gyxnkHv0L2r7 CmPAFZ0lVZfu0PYFPY6erLtDtDSPUIHiydENHFMt6PRn1/SAY1hG916arPoijJ+Dzokg HidkRjzSKhq75XCMsQ40i52bb6IhcSjcyp6CDdwZ7iazFWSLvZqklzZ1U74hTYTiGkJP Beqw== X-Gm-Message-State: AOAM530KfdkXPZ+7Z4vQetRm3pn1up4JU0MtrXb3ekvx0agluKTpCn6g 8gTGQ4CDkJGQ5XBzd1WVKlkvvw== X-Google-Smtp-Source: ABdhPJzt50XykWx+0tWjlGukGzZMOR/XsM+FWIFaNqeZRK3fs6wk/ktZqv15RMlzys50RaboRzuhyQ== X-Received: by 2002:a17:90a:5e05:: with SMTP id w5mr4443843pjf.57.1642843089091; Sat, 22 Jan 2022 01:18:09 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:08 -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 11/31] clk: mediatek: mux: Clean up included headers Date: Sat, 22 Jan 2022 17:17:11 +0800 Message-Id: <20220122091731.283592-12-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" Some included headers aren't actually used anywhere, while other headers with the declaration of functions and structures aren't directly included. Get rid of the unused ones, and add the ones that should be included directly. On the header side, replace headers that are included purely for data structure definitions with forward declarations. This decreases the amount of preprocessing and compilation effort required for each inclusion. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mux.c | 11 +++++++---- drivers/clk/mediatek/clk-mux.h | 8 +++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c index 2d4d8dc0120a..01af6a52711a 100644 --- a/drivers/clk/mediatek/clk-mux.c +++ b/drivers/clk/mediatek/clk-mux.c @@ -4,13 +4,16 @@ * Author: Owen Chen */ =20 -#include -#include -#include +#include +#include +#include +#include #include #include +#include +#include +#include =20 -#include "clk-mtk.h" #include "clk-mux.h" =20 struct mtk_clk_mux { diff --git a/drivers/clk/mediatek/clk-mux.h b/drivers/clk/mediatek/clk-mux.h index 38a2b6014b08..903a3c937959 100644 --- a/drivers/clk/mediatek/clk-mux.h +++ b/drivers/clk/mediatek/clk-mux.h @@ -7,7 +7,13 @@ #ifndef __DRV_CLK_MTK_MUX_H #define __DRV_CLK_MTK_MUX_H =20 -#include +#include +#include + +struct clk; +struct clk_onecell_data; +struct clk_ops; +struct device_node; =20 struct mtk_mux { int id; --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 BE934C433EF for ; Sat, 22 Jan 2022 09:18:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234185AbiAVJSe (ORCPT ); Sat, 22 Jan 2022 04:18:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234111AbiAVJSM (ORCPT ); Sat, 22 Jan 2022 04:18:12 -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 DA6A0C06173D for ; Sat, 22 Jan 2022 01:18:11 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id g9-20020a17090a67c900b001b4f1d71e4fso11261449pjm.4 for ; Sat, 22 Jan 2022 01:18:11 -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=soaaam3hrgCVzQ6/QI7F3r+P2+uJDpqXG3CI212RPDk=; b=QyFbqM44aSrb34eI7sLJhVr+hT9Xtu0lkHQkKLNPHCtf1GU8JFK91tJXqMQ9bei7M7 QytbwIPkuZ5AVIcsuR/+JT/ECDDm5VWuBZ1Pguckwoh8lDgLYF48js/ARCzFJQk5zOlY bwcq6LLeujCAyj+nV3sGiz5Nj1OKxjg1aOlO8= 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=soaaam3hrgCVzQ6/QI7F3r+P2+uJDpqXG3CI212RPDk=; b=xAuWmZofmJW1EhIYp+CoQcjY+KKzHHhaed/mi9iXQhCD11vqVPwNgTA1zAXP9b9BYQ lQCLR3mfHAKp+zPHqUetLWGZCR9Mk9NPsQQO58VAcRy6ICFnWVzR1WJx9gY2aUOhVhAk WQ1YgKRL+Td+2wf+KXEOrmOy+oRfeZ4n1QpVGDRkTOkIDRlauK4qPUPqTVMs56US+f/R x3Er5Gwg+JFwRuK1sw3Tk7wf2hfY2NAaAzwj53aw2oEAh1/c8b9M+y332SrorfUmOAIb m9lhRJH4NVjHxqAdcVIaotE+q1N/6x68g1+lDHZPbUmmcvlcBM8NEz6lrbXhSPINTYd2 N+zA== X-Gm-Message-State: AOAM5311SJuwrNXxHugjwp8A5fdK2I5k4EnpMjYWA/o+jCYeBbPcJbQH 7lGRXh7Ar6GqoKeE+clEFPO3Tw== X-Google-Smtp-Source: ABdhPJzdpROET+8RI0Gyr57GHoVyoxvKKi9vA/0+ao7/0omPPQuT+tNYt69NCwuFKYCBbus3iiVFTg== X-Received: by 2002:a17:90b:3b88:: with SMTP id pc8mr24965pjb.245.1642843091354; Sat, 22 Jan 2022 01:18:11 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:10 -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 12/31] clk: mediatek: pll: Split definitions into separate header file Date: Sat, 22 Jan 2022 17:17:12 +0800 Message-Id: <20220122091731.283592-13-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" When the PLL type clk was implemented in the MediaTek clk driver library, the data structure definitions and function declaration were put in the common header file. Since it is its own type of clk, and not all platform clk drivers utilize it, having the definitions in the common header results in wasted cycles during compilation. Split out the related definitions and declarations into its own header file, and include that only in the platform clk drivers that need it. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mt2701.c | 5 +- drivers/clk/mediatek/clk-mt2712.c | 3 +- drivers/clk/mediatek/clk-mt6765.c | 3 +- drivers/clk/mediatek/clk-mt6779.c | 3 +- drivers/clk/mediatek/clk-mt6797.c | 3 +- drivers/clk/mediatek/clk-mt7622.c | 5 +- drivers/clk/mediatek/clk-mt7629.c | 5 +- drivers/clk/mediatek/clk-mt7986-apmixed.c | 4 +- drivers/clk/mediatek/clk-mt8135.c | 3 +- drivers/clk/mediatek/clk-mt8167.c | 3 +- drivers/clk/mediatek/clk-mt8173.c | 5 +- drivers/clk/mediatek/clk-mt8183.c | 3 +- drivers/clk/mediatek/clk-mt8192.c | 3 +- drivers/clk/mediatek/clk-mt8195-apmixedsys.c | 1 + drivers/clk/mediatek/clk-mt8195-apusys_pll.c | 1 + drivers/clk/mediatek/clk-mt8516.c | 3 +- drivers/clk/mediatek/clk-mtk.h | 39 -------------- drivers/clk/mediatek/clk-pll.c | 1 + drivers/clk/mediatek/clk-pll.h | 55 ++++++++++++++++++++ 19 files changed, 91 insertions(+), 57 deletions(-) create mode 100644 drivers/clk/mediatek/clk-pll.h diff --git a/drivers/clk/mediatek/clk-mt2701.c b/drivers/clk/mediatek/clk-m= t2701.c index 695be0f77427..1eb3e4563c3f 100644 --- a/drivers/clk/mediatek/clk-mt2701.c +++ b/drivers/clk/mediatek/clk-mt2701.c @@ -10,9 +10,10 @@ #include #include =20 -#include "clk-mtk.h" -#include "clk-gate.h" #include "clk-cpumux.h" +#include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" =20 #include =20 diff --git a/drivers/clk/mediatek/clk-mt2712.c b/drivers/clk/mediatek/clk-m= t2712.c index a3bd9a107209..ff72b9ab945b 100644 --- a/drivers/clk/mediatek/clk-mt2712.c +++ b/drivers/clk/mediatek/clk-mt2712.c @@ -13,8 +13,9 @@ #include #include =20 -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-pll.h" +#include "clk-mtk.h" =20 #include =20 diff --git a/drivers/clk/mediatek/clk-mt6765.c b/drivers/clk/mediatek/clk-m= t6765.c index d77ea5aff292..24829ca3bd1f 100644 --- a/drivers/clk/mediatek/clk-mt6765.c +++ b/drivers/clk/mediatek/clk-mt6765.c @@ -12,9 +12,10 @@ #include #include =20 -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" #include "clk-mux.h" +#include "clk-pll.h" =20 #include =20 diff --git a/drivers/clk/mediatek/clk-mt6779.c b/drivers/clk/mediatek/clk-m= t6779.c index 9825385c9f94..7b61664da18f 100644 --- a/drivers/clk/mediatek/clk-mt6779.c +++ b/drivers/clk/mediatek/clk-mt6779.c @@ -10,9 +10,10 @@ #include #include =20 +#include "clk-gate.h" #include "clk-mtk.h" #include "clk-mux.h" -#include "clk-gate.h" +#include "clk-pll.h" =20 #include =20 diff --git a/drivers/clk/mediatek/clk-mt6797.c b/drivers/clk/mediatek/clk-m= t6797.c index 428eb24ffec5..02259e81625a 100644 --- a/drivers/clk/mediatek/clk-mt6797.c +++ b/drivers/clk/mediatek/clk-mt6797.c @@ -9,8 +9,9 @@ #include #include =20 -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" =20 #include =20 diff --git a/drivers/clk/mediatek/clk-mt7622.c b/drivers/clk/mediatek/clk-m= t7622.c index ef5947e15c75..0e1fb30a1e98 100644 --- a/drivers/clk/mediatek/clk-mt7622.c +++ b/drivers/clk/mediatek/clk-mt7622.c @@ -11,9 +11,10 @@ #include #include =20 -#include "clk-mtk.h" -#include "clk-gate.h" #include "clk-cpumux.h" +#include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" =20 #include #include /* for consumer */ diff --git a/drivers/clk/mediatek/clk-mt7629.c b/drivers/clk/mediatek/clk-m= t7629.c index a0ee079670c7..c0e023bf31eb 100644 --- a/drivers/clk/mediatek/clk-mt7629.c +++ b/drivers/clk/mediatek/clk-mt7629.c @@ -12,9 +12,10 @@ #include #include =20 -#include "clk-mtk.h" -#include "clk-gate.h" #include "clk-cpumux.h" +#include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" =20 #include =20 diff --git a/drivers/clk/mediatek/clk-mt7986-apmixed.c b/drivers/clk/mediat= ek/clk-mt7986-apmixed.c index 98ec3887585f..21d4c82e782a 100644 --- a/drivers/clk/mediatek/clk-mt7986-apmixed.c +++ b/drivers/clk/mediatek/clk-mt7986-apmixed.c @@ -10,9 +10,11 @@ #include #include #include -#include "clk-mtk.h" + #include "clk-gate.h" +#include "clk-mtk.h" #include "clk-mux.h" +#include "clk-pll.h" =20 #include #include diff --git a/drivers/clk/mediatek/clk-mt8135.c b/drivers/clk/mediatek/clk-m= t8135.c index 9b4b645aea99..09ad272d51f1 100644 --- a/drivers/clk/mediatek/clk-mt8135.c +++ b/drivers/clk/mediatek/clk-mt8135.c @@ -11,8 +11,9 @@ #include #include =20 -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" =20 static DEFINE_SPINLOCK(mt8135_clk_lock); =20 diff --git a/drivers/clk/mediatek/clk-mt8167.c b/drivers/clk/mediatek/clk-m= t8167.c index e5ea10e31799..812b33a57530 100644 --- a/drivers/clk/mediatek/clk-mt8167.c +++ b/drivers/clk/mediatek/clk-mt8167.c @@ -12,8 +12,9 @@ #include #include =20 -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" =20 #include =20 diff --git a/drivers/clk/mediatek/clk-mt8173.c b/drivers/clk/mediatek/clk-m= t8173.c index 8f898ac476c0..46b7655feeaa 100644 --- a/drivers/clk/mediatek/clk-mt8173.c +++ b/drivers/clk/mediatek/clk-mt8173.c @@ -8,9 +8,10 @@ #include #include =20 -#include "clk-mtk.h" -#include "clk-gate.h" #include "clk-cpumux.h" +#include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" =20 #include =20 diff --git a/drivers/clk/mediatek/clk-mt8183.c b/drivers/clk/mediatek/clk-m= t8183.c index 5046852eb0fd..68496554dd3d 100644 --- a/drivers/clk/mediatek/clk-mt8183.c +++ b/drivers/clk/mediatek/clk-mt8183.c @@ -11,9 +11,10 @@ #include #include =20 +#include "clk-gate.h" #include "clk-mtk.h" #include "clk-mux.h" -#include "clk-gate.h" +#include "clk-pll.h" =20 #include =20 diff --git a/drivers/clk/mediatek/clk-mt8192.c b/drivers/clk/mediatek/clk-m= t8192.c index cbc7c6dbe0f4..5f998aab3bfd 100644 --- a/drivers/clk/mediatek/clk-mt8192.c +++ b/drivers/clk/mediatek/clk-mt8192.c @@ -12,9 +12,10 @@ #include #include =20 +#include "clk-gate.h" #include "clk-mtk.h" #include "clk-mux.h" -#include "clk-gate.h" +#include "clk-pll.h" =20 #include =20 diff --git a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c b/drivers/clk/med= iatek/clk-mt8195-apmixedsys.c index 6156ceeed71e..5b1b7dc447eb 100644 --- a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c +++ b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c @@ -5,6 +5,7 @@ =20 #include "clk-gate.h" #include "clk-mtk.h" +#include "clk-pll.h" =20 #include #include diff --git a/drivers/clk/mediatek/clk-mt8195-apusys_pll.c b/drivers/clk/med= iatek/clk-mt8195-apusys_pll.c index f1c84186346e..db449ff877d7 100644 --- a/drivers/clk/mediatek/clk-mt8195-apusys_pll.c +++ b/drivers/clk/mediatek/clk-mt8195-apusys_pll.c @@ -4,6 +4,7 @@ // Author: Chun-Jie Chen =20 #include "clk-mtk.h" +#include "clk-pll.h" =20 #include #include diff --git a/drivers/clk/mediatek/clk-mt8516.c b/drivers/clk/mediatek/clk-m= t8516.c index 9d4261ecc760..a37143f920ce 100644 --- a/drivers/clk/mediatek/clk-mt8516.c +++ b/drivers/clk/mediatek/clk-mt8516.c @@ -11,8 +11,9 @@ #include #include =20 -#include "clk-mtk.h" #include "clk-gate.h" +#include "clk-mtk.h" +#include "clk-pll.h" =20 #include =20 diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index bdec7dc5e07a..168220f85489 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -179,45 +179,6 @@ void mtk_clk_register_dividers(const struct mtk_clk_di= vider *mcds, struct clk_onecell_data *mtk_alloc_clk_data(unsigned int clk_num); void mtk_free_clk_data(struct clk_onecell_data *clk_data); =20 -#define HAVE_RST_BAR BIT(0) -#define PLL_AO BIT(1) - -struct mtk_pll_div_table { - u32 div; - unsigned long freq; -}; - -struct mtk_pll_data { - int id; - const char *name; - u32 reg; - u32 pwr_reg; - u32 en_mask; - u32 pd_reg; - u32 tuner_reg; - u32 tuner_en_reg; - u8 tuner_en_bit; - int pd_shift; - unsigned int flags; - const struct clk_ops *ops; - u32 rst_bar_mask; - unsigned long fmin; - unsigned long fmax; - int pcwbits; - int pcwibits; - u32 pcw_reg; - int pcw_shift; - u32 pcw_chg_reg; - const struct mtk_pll_div_table *div_table; - const char *parent_name; - u32 en_reg; - u8 pll_en_bit; /* Assume 0, indicates BIT(0) by default */ -}; - -void mtk_clk_register_plls(struct device_node *node, - const struct mtk_pll_data *plls, int num_plls, - struct clk_onecell_data *clk_data); - struct clk *mtk_clk_register_ref2usb_tx(const char *name, const char *parent_name, void __iomem *reg); =20 diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c index f04f724e12e5..64f59554bc9b 100644 --- a/drivers/clk/mediatek/clk-pll.c +++ b/drivers/clk/mediatek/clk-pll.c @@ -13,6 +13,7 @@ #include =20 #include "clk-mtk.h" +#include "clk-pll.h" =20 #define REG_CON0 0 #define REG_CON1 4 diff --git a/drivers/clk/mediatek/clk-pll.h b/drivers/clk/mediatek/clk-pll.h new file mode 100644 index 000000000000..d01b0c38311d --- /dev/null +++ b/drivers/clk/mediatek/clk-pll.h @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2014 MediaTek Inc. + * Author: James Liao + */ + +#ifndef __DRV_CLK_MTK_PLL_H +#define __DRV_CLK_MTK_PLL_H + +#include + +struct clk_ops; +struct clk_onecell_data; +struct device_node; + +struct mtk_pll_div_table { + u32 div; + unsigned long freq; +}; + +#define HAVE_RST_BAR BIT(0) +#define PLL_AO BIT(1) + +struct mtk_pll_data { + int id; + const char *name; + u32 reg; + u32 pwr_reg; + u32 en_mask; + u32 pd_reg; + u32 tuner_reg; + u32 tuner_en_reg; + u8 tuner_en_bit; + int pd_shift; + unsigned int flags; + const struct clk_ops *ops; + u32 rst_bar_mask; + unsigned long fmin; + unsigned long fmax; + int pcwbits; + int pcwibits; + u32 pcw_reg; + int pcw_shift; + u32 pcw_chg_reg; + const struct mtk_pll_div_table *div_table; + const char *parent_name; + u32 en_reg; + u8 pll_en_bit; /* Assume 0, indicates BIT(0) by default */ +}; + +void mtk_clk_register_plls(struct device_node *node, + const struct mtk_pll_data *plls, int num_plls, + struct clk_onecell_data *clk_data); + +#endif /* __DRV_CLK_MTK_PLL_H */ --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 C9DA2C433FE for ; Sat, 22 Jan 2022 09:18:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234218AbiAVJSh (ORCPT ); Sat, 22 Jan 2022 04:18:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234119AbiAVJSO (ORCPT ); Sat, 22 Jan 2022 04:18:14 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEFFDC061401 for ; Sat, 22 Jan 2022 01:18:13 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id t18so10870390plg.9 for ; Sat, 22 Jan 2022 01:18:13 -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=MgVxYLqn7e5CbtxyDunniYd0pM9V2lFEkskjcE0RgkM=; b=Uoy5LPBTFoU2mLPls+lvhUkx952hkxqIoO9usG6HBvsf5PK45trlJ0cDer4J2/ruQk YeehYSwjMVpGOqkFHMSSV0qnghdbQP4B5f4R6C/O/pqag9DE5V9+z6qm/82kghl7gcyC fNTL245NESs6ROe+n/GD7AHbl6KxLkUBSESIo= 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=MgVxYLqn7e5CbtxyDunniYd0pM9V2lFEkskjcE0RgkM=; b=rPtQATa0sAzyAytrWZiDh9NBLvR4JIagOHFBysRa2125yjrvvggJl5IiYPwXrZZkbR yiineo4dA34QHKrEebQsT/I1UZt/6Kfd0t5le6RZUIXLeJxmXiB5x+u7iFmVjVTdEGkW 5gdyUGB1PE6H9f5lNRnlxLCmB5aQ5UUk6GO4EgTIWilkrRn09NddiwX6RsRGuMguASVo toxfHD7GErT/+2RKwitQ89EnpNh+RrfyPlczZaV30NrFC/uqVZDgWD/v36BSWTcgIPC6 oAOavq0aNqnEb6eNsEtbQOaCZxs7ysMjE5XIo+mPz1EV43XEdLbhs2zMn/aUgLLtrfBB q0Qw== X-Gm-Message-State: AOAM532K3A8aJfi3aAmU9rSDq9hX9bhGKrVmmRhBOgEuUscUPus4iISH 5WlfsoB1VxUk+LZiDf5a8E+roQ== X-Google-Smtp-Source: ABdhPJz5s0TxxuEXSon71jmhisUSFx3ph6WF8cavJgqsrEAxrQRzhkraOlOofKfWPWSYHQ/+KjByhQ== X-Received: by 2002:a17:90a:b702:: with SMTP id l2mr4405014pjr.126.1642843093546; Sat, 22 Jan 2022 01:18:13 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:13 -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 13/31] clk: mediatek: pll: Implement unregister API Date: Sat, 22 Jan 2022 17:17:13 +0800 Message-Id: <20220122091731.283592-14-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" The PLL 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 PLL type clk. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-pll.c | 49 ++++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-pll.h | 2 ++ 2 files changed, 51 insertions(+) diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c index 64f59554bc9b..081e0df8203e 100644 --- a/drivers/clk/mediatek/clk-pll.c +++ b/drivers/clk/mediatek/clk-pll.c @@ -360,6 +360,15 @@ static struct clk *mtk_clk_register_pll(const struct m= tk_pll_data *data, return clk; } =20 +static void mtk_clk_unregister_pll(struct clk *clk) +{ + struct clk_hw *hw =3D __clk_get_hw(clk); + struct mtk_clk_pll *pll =3D to_mtk_clk_pll(hw); + + clk_unregister(clk); + kfree(pll); +} + void mtk_clk_register_plls(struct device_node *node, const struct mtk_pll_data *plls, int num_plls, struct clk_onecell_data *= clk_data) { @@ -388,4 +397,44 @@ void mtk_clk_register_plls(struct device_node *node, } EXPORT_SYMBOL_GPL(mtk_clk_register_plls); =20 +static __iomem void *mtk_clk_pll_get_base(struct clk *clk, + const struct mtk_pll_data *data) +{ + struct clk_hw *hw =3D __clk_get_hw(clk); + struct mtk_clk_pll *pll =3D to_mtk_clk_pll(hw); + + return pll->base_addr - data->reg; +} + +void mtk_clk_unregister_plls(const struct mtk_pll_data *plls, int num_plls, + struct clk_onecell_data *clk_data) +{ + __iomem void *base =3D NULL; + int i; + + if (!clk_data) + return; + + for (i =3D num_plls; i > 0; i--) { + const struct mtk_pll_data *pll =3D &plls[i - 1]; + + if (IS_ERR_OR_NULL(clk_data->clks[pll->id])) + continue; + + /* + * This is quite ugly but unfortunately the clks don't have + * any device tied to them, so there's no place to store the + * pointer to the I/O region base address. We have to fetch + * it from one of the registered clks. + */ + base =3D mtk_clk_pll_get_base(clk_data->clks[pll->id], pll); + + mtk_clk_unregister_pll(clk_data->clks[pll->id]); + clk_data->clks[pll->id] =3D ERR_PTR(-ENOENT); + } + + iounmap(base); +} +EXPORT_SYMBOL_GPL(mtk_clk_unregister_plls); + MODULE_LICENSE("GPL"); diff --git a/drivers/clk/mediatek/clk-pll.h b/drivers/clk/mediatek/clk-pll.h index d01b0c38311d..a889b1e472e7 100644 --- a/drivers/clk/mediatek/clk-pll.h +++ b/drivers/clk/mediatek/clk-pll.h @@ -51,5 +51,7 @@ struct mtk_pll_data { void mtk_clk_register_plls(struct device_node *node, const struct mtk_pll_data *plls, int num_plls, struct clk_onecell_data *clk_data); +void mtk_clk_unregister_plls(const struct mtk_pll_data *plls, int num_plls, + struct clk_onecell_data *clk_data); =20 #endif /* __DRV_CLK_MTK_PLL_H */ --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 DFC6EC433FE for ; Sat, 22 Jan 2022 09:18:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234241AbiAVJSm (ORCPT ); Sat, 22 Jan 2022 04:18:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234125AbiAVJSQ (ORCPT ); Sat, 22 Jan 2022 04:18:16 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 254C1C06173D for ; Sat, 22 Jan 2022 01:18:16 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id p125so10272225pga.2 for ; Sat, 22 Jan 2022 01:18:16 -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=+Kc6foonKZ2qx7qyPXvjxQG3lzal7VzJVK7KIYAvJnU=; b=RHT7W3/ZsxsUmr+8O1nsTAlt6tlW1+Dhp4h5kBzotqI3R6YbBJVuKnijdIFU9OMx6M UX3bVws4jV0tIF5PgNS580YUHpdXwlzudiOHTYlMouBxtGezlIsxaT7N1ttLXEh3UOsw Y9XYHMLApFpuxg98NlVVPZjBGx8Db/2LkavQQ= 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=+Kc6foonKZ2qx7qyPXvjxQG3lzal7VzJVK7KIYAvJnU=; b=i4SI9jQn+9RTvBxsivS+D9z6sFS7Csnhi00tNLFMOVVuj7NPHxjSYYTvuh11bY4Fwa WiF1rY0HxlfSp+rRDKGCBxcUj1Ps+TtRulMFskPWgwnL0/HUSzxY9NJAduQA1STagxK0 3w/8xgAt7BahlaBLVkFmAenlrjhacDsm6jCYpbjeq4xqgzfg87UbwAN6BkKVjhuNkPl2 7h8TxV/0VSh1+aY7MGAICbFlKLkfPSNdkj9YzN/jzo/ON6RXcCqCXON7oqxtSfjgXOEY WpLSp4h/A3oxOngaCn/4C1raB+xXxQl9i240ZPjopP0PEQgF+FGzrPwNWgBO4xirLtQr fpBg== X-Gm-Message-State: AOAM533XRFLS3T6SUTAOYrgb90qIsFpU72MujBGbUY99XgFSGEgZqDo3 p87//0ytAZaqy/QVAQGxKkEhQQ== X-Google-Smtp-Source: ABdhPJy8nbK4n66ql++9II+COsZy//czwDilD2Qwh2Dtb/rurvA7kS9mqeUDD4jcA4hNweQ1+uLf7Q== X-Received: by 2002:a63:6b42:: with SMTP id g63mr5394978pgc.345.1642843095714; Sat, 22 Jan 2022 01:18:15 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:15 -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 14/31] clk: mediatek: pll: Clean up included headers Date: Sat, 22 Jan 2022 17:17:14 +0800 Message-Id: <20220122091731.283592-15-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" Some included headers aren't actually used anywhere, while other headers with the declaration of functions and structures aren't directly included. Get rid of the unused ones, and add the ones that should be included directly. Also, expand the MHZ macro with spelled-out "1000 * 1000" to be able to not include clk-mtk.h. The existing ternary operator is rewritten in a shortened form to accommodate the expanded macro. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-pll.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c index 081e0df8203e..9698d1c97cd6 100644 --- a/drivers/clk/mediatek/clk-pll.c +++ b/drivers/clk/mediatek/clk-pll.c @@ -4,15 +4,15 @@ * Author: James Liao */ =20 -#include -#include +#include +#include +#include +#include #include #include +#include #include -#include -#include =20 -#include "clk-mtk.h" #include "clk-pll.h" =20 #define REG_CON0 0 @@ -162,7 +162,7 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *p= ll, u32 pcw, static void mtk_pll_calc_values(struct mtk_clk_pll *pll, u32 *pcw, u32 *po= stdiv, u32 freq, u32 fin) { - unsigned long fmin =3D pll->data->fmin ? pll->data->fmin : (1000 * MHZ); + unsigned long fmin =3D pll->data->fmin ?: (1000 * 1000 * 1000); const struct mtk_pll_div_table *div_table =3D pll->data->div_table; u64 _pcw; int ibits; --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 6BA15C433F5 for ; Sat, 22 Jan 2022 09:18:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234165AbiAVJSo (ORCPT ); Sat, 22 Jan 2022 04:18:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233985AbiAVJSS (ORCPT ); Sat, 22 Jan 2022 04:18:18 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72500C061401 for ; Sat, 22 Jan 2022 01:18:18 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id e28so6621256pfj.5 for ; Sat, 22 Jan 2022 01:18:18 -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=09dDye5BTCvVOx6QTdRmbLqERJKxycNqJsPrVtKKxIE=; b=X3nIg5syolDA5HTdP7//AqfI4DJhbQGH46eWBgE4YrqJbpegvuy5ySZCOWf+X4wydK PNoitdzRr/Dmxm9+e3Den/5btX1k/CCClXLx7nT9PJ0XmJCJfRhD9wzIfRps3y2eGcp4 tsPfpIzu5etmcDeibSN0H6wmhO6CcAKJ6YS94= 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=09dDye5BTCvVOx6QTdRmbLqERJKxycNqJsPrVtKKxIE=; b=Mseo8WwuPvRHtW3+/F67Q06KMPu+cxX3lLNwykAnqC9crohFoMC7jY8oo9ypMf64a4 pR97qDvY+Tqu5O/VvfReKzu8rcYhFuM2+vpbv3jxMvacqsq5sDS36ZcZ/srlMaZfFb2+ JD7SZNPR+nKTvSJF34FQnIYgEIoTljHkqRYwBRjk8ByU7O0NRLThOt7NVDJtNk9F63ZV R5RJmvrvqIMBXx7kk3ERmePdzmEspTgZSfSX+uoGC/0NBwTNENpttpXbHDBo1Rf1RgRc 7d8BJAlEWUZYZ8YFSD1SxQADa7BW8jHC7Pv/ni0c+/UQevVEtXRhQbp5nU/TRO3FvWcW mYhA== X-Gm-Message-State: AOAM532yZHjlFXM/n0FnkAOV51Ljm4xrYNy5wBVQ9GWgdP9H6zv169Rf 9gdafJxXI75r3SePV7lqoH33qw== X-Google-Smtp-Source: ABdhPJxMWFtklW2XRMgutkF5dkiCv5I5Xs1QlLxCtE78BQzj9qwRiqQ5OKon4OfL+/Wvz2V100nLCA== X-Received: by 2002:a63:8f4a:: with SMTP id r10mr5515957pgn.414.1642843097972; Sat, 22 Jan 2022 01:18:17 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:17 -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 15/31] clk: mediatek: Implement mtk_clk_unregister_fixed_clks() API Date: Sat, 22 Jan 2022 17:17:15 +0800 Message-Id: <20220122091731.283592-16-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_fixed_clks(), as the name suggests, is used to register a given list of fixed rate 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 | 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 0c5db3c71fdd..7c0d5706eed7 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -80,6 +80,26 @@ void mtk_clk_register_fixed_clks(const struct mtk_fixed_= clk *clks, } EXPORT_SYMBOL_GPL(mtk_clk_register_fixed_clks); =20 +void mtk_clk_unregister_fixed_clks(const struct mtk_fixed_clk *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_clk *rc =3D &clks[i - 1]; + + if (IS_ERR_OR_NULL(clk_data->clks[rc->id])) + continue; + + clk_unregister_fixed_rate(clk_data->clks[rc->id]); + clk_data->clks[rc->id] =3D ERR_PTR(-ENOENT); + } +} +EXPORT_SYMBOL_GPL(mtk_clk_unregister_fixed_clks); + void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, int num, struct clk_onecell_data *clk_data) { diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index 168220f85489..cc7f920eabb4 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -34,8 +34,10 @@ struct mtk_fixed_clk { .rate =3D _rate, \ } =20 -void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, - int num, struct clk_onecell_data *clk_data); +void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num, + struct clk_onecell_data *clk_data); +void mtk_clk_unregister_fixed_clks(const struct mtk_fixed_clk *clks, int n= um, + struct clk_onecell_data *clk_data); =20 struct mtk_fixed_factor { int id; --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 F1AAFC433EF for ; Sat, 22 Jan 2022 09:19:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234173AbiAVJS7 (ORCPT ); Sat, 22 Jan 2022 04:18:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234007AbiAVJSU (ORCPT ); Sat, 22 Jan 2022 04:18:20 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACF3AC061748 for ; Sat, 22 Jan 2022 01:18:20 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id w190so4880433pfw.7 for ; Sat, 22 Jan 2022 01:18:20 -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=0r/icLyBiPRWAX9DR8xwoo1Ajn0xsQM7/jQJfiNovl4=; b=NIkPglMlv2Ah6b+M/D72wGdMSWs329exo2s/sWwo2kEcfCVveRvRW8MflsWkpCHok3 UZJp2re6/JJjOPSx8f/2LE/F4aWPQMMtXDkn8xgg+wi4Q6MmSbCmDvaIcAGT/QwbE6Oi zhQ2nJ1tR6PVO4uBVfjkOAcFQ/7daZCPRGv40= 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=0r/icLyBiPRWAX9DR8xwoo1Ajn0xsQM7/jQJfiNovl4=; b=bh6Jatf9NTYdNjf7/T+3EUuHWfzwocXM+wsi+apw5roosyRlIUFn7SmKHbA869tRZP pqWu1QsoYSnMCKfIane0qmGnHqJ5iT/MQ0mV/Xz79+kdXJE1MLB51cr4N4W5WuUmdP8g twYyKtukLONteZ6RQRGTSnYIEUjZbKKFMAhrvyaLlbpq6GScDI9VfKiwTFBk8uJV6NeF ZKwRTaXKsYOvtRTW190/xiR/r9ys7bvyVVi11aD2A/9h1cywXNf1zx6p+VoAD55pVov2 Q3UPkIh3cAL18osu4ylyrGnfJt07urAIhiCgni/GkbPPSKDsRTA+oAL2NHAddHi9pq0v GL5A== X-Gm-Message-State: AOAM532/JMEciEUN6LkPM7f6PJfngxVHoApUjPJ6WDiIg2fsOLpAtrmB BSPxh6g4ljBZX2879NEO3Pi5lA== X-Google-Smtp-Source: ABdhPJwZs4dBcrlJUtQnvPcUNmuVMsA70DkLPP33YojMfq1AMhxrajglxuuN8K2CRtm/7ScyiwQpMw== X-Received: by 2002:a65:4685:: with SMTP id h5mr5536639pgr.14.1642843100230; Sat, 22 Jan 2022 01:18:20 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:19 -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 16/31] clk: mediatek: Implement mtk_clk_unregister_factors() API Date: Sat, 22 Jan 2022 17:17:16 +0800 Message-Id: <20220122091731.283592-17-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_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 --- 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.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 7AD59C433F5 for ; Sat, 22 Jan 2022 09:19:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234194AbiAVJTN (ORCPT ); Sat, 22 Jan 2022 04:19:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234136AbiAVJSe (ORCPT ); Sat, 22 Jan 2022 04:18:34 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1068C061756 for ; Sat, 22 Jan 2022 01:18:22 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id pf13so11361403pjb.0 for ; Sat, 22 Jan 2022 01:18:22 -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=OL43s5I7LNHYgmLD2gKEH5DLtt+mhRAmKo34NJ8rtwE=; b=Ggo0kYpwoWnwSolmdIbTiIGBqEoKYbbJGe28yVsffQtRCfNStfbzu7ufp6Frh7kLje tP7/f8uW+0pNL+bOuvU/y84/uITpHYEb4voWNxDpRawsGCYd/r3YXYAKeQhm0MdB4Mlt UhRx3i9YIEqpmxfnvwv7tKZDw0i0XRfWQqIWo= 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=OL43s5I7LNHYgmLD2gKEH5DLtt+mhRAmKo34NJ8rtwE=; b=B+r73/D7DuEWE3PX30aQqyg2p4U84V5bjNkE84XWgqtZ1RHURU9vF8O1+uMYAMwdd2 0t7G40SXks4DD85KnJF53lIbqo4iiHN/FmJxoHAFEo5G5RtpcaU+tMHkY37000q+1/hj rnu4/MI9a4VpKubNr/iIurF7oJtqMujcGx3wBJNvPBxxZZ3chslVysqmrWbURWydayCN +wpYD/ohtBSadnLgx5o8LlN9y+AAC7j+K4N40RMMNjFXbwJVORYNMNhDSVLaElrQKxWs X9wFlltBtCsbwoB4a2GCFRMLu8PWZe85bbfAxsF0uvRFmD5zTVuejZfq2V9QcJp3T9ji 598g== X-Gm-Message-State: AOAM533EOMn+xslxPgKCasS2fjIYpWOLt/w7XJoxoweot7HOnv1Uf6NO xCGNBRvnNXI1rxkJdmmfG/90AQ== X-Google-Smtp-Source: ABdhPJxYWG1G6A9uuQSoK+hKtiVNFyIt2rfYZvu/Rc9m92uJiLRu3G1sp2IZGb5nnUAghww4dGPDEA== X-Received: by 2002:a17:903:32c6:b0:14b:3f5b:e9c6 with SMTP id i6-20020a17090332c600b0014b3f5be9c6mr89273plr.136.1642843102481; Sat, 22 Jan 2022 01:18:22 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:22 -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 17/31] clk: mediatek: Implement mtk_clk_unregister_divider_clks() API Date: Sat, 22 Jan 2022 17:17:17 +0800 Message-Id: <20220122091731.283592-18-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_divider_clks(), as the name suggests, is used to register a given list of divider 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 | 19 +++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 8 +++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index b267b2f04b84..3a6dfe445e63 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -286,6 +286,25 @@ void mtk_clk_register_dividers(const struct mtk_clk_di= vider *mcds, } } =20 +void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, 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_clk_divider *mcd =3D &mcds[i - 1]; + + if (IS_ERR_OR_NULL(clk_data->clks[mcd->id])) + continue; + + clk_unregister_divider(clk_data->clks[mcd->id]); + clk_data->clks[mcd->id] =3D ERR_PTR(-ENOENT); + } +} + int mtk_clk_simple_probe(struct platform_device *pdev) { const struct mtk_clk_desc *mcd; diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index 4db1a97c1250..e3ae22fb0334 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -176,9 +176,11 @@ struct mtk_clk_divider { .div_width =3D _width, \ } =20 -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); +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); +void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, int n= um, + struct clk_onecell_data *clk_data); =20 struct clk_onecell_data *mtk_alloc_clk_data(unsigned int clk_num); void mtk_free_clk_data(struct clk_onecell_data *clk_data); --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 From nobody Wed Nov 13 15:09:41 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 2704AC433EF for ; Sat, 22 Jan 2022 09:19:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231154AbiAVJTV (ORCPT ); Sat, 22 Jan 2022 04:19:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234147AbiAVJSk (ORCPT ); Sat, 22 Jan 2022 04:18:40 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E138C061760 for ; Sat, 22 Jan 2022 01:18:27 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id n16-20020a17090a091000b001b46196d572so11244578pjn.5 for ; Sat, 22 Jan 2022 01:18:27 -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=4dLgzVu3UPZmPwEvYWiLff/Jy1kChuWKg74HILKInho=; b=gvpLT+OdMi/dn6Dv46g2q0G1XapqMDfLybAIlxoP4Ayr5j4S/KvK9rv/+vCyBlQ1iy 2oTd9OqTJ9lEf2gY7L2QkJr1k9eKXK4uIBF6TCpPlZw5eqpxT+obPum79TTyWO4vY00k /uoM9jLUdRSy39Sb3qF+pNjr3o77BCBo2yzxk= 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=4dLgzVu3UPZmPwEvYWiLff/Jy1kChuWKg74HILKInho=; b=bGKOqTHA4DeNvfkOeXfU6DN9P6v/n3oxKwxJzEsw+kaZmquViQ7XjWoB5HkSDXCW9t +wwzNfOU+4mqHUqmUyph+nONSFHlAiZCBmVovOuoZ+AFA6yaMGchYyd2a72wnsM9Qiwg JydeCs1SSHDGZMEtvvbjySYSCdW1YO6JAfyeq/f4zfrXhsvlvi64zT6NhbNnwkGbllE7 eEMMzZU6eicgsznwHvxsL0XlplutVyu+ndxlOMUPQjPaEQxcaxbmQ9tSqr5Ukz8o7hIl FRJIcBiAEkrksv8/us/u6R9Ysc5ak4apDvwzu6zbK2TjWB1KnRkApKJg57Xhn9mk1nY5 h4VQ== X-Gm-Message-State: AOAM533D8HsbLxD6cvSGKyPQQTxc+ZK806tUI/67/fVVuLRNj2ENhsTQ U5aUo5rrjYDqB0mXOC8XfLbSag== X-Google-Smtp-Source: ABdhPJwrAq/6QES+b7lFgZS4hCPr/6p1PUXBrtNXH0twTGUh/4YxyTn0GKRlHBgLrCyy4BiumuQBmw== X-Received: by 2002:a17:902:d2c6:b0:14a:6e28:591c with SMTP id n6-20020a170902d2c600b0014a6e28591cmr6956198plc.85.1642843106909; Sat, 22 Jan 2022 01:18:26 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:26 -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 19/31] clk: mediatek: Add mtk_clk_simple_remove() Date: Sat, 22 Jan 2022 17:17:19 +0800 Message-Id: <20220122091731.283592-20-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" In commit c58cd0e40ffa ("clk: mediatek: Add mtk_clk_simple_probe() to simplify clock providers"), a generic probe function was added to simplify clk drivers that only needed to support clk gates. However due to the lack of unregister APIs, a corresponding remove function was not added. Now that the unregister APIs have been implemented, add aforementioned remove function to make it complete. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mtk.c | 15 +++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 1 + 2 files changed, 16 insertions(+) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 2150ed8678e0..cd76e1d80242 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -369,6 +369,8 @@ int mtk_clk_simple_probe(struct platform_device *pdev) if (r) goto free_data; =20 + platform_set_drvdata(pdev, clk_data); + return r; =20 free_data: @@ -376,4 +378,17 @@ int mtk_clk_simple_probe(struct platform_device *pdev) return r; } =20 +int mtk_clk_simple_remove(struct platform_device *pdev) +{ + const struct mtk_clk_desc *mcd =3D of_device_get_match_data(&pdev->dev); + struct clk_onecell_data *clk_data =3D platform_get_drvdata(pdev); + struct device_node *node =3D pdev->dev.of_node; + + of_clk_del_provider(node); + mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data); + mtk_free_clk_data(clk_data); + + return 0; +} + MODULE_LICENSE("GPL"); diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index 3c3a934f53cd..4fa658f5d934 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -202,5 +202,6 @@ struct mtk_clk_desc { }; =20 int mtk_clk_simple_probe(struct platform_device *pdev); +int mtk_clk_simple_remove(struct platform_device *pdev); =20 #endif /* __DRV_CLK_MTK_H */ --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 B6B50C433F5 for ; Sat, 22 Jan 2022 09:19:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234396AbiAVJTY (ORCPT ); Sat, 22 Jan 2022 04:19:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234233AbiAVJSl (ORCPT ); Sat, 22 Jan 2022 04:18:41 -0500 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C774C061763 for ; Sat, 22 Jan 2022 01:18:29 -0800 (PST) Received: by mail-pf1-x42e.google.com with SMTP id x37so7096055pfh.8 for ; Sat, 22 Jan 2022 01:18:29 -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=y7ikYR2DO0KTQJWDZKewH0oM7Rmj3LYjnAGwR2+oJK8=; b=MK5yUJ0QuCGEKf3Fc/Pxxv6kVp2sCxxGWLo2+2smGGBR2K/o7OHOjjJgu2n+G57HdW eAjYKu6r69okMTLnUNRSORWTYe+o4pIcmJH6zpYeOFj361NZkjOI+OknPUS5cKY/PrsO D/j75AnvdU5gV234xvjW9KODPrnuFljn+y8n8= 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=y7ikYR2DO0KTQJWDZKewH0oM7Rmj3LYjnAGwR2+oJK8=; b=JhVK8pP9Vuu/PPmKIkdXZUz6iueQJ5eNZVSR+TjHGAiNOjPYkedQSnUm2D0Ju7KuTU k2VhqW+eWscdCXEfmk8zdb7MQotT7pM6lb2KzTuoo8dWo1cB+NaIYEcoa6IOnkHIXLHp j5sUvxHh4bZBtQolOc1Q8iARk+nygboTySxc4iof7XMwqzFvjt1E21cY31daawSp11mW eXtC15NsUdrOLBbq8j8Vzm/scQXz5pdZHRI/LV9xkClh/r78NL5OQIlArCrVMczpByFC mDWouyp+bNs73d225b2SC+L5B2E7WxPJm3ose4TXfxalfqnPUjG3xf48IsmQbvZD7mQ+ pO+w== X-Gm-Message-State: AOAM532rVKXDbtg7TqegNVXCeMMgQ2Vp0lHrD0dBjGrUxxO879RJlLZY G3aQBmja+2v4TMFJyGne8T8K+A== X-Google-Smtp-Source: ABdhPJzqwpvGnrOLvq1Wc8tRhNv6bldrv9fnylHIYcV+GIPyjQgEr0P19blEPg/NwRaCCyKvYFaDxw== X-Received: by 2002:a63:b204:: with SMTP id x4mr5614276pge.224.1642843109114; Sat, 22 Jan 2022 01:18:29 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:28 -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 20/31] clk: mediatek: mtk: Clean up included headers Date: Sat, 22 Jan 2022 17:17:20 +0800 Message-Id: <20220122091731.283592-21-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" Some included headers aren't actually used anywhere, while other headers with the declaration of functions and structures aren't directly included. Get rid of the unused ones, and add the ones that should be included directly. On the header side, replace headers that are included purely for data structure definitions with forward declarations. This decreases the amount of preprocessing and compilation effort required for each inclusion. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mtk.c | 13 ++++++------- drivers/clk/mediatek/clk-mtk.h | 12 ++++++------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index cd76e1d80242..d2c50186cceb 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -4,17 +4,16 @@ * Author: James Liao */ =20 -#include -#include +#include +#include #include #include -#include -#include -#include -#include #include -#include +#include +#include #include +#include +#include =20 #include "clk-mtk.h" #include "clk-gate.h" diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index 4fa658f5d934..7f902581a115 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -7,19 +7,19 @@ #ifndef __DRV_CLK_MTK_H #define __DRV_CLK_MTK_H =20 -#include -#include #include -#include - -struct clk; -struct clk_onecell_data; +#include +#include +#include +#include =20 #define MAX_MUX_GATE_BIT 31 #define INVALID_MUX_GATE_BIT (MAX_MUX_GATE_BIT + 1) =20 #define MHZ (1000 * 1000) =20 +struct platform_device; + struct mtk_fixed_clk { int id; const char *name; --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 4B6D3C433EF for ; Sat, 22 Jan 2022 09:19:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234123AbiAVJT4 (ORCPT ); Sat, 22 Jan 2022 04:19:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233358AbiAVJTL (ORCPT ); Sat, 22 Jan 2022 04:19:11 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5E09C06176D for ; Sat, 22 Jan 2022 01:18:31 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id h5so2664997pfv.13 for ; Sat, 22 Jan 2022 01:18:31 -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=WfZgCCKhWWL4g9b63+UJL7GvGCEBOJx3TOX6o+D52NI=; b=BsAVCGC9C4UCU9w4e0beBa1T1K3NEh7vcM+upT9wdmY25oE2j+R+CPgkeTRHf5YF0U 2HLwzn10mw+DqT20c0YkpYAow643YIWjQZXE/tqB9DuFeaRY5JLeEKvdwGTpttT9fxD1 xl8Jem+89eo2oglIvf1Hx3HfDHQHmamvRvEmc= 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=WfZgCCKhWWL4g9b63+UJL7GvGCEBOJx3TOX6o+D52NI=; b=gpePOa1PdoiEoiyLnRdlC2yzv9RqGoXrikjfOXgPitXu+W8G0WShxv21k5AoUHATpZ TmcbCQtiHpSGLb8GSzGHLKNsRCX04VnqydiHOKn+E54in3gC7o44ql3urNmlrf/f/yTp IJkIkNFFqeeB/4BoXvUJfBN8J1Y7yAsYAIwNAiXk7CgyFmojxokDv0/p9NZhPQu3zmOP Pn/I6Hqc9NFE2qI5zCDDt+C6q3yKNbxX4TbTQPrHtykH7A73wpuKHYwjXbchjXjgK1OO c/Ri55A+af1536Ryc9kBxsxe48koKPxzZQVA3d7xYDltjnBY4SBPd+cU6LFZLv+N3wYy xT9Q== X-Gm-Message-State: AOAM530Ldo7DLCPpFGq3TJgpOikMj1Va4+ozvg2dY+hrmZ7VQqzy6jVJ qYiGjno/70FjyzT1sWei+NuC0w== X-Google-Smtp-Source: ABdhPJx2VhgGVxkpCD6c4pBfWLcAfhPTpc4I2h8LOcFbzz4iFjf2yJpC7rnNN2p2KTBfDDh2j2J+Lw== X-Received: by 2002:a63:2b84:: with SMTP id r126mr5552900pgr.624.1642843111330; Sat, 22 Jan 2022 01:18:31 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:30 -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 21/31] clk: mediatek: cpumux: Implement error handling in register API Date: Sat, 22 Jan 2022 17:17:21 +0800 Message-Id: <20220122091731.283592-22-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" The cpumux clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed. Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-cpumux.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/clk/mediatek/clk-cpumux.c b/drivers/clk/mediatek/clk-c= pumux.c index 658aee789f44..499c60432280 100644 --- a/drivers/clk/mediatek/clk-cpumux.c +++ b/drivers/clk/mediatek/clk-cpumux.c @@ -123,13 +123,26 @@ int mtk_clk_register_cpumuxes(struct device_node *nod= e, clk =3D mtk_clk_register_cpumux(mux, regmap); if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", mux->name, clk); - continue; + goto err; } =20 clk_data->clks[mux->id] =3D clk; } =20 return 0; + +err: + while (--i >=3D 0) { + const struct mtk_composite *mux =3D &clks[i]; + + if (IS_ERR_OR_NULL(clk_data->clks[mux->id])) + continue; + + mtk_clk_unregister_cpumux(clk_data->clks[mux->id]); + clk_data->clks[mux->id] =3D ERR_PTR(-ENOENT); + } + + return PTR_ERR(clk); } =20 void mtk_clk_unregister_cpumuxes(const struct mtk_composite *clks, int num, --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 5A932C433EF for ; Sat, 22 Jan 2022 09:20:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234184AbiAVJT6 (ORCPT ); Sat, 22 Jan 2022 04:19:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234116AbiAVJTM (ORCPT ); Sat, 22 Jan 2022 04:19:12 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC3F2C06173B for ; Sat, 22 Jan 2022 01:18:34 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id u10so6522393pfg.10 for ; Sat, 22 Jan 2022 01:18:34 -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=1TEZ0MfngpjieBK0SXrIypAK0YzHVKnAErn4UHbTrxk=; b=G89iIeSLYaSHnG28ej39jy7C6u1UfWz4foTwDQ3HDtc1rwz7fX2NqHJAzXQGdhTaM7 7dkLHYZsAY363xBWB4t2vrJVLdsj7YQorPuqazaY1Zwn/+TUsRlc6Ic7+WjjdaooeKuk gURdzHetX2DAxi4E6qBVou42HNmx++CcJTDEw= 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=1TEZ0MfngpjieBK0SXrIypAK0YzHVKnAErn4UHbTrxk=; b=hsaMFdqUBrz3CqQpOKM4GUBRCvPakuCI+iknDrPiqP/369wrroAzsiHk0QURLozTu3 GXM4zyaDccfr+p4fHR/6W0GhaZTLsAM/yDFMq33X2CSx+/ADlWDaHJ+RcQYGIsgcy6PB 7RDlL5EoCGXhRQ1O32sTPgcLqRBbeP0uxw6kBS/b6uYAHqdFXhRu37oKGm2THnz3yW/H Zr/zckQiNGjyu6vbcLU13moUrZZsxf0x1I9h00fG9mgY0IqZXw5Bd48Gq2rSKEkpDafr WaT8LzYnJ2LBkwzSLrMeKxzkODvIdpUzvofSMcKtmo5HMlFEzNHciS/x/f5HaUVEXAyB 7iDA== X-Gm-Message-State: AOAM5335Akl/I+W+AVoid+kH8qpRkPWq49wOQycKcvhSfeZeX1BCZjVB +kC+WPhUtKLPKQrYaJ4jVXgjag== X-Google-Smtp-Source: ABdhPJxJiShS15jsyBrH2j+XqBNlWH2MNjyeLX7mBslEBYwQ2NuEg6RU8qADx6ysHah6+FMDvsbf+Q== X-Received: by 2002:a63:4e5a:: with SMTP id o26mr5497546pgl.272.1642843113500; Sat, 22 Jan 2022 01:18:33 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:33 -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 22/31] clk: mediatek: gate: Implement error handling in register API Date: Sat, 22 Jan 2022 17:17:22 +0800 Message-Id: <20220122091731.283592-23-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" The gate clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed. Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-gate.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/clk/mediatek/clk-gate.c b/drivers/clk/mediatek/clk-gat= e.c index e8881ae1489a..631ff170b7b9 100644 --- a/drivers/clk/mediatek/clk-gate.c +++ b/drivers/clk/mediatek/clk-gate.c @@ -237,13 +237,26 @@ int mtk_clk_register_gates_with_dev(struct device_nod= e *node, =20 if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", gate->name, clk); - continue; + goto err; } =20 clk_data->clks[gate->id] =3D clk; } =20 return 0; + +err: + while (--i >=3D 0) { + const struct mtk_gate *gate =3D &clks[i]; + + if (IS_ERR_OR_NULL(clk_data->clks[gate->id])) + continue; + + mtk_clk_unregister_gate(clk_data->clks[gate->id]); + clk_data->clks[gate->id] =3D ERR_PTR(-ENOENT); + } + + return PTR_ERR(clk); } =20 int mtk_clk_register_gates(struct device_node *node, --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 56DDFC433F5 for ; Sat, 22 Jan 2022 09:20:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232171AbiAVJUD (ORCPT ); Sat, 22 Jan 2022 04:20:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234130AbiAVJTN (ORCPT ); Sat, 22 Jan 2022 04:19:13 -0500 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38106C061773 for ; Sat, 22 Jan 2022 01:18:36 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id 187so10050931pga.10 for ; Sat, 22 Jan 2022 01:18:36 -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=/yYGXqDxo/eWqrROn24aC9cA0IymJmQ8zZXIQFx6Mzg=; b=E3fL9k4nB0J+U7dhnH/244EmdfdD1ulLNX+eG5dBwQJtHMj/EcLeIsfa2TRUuWcGd9 oiNAiHupmkNXYOFsXFJ6LIF2ndolec9H7eZ97eKqnFFN80k3IizBuZjLwuQ1VELWkx31 mochVNtqJ50lh6iJe00VnTcom/Wyt65N6eHLk= 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=/yYGXqDxo/eWqrROn24aC9cA0IymJmQ8zZXIQFx6Mzg=; b=QjC0egiQgzUAOUj41mR/rOcZO2ziAFL50imS6LnM0bdhF/TgJDhqQvD/e6P97IzNAU 5LQE+4292t3NOHc74JUAvTXlRPBR6pIO9Tp7jMfWYbW7bRvt24S0Gst30ypDfxcsFwRf klhSl/I25HtjNHvNfkn12clnUgWnhMZxoZdH1nMQZnhVwQasjWagkd2lsV1bg1JpvmOQ 3SE21zkIzphmIzXEdt+KhPHw2/CjStPOph5YfQgTYUa7vZwQaeNNm9WPnwBTvYiLHSi0 39Pl/Q3c+WXcy4JVR20axAae+cK6YlJlcEdR+j+VbGx/qjjmMYWi1SUMMA9mZuKQ61uS zFYw== X-Gm-Message-State: AOAM532YKW0QEqABXYaqfzd4VTS/fLAJvD+cvjfuUx83LU9wGXVKuGBK Yu9GA+HLmdw/Hoo0YeqyJyK89g== X-Google-Smtp-Source: ABdhPJyf9HKfNksySR0iObSvFPhmBF8ZKz+iwD2Gd4unIv10qS1uI5MvXPoHzlLDKI0sSrcTb0B6jA== X-Received: by 2002:a63:6845:: with SMTP id d66mr5494690pgc.199.1642843115668; Sat, 22 Jan 2022 01:18:35 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:35 -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 23/31] clk: mediatek: mux: Reverse check for existing clk to reduce nesting level Date: Sat, 22 Jan 2022 17:17:23 +0800 Message-Id: <20220122091731.283592-24-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" The clk registration code here currently does: if (IS_ERR_OR_NULL(clk_data->clks[mux->id])) { ... do clk registration ... } This extra level of nesting wastes screen real estate. Reduce the nesting level by reversing the conditional shown above. Other than that, functionality is not changed. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mux.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c index 01af6a52711a..70aa42144632 100644 --- a/drivers/clk/mediatek/clk-mux.c +++ b/drivers/clk/mediatek/clk-mux.c @@ -208,16 +208,17 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxe= s, for (i =3D 0; i < num; i++) { const struct mtk_mux *mux =3D &muxes[i]; =20 - if (IS_ERR_OR_NULL(clk_data->clks[mux->id])) { - clk =3D mtk_clk_register_mux(mux, regmap, lock); + if (!IS_ERR_OR_NULL(clk_data->clks[mux->id])) + continue; =20 - if (IS_ERR(clk)) { - pr_err("Failed to register clk %s: %pe\n", mux->name, clk); - continue; - } + clk =3D mtk_clk_register_mux(mux, regmap, lock); =20 - clk_data->clks[mux->id] =3D clk; + if (IS_ERR(clk)) { + pr_err("Failed to register clk %s: %pe\n", mux->name, clk); + continue; } + + clk_data->clks[mux->id] =3D clk; } =20 return 0; --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 2B10BC433FE for ; Sat, 22 Jan 2022 09:20:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233965AbiAVJUF (ORCPT ); Sat, 22 Jan 2022 04:20:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234181AbiAVJTN (ORCPT ); Sat, 22 Jan 2022 04:19:13 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CEE2C061744 for ; Sat, 22 Jan 2022 01:18:38 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id o64so11345391pjo.2 for ; Sat, 22 Jan 2022 01:18:38 -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=8YPN+1zbb0FLmeCLY1r05U9fmN1fkUgWhlHUKwR4SnA=; b=X/ZtK2SpDBNbC3Na1TLbE7R39jEjlYu+bOu8u+DNEurHjH1tbv0qDNcyqaLBDYGA1Q 8VwLaJ/PNA2WR9RbNJ4eDR3BMD8BIyBuTAJ/WNHxn6wrfM3rexdndBFYfjpCNFiKNiqo E7c4AfXewebnkxmvND/e8oxCRJ21aYZY5EKFk= 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=8YPN+1zbb0FLmeCLY1r05U9fmN1fkUgWhlHUKwR4SnA=; b=pXuFtVyDYtCL6NxCqmUffdk4gDTh7g52ozlVezSNZKkAs6wYiq+xAzSd+xYf0IWh2v R7gIBAp+Jp9J7+9FcAbQ9CYNaD8gSrazULAWzt8A3dv50Js2sLPKkzIquD6kWDbM8n0n eP1pkGv2n3GgzY0LHSoF6VJqEtlgt6utlfp96qk3IDP7Vxjb+Dqfzcy7ovWcBYQLGNnN 4YwTmo8wJ3iqaO5N5aJuOJ7Ocp7bJU2WVBB53rugFvgL0R7UvqiEYk8gUyMSH+TwTNLu Ku6HtqdLdJoD3z3TJe64ppcWCg4WwhSJn73EE3wYcwXZpuKM2CeHQ0L6uh51jVdpoxyR 1GiA== X-Gm-Message-State: AOAM531U5oSBdrnwNPUwOgmHkmYxKIWKm0/CUatN8KnkGpLuJGzEwTjP H2aAQAiGjQMHttpbwcf91T41BQ== X-Google-Smtp-Source: ABdhPJxXOmZFL9go3UdVwQDSJBJ6fg68hKE0lBH0fAd3eIgttYowB4HFeZeVzoGLMe1c7TNtJJKpJw== X-Received: by 2002:a17:902:6b02:b0:149:7c20:c15b with SMTP id o2-20020a1709026b0200b001497c20c15bmr7026790plk.173.1642843117953; Sat, 22 Jan 2022 01:18:37 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:37 -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 24/31] clk: mediatek: mux: Implement error handling in register API Date: Sat, 22 Jan 2022 17:17:24 +0800 Message-Id: <20220122091731.283592-25-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" The mux clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed. Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mux.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c index 70aa42144632..f51e67650f03 100644 --- a/drivers/clk/mediatek/clk-mux.c +++ b/drivers/clk/mediatek/clk-mux.c @@ -215,13 +215,26 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxe= s, =20 if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", mux->name, clk); - continue; + goto err; } =20 clk_data->clks[mux->id] =3D clk; } =20 return 0; + +err: + while (--i >=3D 0) { + const struct mtk_mux *mux =3D &muxes[i]; + + 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] =3D ERR_PTR(-ENOENT); + } + + return PTR_ERR(clk); } EXPORT_SYMBOL_GPL(mtk_clk_register_muxes); =20 --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 7BD99C433FE for ; Sat, 22 Jan 2022 09:20:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234337AbiAVJUH (ORCPT ); Sat, 22 Jan 2022 04:20:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234136AbiAVJTN (ORCPT ); Sat, 22 Jan 2022 04:19:13 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DBDEC061749 for ; Sat, 22 Jan 2022 01:18:40 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id 192so7616092pfz.3 for ; Sat, 22 Jan 2022 01:18:40 -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=eaTeWNEgjqwSs85dnefGHTIT7+UhSwDVAnPu0tdvvQE=; b=PRKpymQV7xWUkT5i0Ifjesb20aljfmowZM4+SjVfERsyMOTucgZNAUD9YO7ar8zJfr d1WarJMewlgGgzEyuoKB/jwrxIOHkjlYILVfH25V+Psn2PnnJ4re0cugZPIspYaWN82h YROLc5AQFk+7TBATAuWCjd8/uH4WAnKtYdXk4= 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=eaTeWNEgjqwSs85dnefGHTIT7+UhSwDVAnPu0tdvvQE=; b=cucDIKM7g+GojlpGn2iRkENdAiNhG9aVrVbjs2u8ALU1x0pOKSgEZqJiNN3Ro/B4G1 OLHkj/4UxF2zhKCSQer6naKiATkreGWsT4B0POPUlcmAYqvkundmItZfRCkr3NMNCKii v+dgT+JwjBYE6KQBu0MyQ62eJDgW3Z/JWhgLplhfZhWQbqj5omqE99TEMH/j4hUyb8Ed pfXAzs6npCWVaG57evvKdYb+VJAWFpnKh7r1ZtTrKd9DFg0lTQSPCuRmNrPopr8muuHu x7sS7cfeBpruGt/LG7UHIfL+iGLxC+4rzWtYxOPnLAPvZZOm/wU6xvqyelHQ8Klb7rXl JEKg== X-Gm-Message-State: AOAM532iP1YmWJ4pbXZDyZW7jbW8w+1evRMRmISe2CkxazNESFWC5q4E hof68EzdZKxjhLBsWLAHhNgzSg== X-Google-Smtp-Source: ABdhPJwRjgaufhTqOLp2a5KJoAsvUWYZrG3/EkFjCr5zSjeJlit/D9oY598PALMqVYEQeylLybPljA== X-Received: by 2002:a65:610b:: with SMTP id z11mr5646889pgu.205.1642843120168; Sat, 22 Jan 2022 01:18:40 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:39 -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 25/31] clk: mediatek: pll: Implement error handling in register API Date: Sat, 22 Jan 2022 17:17:25 +0800 Message-Id: <20220122091731.283592-26-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" The pll clk type registration function does not stop or return errors if any clk failed to be registered, nor does it implement an error handling path. This may result in a partially working device if any step failed. Make the register function return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, and unmap the I/O space, is done in the new error path. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-pll.c | 23 +++++++++++++++++++---- drivers/clk/mediatek/clk-pll.h | 6 +++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c index 9698d1c97cd6..1dd15f560659 100644 --- a/drivers/clk/mediatek/clk-pll.c +++ b/drivers/clk/mediatek/clk-pll.c @@ -369,8 +369,9 @@ static void mtk_clk_unregister_pll(struct clk *clk) kfree(pll); } =20 -void mtk_clk_register_plls(struct device_node *node, - const struct mtk_pll_data *plls, int num_plls, struct clk_onecell_data *= clk_data) +int mtk_clk_register_plls(struct device_node *node, + const struct mtk_pll_data *plls, int num_plls, + struct clk_onecell_data *clk_data) { void __iomem *base; int i; @@ -379,7 +380,7 @@ void mtk_clk_register_plls(struct device_node *node, base =3D of_iomap(node, 0); if (!base) { pr_err("%s(): ioremap failed\n", __func__); - return; + return -EINVAL; } =20 for (i =3D 0; i < num_plls; i++) { @@ -389,11 +390,25 @@ void mtk_clk_register_plls(struct device_node *node, =20 if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", pll->name, clk); - continue; + goto err; } =20 clk_data->clks[pll->id] =3D clk; } + + return 0; + +err: + while (--i >=3D 0) { + const struct mtk_pll_data *pll =3D &plls[i]; + + mtk_clk_unregister_pll(clk_data->clks[pll->id]); + clk_data->clks[pll->id] =3D ERR_PTR(-ENOENT); + }; + + iounmap(base); + + return PTR_ERR(clk); } EXPORT_SYMBOL_GPL(mtk_clk_register_plls); =20 diff --git a/drivers/clk/mediatek/clk-pll.h b/drivers/clk/mediatek/clk-pll.h index a889b1e472e7..bf06e44caef9 100644 --- a/drivers/clk/mediatek/clk-pll.h +++ b/drivers/clk/mediatek/clk-pll.h @@ -48,9 +48,9 @@ struct mtk_pll_data { u8 pll_en_bit; /* Assume 0, indicates BIT(0) by default */ }; =20 -void mtk_clk_register_plls(struct device_node *node, - const struct mtk_pll_data *plls, int num_plls, - struct clk_onecell_data *clk_data); +int mtk_clk_register_plls(struct device_node *node, + const struct mtk_pll_data *plls, int num_plls, + struct clk_onecell_data *clk_data); void mtk_clk_unregister_plls(const struct mtk_pll_data *plls, int num_plls, struct clk_onecell_data *clk_data); =20 --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 85BB8C433F5 for ; Sat, 22 Jan 2022 09:20:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234349AbiAVJUK (ORCPT ); Sat, 22 Jan 2022 04:20:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234220AbiAVJTR (ORCPT ); Sat, 22 Jan 2022 04:19:17 -0500 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6BB8C06177E for ; Sat, 22 Jan 2022 01:18:42 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id c5so10237212pgk.12 for ; Sat, 22 Jan 2022 01:18:42 -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=cbPbA9/DLWUYTIxrdST0gBpfgjb/5RZYFjIh1hKBGaw=; b=fXfvPqZw/4dYCNRcYbxy3FQcxMrUAI7ndyklT4lYjdDuwYyCkAxRarz7aw+CAQh6/w AsexIaSXdv4RskQreEXbs88+kzid2zRVKf9Hn/PSZbjMAQIGnyic/sR/2Un/j3NIZzmI 2F/MqS+afK/Z10bWZ0jJTAf5yQjVpk0Z+rE7k= 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=cbPbA9/DLWUYTIxrdST0gBpfgjb/5RZYFjIh1hKBGaw=; b=dYqXDSiNexViZVQBinXNJkJuS0LoIcctaka1TUNbI1ZpCBZwR+h90rwZt4a4Yhhcm/ ro6G0WWT/FLmldql5a3wKmBU4mCmBc7a5CeWaczesznxEpUhl6doN15DEn8Gz+wFFAOU Arfv8t3b7eEeV5P/L6CcsToax5PgfsWM/KArca6c5Beay5tJ8qe6NW7qOPPj43+KzxQG Pcwd9vv2ML7WoJU/Y3lWfe6QeE0JRCu2gJVQ8nbFBgcYpJjkyJPfHDKkzpRQwm9KF/E5 F2uzBOtvwa8Rti6OSFxL37fXioRbbIhAW9ZRWOjX6aCWMVARYvIuz38jm6FJN6iCrHG1 ilww== X-Gm-Message-State: AOAM531xuqY6Eq0T8t1Nqg7JNtStrbDFkxY5uAZE0ixOmKXYNY/co7Rn k1Pe7l27RS17i+JYcp40Jsw9cA== X-Google-Smtp-Source: ABdhPJypl8e8g8WdxvcCTgGDoGSeur3n9oEkuxyTV4uLfQphxOLzks9aTqV8OjUgoQuQSOhx+TnoJg== X-Received: by 2002:a63:2ac2:: with SMTP id q185mr5565195pgq.370.1642843122383; Sat, 22 Jan 2022 01:18:42 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:41 -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 26/31] clk: mediatek: mtk: Implement error handling in register APIs Date: Sat, 22 Jan 2022 17:17:26 +0800 Message-Id: <20220122091731.283592-27-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" The remaining clk registration functions do not stop or return errors if any clk failed to be registered, nor do they implement error handling paths. This may result in a partially working device if any step fails. Make the register functions return proper error codes, and bail out if errors occur. Proper cleanup, i.e. unregister any clks that were successfully registered, is done in the new error path. This also makes the |struct clk_data *| argument mandatory, as it is used to track the list of clks registered. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mtk.c | 118 ++++++++++++++++++++++++++------- drivers/clk/mediatek/clk-mtk.h | 20 +++--- 2 files changed, 103 insertions(+), 35 deletions(-) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index d2c50186cceb..e1977c8e130a 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -53,16 +53,19 @@ void mtk_free_clk_data(struct clk_onecell_data *clk_dat= a) kfree(clk_data); } =20 -void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, - int num, struct clk_onecell_data *clk_data) +int mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num, + struct clk_onecell_data *clk_data) { int i; struct clk *clk; =20 + if (!clk_data) + return -ENOMEM; + for (i =3D 0; i < num; i++) { const struct mtk_fixed_clk *rc =3D &clks[i]; =20 - if (clk_data && !IS_ERR_OR_NULL(clk_data->clks[rc->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[rc->id])) continue; =20 clk =3D clk_register_fixed_rate(NULL, rc->name, rc->parent, 0, @@ -70,12 +73,26 @@ void mtk_clk_register_fixed_clks(const struct mtk_fixed= _clk *clks, =20 if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", rc->name, clk); - continue; + goto err; } =20 - if (clk_data) - clk_data->clks[rc->id] =3D clk; + clk_data->clks[rc->id] =3D clk; } + + return 0; + +err: + while (--i >=3D 0) { + const struct mtk_fixed_clk *rc =3D &clks[i]; + + if (IS_ERR_OR_NULL(clk_data->clks[rc->id])) + continue; + + clk_unregister_fixed_rate(clk_data->clks[rc->id]); + clk_data->clks[rc->id] =3D ERR_PTR(-ENOENT); + } + + return PTR_ERR(clk); } EXPORT_SYMBOL_GPL(mtk_clk_register_fixed_clks); =20 @@ -99,16 +116,19 @@ void mtk_clk_unregister_fixed_clks(const struct mtk_fi= xed_clk *clks, int num, } EXPORT_SYMBOL_GPL(mtk_clk_unregister_fixed_clks); =20 -void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, - int num, struct clk_onecell_data *clk_data) +int mtk_clk_register_factors(const struct mtk_fixed_factor *clks, int num, + struct clk_onecell_data *clk_data) { int i; struct clk *clk; =20 + if (!clk_data) + return -ENOMEM; + for (i =3D 0; i < num; i++) { const struct mtk_fixed_factor *ff =3D &clks[i]; =20 - if (clk_data && !IS_ERR_OR_NULL(clk_data->clks[ff->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[ff->id])) continue; =20 clk =3D clk_register_fixed_factor(NULL, ff->name, ff->parent_name, @@ -116,12 +136,26 @@ void mtk_clk_register_factors(const struct mtk_fixed_= factor *clks, =20 if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", ff->name, clk); - continue; + goto err; } =20 - if (clk_data) - clk_data->clks[ff->id] =3D clk; + clk_data->clks[ff->id] =3D clk; + } + + return 0; + +err: + while (--i >=3D 0) { + const struct mtk_fixed_factor *ff =3D &clks[i]; + + 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); } + + return PTR_ERR(clk); } EXPORT_SYMBOL_GPL(mtk_clk_register_factors); =20 @@ -253,13 +287,16 @@ static void mtk_clk_unregister_composite(struct clk *= clk) kfree(mux); } =20 -void mtk_clk_register_composites(const struct mtk_composite *mcs, - int num, void __iomem *base, spinlock_t *lock, - struct clk_onecell_data *clk_data) +int mtk_clk_register_composites(const struct mtk_composite *mcs, int num, + void __iomem *base, spinlock_t *lock, + struct clk_onecell_data *clk_data) { struct clk *clk; int i; =20 + if (!clk_data) + return -ENOMEM; + for (i =3D 0; i < num; i++) { const struct mtk_composite *mc =3D &mcs[i]; =20 @@ -270,12 +307,26 @@ void mtk_clk_register_composites(const struct mtk_com= posite *mcs, =20 if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", mc->name, clk); - continue; + goto err; } =20 - if (clk_data) - clk_data->clks[mc->id] =3D clk; + clk_data->clks[mc->id] =3D clk; + } + + return 0; + +err: + while (--i >=3D 0) { + const struct mtk_composite *mc =3D &mcs[i]; + + if (IS_ERR_OR_NULL(clk_data->clks[mcs->id])) + continue; + + mtk_clk_unregister_composite(clk_data->clks[mc->id]); + clk_data->clks[mc->id] =3D ERR_PTR(-ENOENT); } + + return PTR_ERR(clk); } EXPORT_SYMBOL_GPL(mtk_clk_register_composites); =20 @@ -299,17 +350,20 @@ void mtk_clk_unregister_composites(const struct mtk_c= omposite *mcs, int num, } EXPORT_SYMBOL_GPL(mtk_clk_unregister_composites); =20 -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) +int mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num, + void __iomem *base, spinlock_t *lock, + struct clk_onecell_data *clk_data) { struct clk *clk; int i; =20 + if (!clk_data) + return -ENOMEM; + for (i =3D 0; i < num; i++) { const struct mtk_clk_divider *mcd =3D &mcds[i]; =20 - if (clk_data && !IS_ERR_OR_NULL(clk_data->clks[mcd->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[mcd->id])) continue; =20 clk =3D clk_register_divider(NULL, mcd->name, mcd->parent_name, @@ -318,12 +372,26 @@ void mtk_clk_register_dividers(const struct mtk_clk_d= ivider *mcds, =20 if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", mcd->name, clk); - continue; + goto err; } =20 - if (clk_data) - clk_data->clks[mcd->id] =3D clk; + clk_data->clks[mcd->id] =3D clk; + } + + return 0; + +err: + while (--i >=3D 0) { + const struct mtk_clk_divider *mcd =3D &mcds[i]; + + if (IS_ERR_OR_NULL(clk_data->clks[mcd->id])) + continue; + + mtk_clk_unregister_composite(clk_data->clks[mcd->id]); + clk_data->clks[mcd->id] =3D ERR_PTR(-ENOENT); } + + return PTR_ERR(clk); } =20 void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, int n= um, diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index 7f902581a115..bf6565aa7319 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -34,8 +34,8 @@ struct mtk_fixed_clk { .rate =3D _rate, \ } =20 -void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num, - struct clk_onecell_data *clk_data); +int mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num, + struct clk_onecell_data *clk_data); void mtk_clk_unregister_fixed_clks(const struct mtk_fixed_clk *clks, int n= um, struct clk_onecell_data *clk_data); =20 @@ -55,8 +55,8 @@ 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); +int 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 @@ -150,9 +150,9 @@ struct mtk_composite { struct clk *mtk_clk_register_composite(const struct mtk_composite *mc, void __iomem *base, spinlock_t *lock); =20 -void mtk_clk_register_composites(const struct mtk_composite *mcs, - int num, void __iomem *base, spinlock_t *lock, - struct clk_onecell_data *clk_data); +int 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 @@ -178,9 +178,9 @@ struct mtk_clk_divider { .div_width =3D _width, \ } =20 -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); +int mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num, + void __iomem *base, spinlock_t *lock, + struct clk_onecell_data *clk_data); void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, int n= um, struct clk_onecell_data *clk_data); =20 --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 2E979C433EF for ; Sat, 22 Jan 2022 09:20:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230274AbiAVJUW (ORCPT ); Sat, 22 Jan 2022 04:20:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234427AbiAVJTc (ORCPT ); Sat, 22 Jan 2022 04:19:32 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 021B2C0613E7 for ; Sat, 22 Jan 2022 01:18:45 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id c3so10891781pls.5 for ; Sat, 22 Jan 2022 01:18:44 -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=BRdPqU8/wgjW8dVj35l2dqDHIgNyG8RkF40G3LrYL04=; b=Fuyv3VjSgzBkc769Lo/2CI7DZ5+GfuLLZoIVtSUhg6V37yvZZjs0K7eQ4eSZslBFGK usShwZDBaY7bdt+XegEK2ZJyP6x7yd5qMvqXo5OydapiA3sNPpx6xr2Zkzu9wSA5RsDS FcKihT3u/k8jED2Ow+v5mvkMHtTDBpLzLnIA8= 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=BRdPqU8/wgjW8dVj35l2dqDHIgNyG8RkF40G3LrYL04=; b=31IdeGxn71E24/PZUgHY4CTHv2gM0VwQMy/IGzgLCotB6WjerwScArzvkegZbUSvQG nEjqehU3SeLQl7lMmosQOn3TnSiLhyiMI6qDBDFx+6CrN4mwsw55hvwlPi/elt/u/RzI B+x88emfnRvhXMO3I1XnJAGVOSAMfaCTc5iiQTKsBKU1Ui3mQD6t7XhXIGBCUU324amk Nu1IJvmETLbCKyxJODTvWGRGy/CkA5+wKBhNPTcmGKcTOQw1Tpk3Tn/yPmz4htvdiEf5 O5OlfXrDKf3B4QCHCYAQhuKVLa13DhwTz3YxR7cnxdQH4CxlFrQcAhKTs/grCpPV3WH5 nU/Q== X-Gm-Message-State: AOAM533vyFAEFhkFNJCURc7nPo6qLjmd572vv8QnukRv5B8ElVfdSG/i 65m1D9rYBjybSNpm701n+KbOjQ== X-Google-Smtp-Source: ABdhPJxTbBDUz1ZVF3T1/WMxItjtS2Jk9+TiJqGSG9ZvAellDQvwJc4yjnRGhEOmpZtTsU1/xc9bqw== X-Received: by 2002:a17:903:110c:b0:149:9004:4e7c with SMTP id n12-20020a170903110c00b0014990044e7cmr6904060plh.167.1642843124559; Sat, 22 Jan 2022 01:18:44 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:44 -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 27/31] clk: mediatek: Unregister clks in mtk_clk_simple_probe() error path Date: Sat, 22 Jan 2022 17:17:27 +0800 Message-Id: <20220122091731.283592-28-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" Until now the mediatek clk driver library did not have any way to unregister clks, and so all drivers did not do proper cleanup in their error paths. Now that the library does have APIs to unregister clks, use them in the error path of mtk_clk_simple_probe() to do proper cleanup. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mtk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index e1977c8e130a..6d0b8842971b 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -434,12 +434,14 @@ int mtk_clk_simple_probe(struct platform_device *pdev) =20 r =3D of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); if (r) - goto free_data; + goto unregister_clks; =20 platform_set_drvdata(pdev, clk_data); =20 return r; =20 +unregister_clks: + mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data); free_data: mtk_free_clk_data(clk_data); return r; --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 7C015C433EF for ; Sat, 22 Jan 2022 09:20:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230392AbiAVJU3 (ORCPT ); Sat, 22 Jan 2022 04:20:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233114AbiAVJTy (ORCPT ); Sat, 22 Jan 2022 04:19:54 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AC97C0613EF for ; Sat, 22 Jan 2022 01:18:47 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id d5so8916765pjk.5 for ; Sat, 22 Jan 2022 01:18:47 -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=Mf1Ke59g0whTcDmTE2X4XTGQ5PLXVqIsYn1wvgyc6go=; b=NZC5E3vuCUE4gTyZrXKANY75px2GeM9sHB0ThxEMsyWf7bFNFj82onVSvkTPDjymQj 86d7d6HVOIsBwpS2RuYr7chQtybx8swkLfzgf8DLqwzRRBqVcmLUVkVfG9tG/12cne3A ekjZIh/ERAsxNl5nTeQhJgaAoX2BOt2dysIv0= 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=Mf1Ke59g0whTcDmTE2X4XTGQ5PLXVqIsYn1wvgyc6go=; b=DQnPpbWIXZcpdeol8isk4SItee9C3H/KAcbARF31lVuK/bbEu1zaAuVmXg4/3Fa+Va fJKjGSg+ROvKAXEujZ1geZcc6FudzrKqdVIw5IGxqiFE2Ls5P9ERFdxRkBU9oNtApioH jmdDCDCzAsIxuMDRfrEEGR/7R+LSO9NvPguOkvto0trO+UCGn2nF47xebhut2hL2FPoM CES612QUczBxiRaH10xBwJVGaA/pRwHYRaVO5+ON67BW6hnNtz2qwnNUSGcNBsTXLGIH 4D0EKxCneMJww7xAklH0lxUV98bH2szwc9VclGUNbG1ny+71l5JhNTkCf5OCOcJXm1a+ oBnA== X-Gm-Message-State: AOAM5338i3YOimuzSA3Tn1ZINSiXjmuNnpmxfoTtPcZJ665QViQk1iM0 n8LW0mUbm+KxzZkN2G6J/HgaboDUHCqziQ== X-Google-Smtp-Source: ABdhPJzED5tMtAsnPQbU9tA6BO4HhRQHaqZgZr4UpkvtZ+6QDKLmSbQeQU9mpJ0NnG8E+2a28C41cg== X-Received: by 2002:a17:90b:3503:: with SMTP id ls3mr2950048pjb.127.1642843126766; Sat, 22 Jan 2022 01:18:46 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:46 -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 28/31] clk: mediatek: mt8195: Hook up mtk_clk_simple_remove() Date: Sat, 22 Jan 2022 17:17:28 +0800 Message-Id: <20220122091731.283592-29-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" Various small clock controllers only have clock gates, and utilize mtk_clk_simple_probe() as their driver probe function. Now that we have a matching remove function, hook it up for the relevant drivers. This was done with the following command: sed -i -e '/mtk_clk_simple_probe/a \ .remove =3D mtk_clk_simple_remove,' drivers/clk/mediatek/clk-mt8195= -*.c Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mt8195-cam.c | 1 + drivers/clk/mediatek/clk-mt8195-ccu.c | 1 + drivers/clk/mediatek/clk-mt8195-img.c | 1 + drivers/clk/mediatek/clk-mt8195-imp_iic_wrap.c | 1 + drivers/clk/mediatek/clk-mt8195-infra_ao.c | 1 + drivers/clk/mediatek/clk-mt8195-ipe.c | 1 + drivers/clk/mediatek/clk-mt8195-mfg.c | 1 + drivers/clk/mediatek/clk-mt8195-peri_ao.c | 1 + drivers/clk/mediatek/clk-mt8195-scp_adsp.c | 1 + drivers/clk/mediatek/clk-mt8195-vdec.c | 1 + drivers/clk/mediatek/clk-mt8195-venc.c | 1 + drivers/clk/mediatek/clk-mt8195-vpp0.c | 1 + drivers/clk/mediatek/clk-mt8195-vpp1.c | 1 + drivers/clk/mediatek/clk-mt8195-wpe.c | 1 + 14 files changed, 14 insertions(+) diff --git a/drivers/clk/mediatek/clk-mt8195-cam.c b/drivers/clk/mediatek/c= lk-mt8195-cam.c index 3d261fc3848e..e4d00fe6e757 100644 --- a/drivers/clk/mediatek/clk-mt8195-cam.c +++ b/drivers/clk/mediatek/clk-mt8195-cam.c @@ -134,6 +134,7 @@ static const struct of_device_id of_match_clk_mt8195_ca= m[] =3D { =20 static struct platform_driver clk_mt8195_cam_drv =3D { .probe =3D mtk_clk_simple_probe, + .remove =3D mtk_clk_simple_remove, .driver =3D { .name =3D "clk-mt8195-cam", .of_match_table =3D of_match_clk_mt8195_cam, diff --git a/drivers/clk/mediatek/clk-mt8195-ccu.c b/drivers/clk/mediatek/c= lk-mt8195-ccu.c index f846f1d73605..4e326b6301ba 100644 --- a/drivers/clk/mediatek/clk-mt8195-ccu.c +++ b/drivers/clk/mediatek/clk-mt8195-ccu.c @@ -42,6 +42,7 @@ static const struct of_device_id of_match_clk_mt8195_ccu[= ] =3D { =20 static struct platform_driver clk_mt8195_ccu_drv =3D { .probe =3D mtk_clk_simple_probe, + .remove =3D mtk_clk_simple_remove, .driver =3D { .name =3D "clk-mt8195-ccu", .of_match_table =3D of_match_clk_mt8195_ccu, diff --git a/drivers/clk/mediatek/clk-mt8195-img.c b/drivers/clk/mediatek/c= lk-mt8195-img.c index 22b52a8f15fe..12f5c436d075 100644 --- a/drivers/clk/mediatek/clk-mt8195-img.c +++ b/drivers/clk/mediatek/clk-mt8195-img.c @@ -88,6 +88,7 @@ static const struct of_device_id of_match_clk_mt8195_img[= ] =3D { =20 static struct platform_driver clk_mt8195_img_drv =3D { .probe =3D mtk_clk_simple_probe, + .remove =3D mtk_clk_simple_remove, .driver =3D { .name =3D "clk-mt8195-img", .of_match_table =3D of_match_clk_mt8195_img, diff --git a/drivers/clk/mediatek/clk-mt8195-imp_iic_wrap.c b/drivers/clk/m= ediatek/clk-mt8195-imp_iic_wrap.c index 4ab312eb26a5..fbc809d05072 100644 --- a/drivers/clk/mediatek/clk-mt8195-imp_iic_wrap.c +++ b/drivers/clk/mediatek/clk-mt8195-imp_iic_wrap.c @@ -58,6 +58,7 @@ static const struct of_device_id of_match_clk_mt8195_imp_= iic_wrap[] =3D { =20 static struct platform_driver clk_mt8195_imp_iic_wrap_drv =3D { .probe =3D mtk_clk_simple_probe, + .remove =3D mtk_clk_simple_remove, .driver =3D { .name =3D "clk-mt8195-imp_iic_wrap", .of_match_table =3D of_match_clk_mt8195_imp_iic_wrap, diff --git a/drivers/clk/mediatek/clk-mt8195-infra_ao.c b/drivers/clk/media= tek/clk-mt8195-infra_ao.c index 5f9b69967459..8ebe3b9415c4 100644 --- a/drivers/clk/mediatek/clk-mt8195-infra_ao.c +++ b/drivers/clk/mediatek/clk-mt8195-infra_ao.c @@ -198,6 +198,7 @@ static const struct of_device_id of_match_clk_mt8195_in= fra_ao[] =3D { =20 static struct platform_driver clk_mt8195_infra_ao_drv =3D { .probe =3D mtk_clk_simple_probe, + .remove =3D mtk_clk_simple_remove, .driver =3D { .name =3D "clk-mt8195-infra_ao", .of_match_table =3D of_match_clk_mt8195_infra_ao, diff --git a/drivers/clk/mediatek/clk-mt8195-ipe.c b/drivers/clk/mediatek/c= lk-mt8195-ipe.c index fc1d42b6ac84..b0d745cf7752 100644 --- a/drivers/clk/mediatek/clk-mt8195-ipe.c +++ b/drivers/clk/mediatek/clk-mt8195-ipe.c @@ -43,6 +43,7 @@ static const struct of_device_id of_match_clk_mt8195_ipe[= ] =3D { =20 static struct platform_driver clk_mt8195_ipe_drv =3D { .probe =3D mtk_clk_simple_probe, + .remove =3D mtk_clk_simple_remove, .driver =3D { .name =3D "clk-mt8195-ipe", .of_match_table =3D of_match_clk_mt8195_ipe, diff --git a/drivers/clk/mediatek/clk-mt8195-mfg.c b/drivers/clk/mediatek/c= lk-mt8195-mfg.c index aca6d9c0837c..9411c556a5a9 100644 --- a/drivers/clk/mediatek/clk-mt8195-mfg.c +++ b/drivers/clk/mediatek/clk-mt8195-mfg.c @@ -39,6 +39,7 @@ static const struct of_device_id of_match_clk_mt8195_mfg[= ] =3D { =20 static struct platform_driver clk_mt8195_mfg_drv =3D { .probe =3D mtk_clk_simple_probe, + .remove =3D mtk_clk_simple_remove, .driver =3D { .name =3D "clk-mt8195-mfg", .of_match_table =3D of_match_clk_mt8195_mfg, diff --git a/drivers/clk/mediatek/clk-mt8195-peri_ao.c b/drivers/clk/mediat= ek/clk-mt8195-peri_ao.c index 907a92b22de8..2f6b3bb657db 100644 --- a/drivers/clk/mediatek/clk-mt8195-peri_ao.c +++ b/drivers/clk/mediatek/clk-mt8195-peri_ao.c @@ -54,6 +54,7 @@ static const struct of_device_id of_match_clk_mt8195_peri= _ao[] =3D { =20 static struct platform_driver clk_mt8195_peri_ao_drv =3D { .probe =3D mtk_clk_simple_probe, + .remove =3D mtk_clk_simple_remove, .driver =3D { .name =3D "clk-mt8195-peri_ao", .of_match_table =3D of_match_clk_mt8195_peri_ao, diff --git a/drivers/clk/mediatek/clk-mt8195-scp_adsp.c b/drivers/clk/media= tek/clk-mt8195-scp_adsp.c index 26b4846c5894..e16c383f631b 100644 --- a/drivers/clk/mediatek/clk-mt8195-scp_adsp.c +++ b/drivers/clk/mediatek/clk-mt8195-scp_adsp.c @@ -39,6 +39,7 @@ static const struct of_device_id of_match_clk_mt8195_scp_= adsp[] =3D { =20 static struct platform_driver clk_mt8195_scp_adsp_drv =3D { .probe =3D mtk_clk_simple_probe, + .remove =3D mtk_clk_simple_remove, .driver =3D { .name =3D "clk-mt8195-scp_adsp", .of_match_table =3D of_match_clk_mt8195_scp_adsp, diff --git a/drivers/clk/mediatek/clk-mt8195-vdec.c b/drivers/clk/mediatek/= clk-mt8195-vdec.c index a1df04f42a90..a1446b666385 100644 --- a/drivers/clk/mediatek/clk-mt8195-vdec.c +++ b/drivers/clk/mediatek/clk-mt8195-vdec.c @@ -96,6 +96,7 @@ static const struct of_device_id of_match_clk_mt8195_vdec= [] =3D { =20 static struct platform_driver clk_mt8195_vdec_drv =3D { .probe =3D mtk_clk_simple_probe, + .remove =3D mtk_clk_simple_remove, .driver =3D { .name =3D "clk-mt8195-vdec", .of_match_table =3D of_match_clk_mt8195_vdec, diff --git a/drivers/clk/mediatek/clk-mt8195-venc.c b/drivers/clk/mediatek/= clk-mt8195-venc.c index 7339851a0856..622f57804f96 100644 --- a/drivers/clk/mediatek/clk-mt8195-venc.c +++ b/drivers/clk/mediatek/clk-mt8195-venc.c @@ -61,6 +61,7 @@ static const struct of_device_id of_match_clk_mt8195_venc= [] =3D { =20 static struct platform_driver clk_mt8195_venc_drv =3D { .probe =3D mtk_clk_simple_probe, + .remove =3D mtk_clk_simple_remove, .driver =3D { .name =3D "clk-mt8195-venc", .of_match_table =3D of_match_clk_mt8195_venc, diff --git a/drivers/clk/mediatek/clk-mt8195-vpp0.c b/drivers/clk/mediatek/= clk-mt8195-vpp0.c index c3241466a8d0..bf2939c3a023 100644 --- a/drivers/clk/mediatek/clk-mt8195-vpp0.c +++ b/drivers/clk/mediatek/clk-mt8195-vpp0.c @@ -102,6 +102,7 @@ static const struct of_device_id of_match_clk_mt8195_vp= p0[] =3D { =20 static struct platform_driver clk_mt8195_vpp0_drv =3D { .probe =3D mtk_clk_simple_probe, + .remove =3D mtk_clk_simple_remove, .driver =3D { .name =3D "clk-mt8195-vpp0", .of_match_table =3D of_match_clk_mt8195_vpp0, diff --git a/drivers/clk/mediatek/clk-mt8195-vpp1.c b/drivers/clk/mediatek/= clk-mt8195-vpp1.c index ce0b9a40a179..ffd52c762890 100644 --- a/drivers/clk/mediatek/clk-mt8195-vpp1.c +++ b/drivers/clk/mediatek/clk-mt8195-vpp1.c @@ -100,6 +100,7 @@ static const struct of_device_id of_match_clk_mt8195_vp= p1[] =3D { =20 static struct platform_driver clk_mt8195_vpp1_drv =3D { .probe =3D mtk_clk_simple_probe, + .remove =3D mtk_clk_simple_remove, .driver =3D { .name =3D "clk-mt8195-vpp1", .of_match_table =3D of_match_clk_mt8195_vpp1, diff --git a/drivers/clk/mediatek/clk-mt8195-wpe.c b/drivers/clk/mediatek/c= lk-mt8195-wpe.c index 274d60838d8e..b483fab10e18 100644 --- a/drivers/clk/mediatek/clk-mt8195-wpe.c +++ b/drivers/clk/mediatek/clk-mt8195-wpe.c @@ -135,6 +135,7 @@ static const struct of_device_id of_match_clk_mt8195_wp= e[] =3D { =20 static struct platform_driver clk_mt8195_wpe_drv =3D { .probe =3D mtk_clk_simple_probe, + .remove =3D mtk_clk_simple_remove, .driver =3D { .name =3D "clk-mt8195-wpe", .of_match_table =3D of_match_clk_mt8195_wpe, --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 15261C433F5 for ; Sat, 22 Jan 2022 09:20:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234113AbiAVJUb (ORCPT ); Sat, 22 Jan 2022 04:20:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234092AbiAVJTz (ORCPT ); Sat, 22 Jan 2022 04:19:55 -0500 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84BFBC061786 for ; Sat, 22 Jan 2022 01:18:49 -0800 (PST) Received: by mail-pg1-x531.google.com with SMTP id r11so10246673pgr.6 for ; Sat, 22 Jan 2022 01:18:49 -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=D3QnS7kjFfrgTHObfO2/gQR9r9A1MdW1YuvW6hFlmPU=; b=OOrn0NajFfioYejG6ULlzdHFsPjRjDyfYd7zw1ryJirM1w1ZAYr6L3IXRn2L7JGr1o HJkQpBknQsf89GYlk/gKbk5gsEWH1Vl39Fdu357zOoVxEd1JpHpLA+ycoLftgQionAH1 8lbvNqtl1RRHj7Z2Xi5f5y6VyFtdf4Ljuy2lY= 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=D3QnS7kjFfrgTHObfO2/gQR9r9A1MdW1YuvW6hFlmPU=; b=e3vjL7FeQ8/CNUsxfg89oSbZ9klhUwADfonCii+f//xbhgA6bKFSsHZDhXr9eOtIgc G5fYlfA/Gf3QAqm++pzOBQO/9SkAkxGEYEEOdqn3k4ZMFOi7itdx69Nd3W2capXFNKdp P28g/n8wUhsXVyezEj7hb9WO9uqhVTipciGBMOagZs65WptTMX0aIoD3DCtSX482o70O IKgB0ZbzKw3mnd+FGb8/0ooeGpb/9s/fPPDOSQQ64LviQHlELudBBEx2rqZw/yvVo4z9 qefXyF5cUKVmGW6mQ6OegRXDe6oM3fzCnHWthAGBv7DrO0lF5FLSUeNeFrp7y7k+HQx9 9Ecg== X-Gm-Message-State: AOAM531zwUJhg8Xh6Y2nM59Ey7Qpz++mAxWMzKM/KKRymnsrZHPxBwl9 CRejDuSST4mEn/neA2X5QdYbgg== X-Google-Smtp-Source: ABdhPJwoZ1uArHfG20JF9aXHV9qAKZo4Nd+NXBHQd93o1IQDmUskgrAp0D7C6MWPy/xOWqDtGvVWWA== X-Received: by 2002:a63:d314:: with SMTP id b20mr5589874pgg.207.1642843129021; Sat, 22 Jan 2022 01:18:49 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:48 -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 29/31] clk: mediatek: mt8195: Implement error handling in probe functions Date: Sat, 22 Jan 2022 17:17:29 +0800 Message-Id: <20220122091731.283592-30-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" Until now the mediatek clk driver library did not have any way to unregister clks, and so all drivers did not do proper cleanup in their error paths. Now that the library does have APIs to unregister clks, use them in the error path of the probe functions for the mt8195 clk drivers to do proper cleanup. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mt8195-apmixedsys.c | 13 ++++-- drivers/clk/mediatek/clk-mt8195-apusys_pll.c | 11 ++++- drivers/clk/mediatek/clk-mt8195-topckgen.c | 49 +++++++++++++++----- drivers/clk/mediatek/clk-mt8195-vdo0.c | 4 +- drivers/clk/mediatek/clk-mt8195-vdo1.c | 4 +- 5 files changed, 63 insertions(+), 18 deletions(-) diff --git a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c b/drivers/clk/med= iatek/clk-mt8195-apmixedsys.c index 5b1b7dc447eb..af8d80f25f30 100644 --- a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c +++ b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c @@ -120,17 +120,24 @@ static int clk_mt8195_apmixed_probe(struct platform_d= evice *pdev) if (!clk_data) return -ENOMEM; =20 - mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); - r =3D mtk_clk_register_gates(node, apmixed_clks, ARRAY_SIZE(apmixed_clks)= , clk_data); + r =3D mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); if (r) goto free_apmixed_data; =20 + r =3D mtk_clk_register_gates(node, apmixed_clks, ARRAY_SIZE(apmixed_clks)= , clk_data); + if (r) + goto unregister_plls; + r =3D of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); if (r) - goto free_apmixed_data; + goto unregister_gates; =20 return r; =20 +unregister_gates: + mtk_clk_register_gates(node, apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_= data); +unregister_plls: + mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); free_apmixed_data: mtk_free_clk_data(clk_data); return r; diff --git a/drivers/clk/mediatek/clk-mt8195-apusys_pll.c b/drivers/clk/med= iatek/clk-mt8195-apusys_pll.c index db449ff877d7..1fff6f3d2dc7 100644 --- a/drivers/clk/mediatek/clk-mt8195-apusys_pll.c +++ b/drivers/clk/mediatek/clk-mt8195-apusys_pll.c @@ -66,13 +66,20 @@ static int clk_mt8195_apusys_pll_probe(struct platform_= device *pdev) if (!clk_data) return -ENOMEM; =20 - mtk_clk_register_plls(node, apusys_plls, ARRAY_SIZE(apusys_plls), clk_dat= a); - r =3D of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); + r =3D mtk_clk_register_plls(node, apusys_plls, ARRAY_SIZE(apusys_plls), c= lk_data); if (r) goto free_apusys_pll_data; =20 + r =3D of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); + if (r) + goto unregister_plls; + + platform_set_drvdata(pdev, clk_data); + return r; =20 +unregister_plls: + mtk_clk_unregister_plls(apusys_plls, ARRAY_SIZE(apusys_plls), clk_data); free_apusys_pll_data: mtk_free_clk_data(clk_data); return r; diff --git a/drivers/clk/mediatek/clk-mt8195-topckgen.c b/drivers/clk/media= tek/clk-mt8195-topckgen.c index 3e2aba9c40bb..3631f49a5e5a 100644 --- a/drivers/clk/mediatek/clk-mt8195-topckgen.c +++ b/drivers/clk/mediatek/clk-mt8195-topckgen.c @@ -1239,25 +1239,52 @@ static int clk_mt8195_topck_probe(struct platform_d= evice *pdev) goto free_top_data; } =20 - mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), - top_clk_data); - mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data); - mtk_clk_register_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), node, - &mt8195_clk_lock, top_clk_data); - mtk_clk_register_composites(top_muxes, ARRAY_SIZE(top_muxes), base, - &mt8195_clk_lock, top_clk_data); - mtk_clk_register_composites(top_adj_divs, ARRAY_SIZE(top_adj_divs), base, - &mt8195_clk_lock, top_clk_data); - r =3D mtk_clk_register_gates(node, top_clks, ARRAY_SIZE(top_clks), top_cl= k_data); + r =3D mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_cl= ks), + top_clk_data); if (r) goto free_top_data; =20 + r =3D mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_da= ta); + if (r) + goto unregister_fixed_clks; + + r =3D mtk_clk_register_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), no= de, + &mt8195_clk_lock, top_clk_data); + if (r) + goto unregister_factors; + + r =3D mtk_clk_register_composites(top_muxes, ARRAY_SIZE(top_muxes), base, + &mt8195_clk_lock, top_clk_data); + if (r) + goto unregister_muxes; + + r =3D mtk_clk_register_composites(top_adj_divs, ARRAY_SIZE(top_adj_divs),= base, + &mt8195_clk_lock, top_clk_data); + if (r) + goto unregister_composite_muxes; + + r =3D mtk_clk_register_gates(node, top_clks, ARRAY_SIZE(top_clks), top_cl= k_data); + if (r) + goto unregister_composite_divs; + r =3D of_clk_add_provider(node, of_clk_src_onecell_get, top_clk_data); if (r) - goto free_top_data; + goto unregister_gates; =20 return r; =20 +unregister_gates: + mtk_clk_unregister_gates(top_clks, ARRAY_SIZE(top_clks), top_clk_data); +unregister_composite_divs: + mtk_clk_unregister_composites(top_adj_divs, ARRAY_SIZE(top_adj_divs), top= _clk_data); +unregister_composite_muxes: + mtk_clk_unregister_composites(top_muxes, ARRAY_SIZE(top_muxes), top_clk_d= ata); +unregister_muxes: + mtk_clk_unregister_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), top_cl= k_data); +unregister_factors: + mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data); +unregister_fixed_clks: + mtk_clk_unregister_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),= top_clk_data); free_top_data: mtk_free_clk_data(top_clk_data); return r; diff --git a/drivers/clk/mediatek/clk-mt8195-vdo0.c b/drivers/clk/mediatek/= clk-mt8195-vdo0.c index f7ff7618c714..af34eb564b1d 100644 --- a/drivers/clk/mediatek/clk-mt8195-vdo0.c +++ b/drivers/clk/mediatek/clk-mt8195-vdo0.c @@ -105,10 +105,12 @@ static int clk_mt8195_vdo0_probe(struct platform_devi= ce *pdev) =20 r =3D of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); if (r) - goto free_vdo0_data; + goto unregister_gates; =20 return r; =20 +unregister_gates: + mtk_clk_unregister_gates(vdo0_clks, ARRAY_SIZE(vdo0_clks), clk_data); free_vdo0_data: mtk_free_clk_data(clk_data); return r; diff --git a/drivers/clk/mediatek/clk-mt8195-vdo1.c b/drivers/clk/mediatek/= clk-mt8195-vdo1.c index 03df8eae8838..6b502bbc730c 100644 --- a/drivers/clk/mediatek/clk-mt8195-vdo1.c +++ b/drivers/clk/mediatek/clk-mt8195-vdo1.c @@ -122,10 +122,12 @@ static int clk_mt8195_vdo1_probe(struct platform_devi= ce *pdev) =20 r =3D of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); if (r) - goto free_vdo1_data; + goto unregister_gates; =20 return r; =20 +unregister_gates: + mtk_clk_unregister_gates(vdo1_clks, ARRAY_SIZE(vdo1_clks), clk_data); free_vdo1_data: mtk_free_clk_data(clk_data); return r; --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 5C4ECC433EF for ; Sat, 22 Jan 2022 09:20:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234423AbiAVJUe (ORCPT ); Sat, 22 Jan 2022 04:20:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231331AbiAVJT4 (ORCPT ); Sat, 22 Jan 2022 04:19:56 -0500 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3DA5C06178A for ; Sat, 22 Jan 2022 01:18:51 -0800 (PST) Received: by mail-pg1-x531.google.com with SMTP id q75so10262864pgq.5 for ; Sat, 22 Jan 2022 01:18:51 -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=2tVyD3kCR8VI41xLDJPrU9Qy3ho9fuGcyr93woETCtQ=; b=eOG+9BqGEp9yE6If/djlk8qPoDc9YyJud438PAYl0npRctcACveC92QRCKlaJfRRwK FhJoFkugw+IrHJljeBXz1R046xaB4XIpF0OrsCUYkk2Ma/RPDluCpN4Yw/8R6z6O39wq ls1PrMpFi6S6SnEVEQDTNxg2gdKqWj4Ior96s= 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=2tVyD3kCR8VI41xLDJPrU9Qy3ho9fuGcyr93woETCtQ=; b=wi7l4UK+tt7lZnMObYFGusM83DsJ+jb/uinEgUcT3m7T0dteZgVO8SeLsrNVIvqzLI BviOHYC1/CsAiMr46dBMSLKPpySpUMeQjyRSQ40fZSK6J46RUlQOdk2hvrw6zNwYhjS+ PuQGPDP6SXlc9LXb1YRMfAsLIYlZfJSy2lTz3E8YaYZ6VHCFL0ZmpkOlYvxgjDHdVchu YXyg5T78Dli9EK34xidxVTKuLpJl6LZwIG9JX9FLXSK9y4KpiBIiv8g75pOKFpFaSWnT x1h0mYuomsV5fE94oZuttRrYnrLFBaFUXTe8u8vSR1qNCCjCzUq+Ijl2bujQEXP9+SPm 8n7w== X-Gm-Message-State: AOAM531Tz77Goy8osd2v79mWOMrTVJGx8Y8eFp6FYU0zr89VoGGHNKME q/CLrsNbxIuoQM3YL9uDwsUNyQ== X-Google-Smtp-Source: ABdhPJw3ygJrl6yteSRDfjOvQdB2WYEUn+GrOoTwni+HNy/7bK2tJUwjJ+Tq1xzBp18rW197UKqTfQ== X-Received: by 2002:a05:6a00:2186:b0:4c6:50ea:6701 with SMTP id h6-20020a056a00218600b004c650ea6701mr6649364pfi.12.1642843131254; Sat, 22 Jan 2022 01:18:51 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:50 -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 30/31] clk: mediatek: mt8195: Implement remove functions Date: Sat, 22 Jan 2022 17:17:30 +0800 Message-Id: <20220122091731.283592-31-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" Until now the mediatek clk driver library did not have any way to unregister clks, and so none of the drivers implemented remove functions. Now that the library does have APIs to unregister clks, use them to implement remove functions for the mt8195 clk drivers. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-mt8195-apmixedsys.c | 16 ++++++++++++++++ drivers/clk/mediatek/clk-mt8195-apusys_pll.c | 13 +++++++++++++ drivers/clk/mediatek/clk-mt8195-topckgen.c | 20 ++++++++++++++++++++ drivers/clk/mediatek/clk-mt8195-vdo0.c | 16 ++++++++++++++++ drivers/clk/mediatek/clk-mt8195-vdo1.c | 16 ++++++++++++++++ 5 files changed, 81 insertions(+) diff --git a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c b/drivers/clk/med= iatek/clk-mt8195-apmixedsys.c index af8d80f25f30..29cac3cf5f53 100644 --- a/drivers/clk/mediatek/clk-mt8195-apmixedsys.c +++ b/drivers/clk/mediatek/clk-mt8195-apmixedsys.c @@ -132,6 +132,8 @@ static int clk_mt8195_apmixed_probe(struct platform_dev= ice *pdev) if (r) goto unregister_gates; =20 + platform_set_drvdata(pdev, clk_data); + return r; =20 unregister_gates: @@ -143,8 +145,22 @@ static int clk_mt8195_apmixed_probe(struct platform_de= vice *pdev) return r; } =20 +static int clk_mt8195_apmixed_remove(struct platform_device *pdev) +{ + struct device_node *node =3D pdev->dev.of_node; + struct clk_onecell_data *clk_data =3D platform_get_drvdata(pdev); + + of_clk_del_provider(node); + mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data= ); + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); + mtk_free_clk_data(clk_data); + + return 0; +} + static struct platform_driver clk_mt8195_apmixed_drv =3D { .probe =3D clk_mt8195_apmixed_probe, + .remove =3D clk_mt8195_apmixed_remove, .driver =3D { .name =3D "clk-mt8195-apmixed", .of_match_table =3D of_match_clk_mt8195_apmixed, diff --git a/drivers/clk/mediatek/clk-mt8195-apusys_pll.c b/drivers/clk/med= iatek/clk-mt8195-apusys_pll.c index 1fff6f3d2dc7..8cd88dfc3283 100644 --- a/drivers/clk/mediatek/clk-mt8195-apusys_pll.c +++ b/drivers/clk/mediatek/clk-mt8195-apusys_pll.c @@ -85,6 +85,18 @@ static int clk_mt8195_apusys_pll_probe(struct platform_d= evice *pdev) return r; } =20 +static int clk_mt8195_apusys_pll_remove(struct platform_device *pdev) +{ + struct clk_onecell_data *clk_data =3D platform_get_drvdata(pdev); + struct device_node *node =3D pdev->dev.of_node; + + of_clk_del_provider(node); + mtk_clk_unregister_plls(apusys_plls, ARRAY_SIZE(apusys_plls), clk_data); + mtk_free_clk_data(clk_data); + + return 0; +} + static const struct of_device_id of_match_clk_mt8195_apusys_pll[] =3D { { .compatible =3D "mediatek,mt8195-apusys_pll", }, {} @@ -92,6 +104,7 @@ static const struct of_device_id of_match_clk_mt8195_apu= sys_pll[] =3D { =20 static struct platform_driver clk_mt8195_apusys_pll_drv =3D { .probe =3D clk_mt8195_apusys_pll_probe, + .remove =3D clk_mt8195_apusys_pll_remove, .driver =3D { .name =3D "clk-mt8195-apusys_pll", .of_match_table =3D of_match_clk_mt8195_apusys_pll, diff --git a/drivers/clk/mediatek/clk-mt8195-topckgen.c b/drivers/clk/media= tek/clk-mt8195-topckgen.c index 3631f49a5e5a..b602fcd7f1d1 100644 --- a/drivers/clk/mediatek/clk-mt8195-topckgen.c +++ b/drivers/clk/mediatek/clk-mt8195-topckgen.c @@ -1271,6 +1271,8 @@ static int clk_mt8195_topck_probe(struct platform_dev= ice *pdev) if (r) goto unregister_gates; =20 + platform_set_drvdata(pdev, top_clk_data); + return r; =20 unregister_gates: @@ -1290,8 +1292,26 @@ static int clk_mt8195_topck_probe(struct platform_de= vice *pdev) return r; } =20 +static int clk_mt8195_topck_remove(struct platform_device *pdev) +{ + struct clk_onecell_data *top_clk_data =3D platform_get_drvdata(pdev); + struct device_node *node =3D pdev->dev.of_node; + + of_clk_del_provider(node); + mtk_clk_unregister_gates(top_clks, ARRAY_SIZE(top_clks), top_clk_data); + mtk_clk_unregister_composites(top_adj_divs, ARRAY_SIZE(top_adj_divs), top= _clk_data); + mtk_clk_unregister_composites(top_muxes, ARRAY_SIZE(top_muxes), top_clk_d= ata); + mtk_clk_unregister_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), top_cl= k_data); + mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data); + mtk_clk_unregister_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),= top_clk_data); + mtk_free_clk_data(top_clk_data); + + return 0; +} + static struct platform_driver clk_mt8195_topck_drv =3D { .probe =3D clk_mt8195_topck_probe, + .remove =3D clk_mt8195_topck_remove, .driver =3D { .name =3D "clk-mt8195-topck", .of_match_table =3D of_match_clk_mt8195_topck, diff --git a/drivers/clk/mediatek/clk-mt8195-vdo0.c b/drivers/clk/mediatek/= clk-mt8195-vdo0.c index af34eb564b1d..3bc7ed19d550 100644 --- a/drivers/clk/mediatek/clk-mt8195-vdo0.c +++ b/drivers/clk/mediatek/clk-mt8195-vdo0.c @@ -107,6 +107,8 @@ static int clk_mt8195_vdo0_probe(struct platform_device= *pdev) if (r) goto unregister_gates; =20 + platform_set_drvdata(pdev, clk_data); + return r; =20 unregister_gates: @@ -116,8 +118,22 @@ static int clk_mt8195_vdo0_probe(struct platform_devic= e *pdev) return r; } =20 +static int clk_mt8195_vdo0_remove(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct device_node *node =3D dev->parent->of_node; + struct clk_onecell_data *clk_data =3D platform_get_drvdata(pdev); + + of_clk_del_provider(node); + mtk_clk_unregister_gates(vdo0_clks, ARRAY_SIZE(vdo0_clks), clk_data); + mtk_free_clk_data(clk_data); + + return 0; +} + static struct platform_driver clk_mt8195_vdo0_drv =3D { .probe =3D clk_mt8195_vdo0_probe, + .remove =3D clk_mt8195_vdo0_remove, .driver =3D { .name =3D "clk-mt8195-vdo0", }, diff --git a/drivers/clk/mediatek/clk-mt8195-vdo1.c b/drivers/clk/mediatek/= clk-mt8195-vdo1.c index 6b502bbc730c..90c738a85ff1 100644 --- a/drivers/clk/mediatek/clk-mt8195-vdo1.c +++ b/drivers/clk/mediatek/clk-mt8195-vdo1.c @@ -124,6 +124,8 @@ static int clk_mt8195_vdo1_probe(struct platform_device= *pdev) if (r) goto unregister_gates; =20 + platform_set_drvdata(pdev, clk_data); + return r; =20 unregister_gates: @@ -133,8 +135,22 @@ static int clk_mt8195_vdo1_probe(struct platform_devic= e *pdev) return r; } =20 +static int clk_mt8195_vdo1_remove(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct device_node *node =3D dev->parent->of_node; + struct clk_onecell_data *clk_data =3D platform_get_drvdata(pdev); + + of_clk_del_provider(node); + mtk_clk_unregister_gates(vdo1_clks, ARRAY_SIZE(vdo1_clks), clk_data); + mtk_free_clk_data(clk_data); + + return 0; +} + static struct platform_driver clk_mt8195_vdo1_drv =3D { .probe =3D clk_mt8195_vdo1_probe, + .remove =3D clk_mt8195_vdo1_remove, .driver =3D { .name =3D "clk-mt8195-vdo1", }, --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Wed Nov 13 15:09:41 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 88DE8C433EF for ; Sat, 22 Jan 2022 09:20:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234451AbiAVJUh (ORCPT ); Sat, 22 Jan 2022 04:20:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234093AbiAVJT4 (ORCPT ); Sat, 22 Jan 2022 04:19:56 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9DC2C061793 for ; Sat, 22 Jan 2022 01:18:53 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id l17so4686151plg.1 for ; Sat, 22 Jan 2022 01:18:53 -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=x4l7SdSy/ZXICUFfVEpfugcTxefmMymFj4v54f2ETqQ=; b=ZtWNhNbC7GUN2q0P8diAFmhrWmdYlpRqqosydKBUFWfUVfCAzBHykWE2mm3SNWMcbt hLqFzAAmx9ZIv0Cd/Qs/0SZ5jFQ+DVHCB/jXrjLgOzlb1ZPwJefdOp1lRBYZCTFC9wNx QhICe9kzg1brGAAj4mFqYZofkdvjCsNcdEdOk= 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=x4l7SdSy/ZXICUFfVEpfugcTxefmMymFj4v54f2ETqQ=; b=BPi+a1rSdTZMUNqIlCqoCZd7A4weMnT/vKJX/EiWiKx4QlnrKrU6IVDQWgE3ywk0Rw EPIDnXtFP1k2O9oppfloiEa+D1cRwZC409Qw5bAGjZPhfT9YjnzLz7pf4h3BJx6s1bnZ iKRU8pJmx/1glEmdCDjkD32VT6dFCqItHkei+i/Az6wa+BKGmCISTMUj7ajFgp3H5oKR SJ6CwVtGPx4qb7JLJNZaFzxl8lhVGBTajSRDQMyLn3xZIfr5rKE2vZxBIxmoZjmuDdPY bGOE2fwILZlBuoU/csqS21WA+t1pgCHbXkupdFbAs/UUD23AQpmIbZf+oqZHk2OuwONa nCMg== X-Gm-Message-State: AOAM530d44wr6NuLCH8ciPcXCg9SK8T0C19Isy+Rn/P5vKysxvLlb125 T8tTt1PjKXzG4Vln1amrU2d5fQ== X-Google-Smtp-Source: ABdhPJwFPbv1eHMv9uXQ0J/1PfctmAALEU6cuguU/AUEcVHQb3vKL3KFeX3jg4pkUAvKg6vM1e63lA== X-Received: by 2002:a17:90b:4f46:: with SMTP id pj6mr4441477pjb.213.1642843133462; Sat, 22 Jan 2022 01:18:53 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 01:18:53 -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 31/31] clk: mediatek: Warn if clk IDs are duplicated Date: Sat, 22 Jan 2022 17:17:31 +0800 Message-Id: <20220122091731.283592-32-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" The Mediatek clk driver library handles duplicate clock IDs in two different ways: either ignoring the duplicate entry, or overwriting the old clk. Either way may cause unexpected behavior, and the latter also causes an orphan clk that cannot be cleaned up. Align the behavior so that later duplicate entries are ignored, and a warning printed. The warning will also aid in making the issue noticeable. Signed-off-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-cpumux.c | 6 ++++++ drivers/clk/mediatek/clk-gate.c | 5 ++++- drivers/clk/mediatek/clk-mtk.c | 18 ++++++++++++++---- drivers/clk/mediatek/clk-mux.c | 5 ++++- drivers/clk/mediatek/clk-pll.c | 6 ++++++ 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/drivers/clk/mediatek/clk-cpumux.c b/drivers/clk/mediatek/clk-c= pumux.c index 499c60432280..c11b3fae622e 100644 --- a/drivers/clk/mediatek/clk-cpumux.c +++ b/drivers/clk/mediatek/clk-cpumux.c @@ -120,6 +120,12 @@ int mtk_clk_register_cpumuxes(struct device_node *node, for (i =3D 0; i < num; i++) { const struct mtk_composite *mux =3D &clks[i]; =20 + if (!IS_ERR_OR_NULL(clk_data->clks[mux->id])) { + pr_warn("%pOF: Trying to register duplicate clock ID: %d\n", + node, mux->id); + continue; + } + clk =3D mtk_clk_register_cpumux(mux, regmap); if (IS_ERR(clk)) { pr_err("Failed to register clk %s: %pe\n", mux->name, clk); diff --git a/drivers/clk/mediatek/clk-gate.c b/drivers/clk/mediatek/clk-gat= e.c index 631ff170b7b9..da52023f8455 100644 --- a/drivers/clk/mediatek/clk-gate.c +++ b/drivers/clk/mediatek/clk-gate.c @@ -224,8 +224,11 @@ int mtk_clk_register_gates_with_dev(struct device_node= *node, for (i =3D 0; i < num; i++) { const struct mtk_gate *gate =3D &clks[i]; =20 - if (!IS_ERR_OR_NULL(clk_data->clks[gate->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[gate->id])) { + pr_warn("%pOF: Trying to register duplicate clock ID: %d\n", + node, gate->id); continue; + } =20 clk =3D mtk_clk_register_gate(gate->name, gate->parent_name, regmap, diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 6d0b8842971b..b2a3568922b2 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -65,8 +65,10 @@ int mtk_clk_register_fixed_clks(const struct mtk_fixed_c= lk *clks, int num, for (i =3D 0; i < num; i++) { const struct mtk_fixed_clk *rc =3D &clks[i]; =20 - if (!IS_ERR_OR_NULL(clk_data->clks[rc->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[rc->id])) { + pr_warn("Trying to register duplicate clock ID: %d\n", rc->id); continue; + } =20 clk =3D clk_register_fixed_rate(NULL, rc->name, rc->parent, 0, rc->rate); @@ -128,8 +130,10 @@ int mtk_clk_register_factors(const struct mtk_fixed_fa= ctor *clks, int num, for (i =3D 0; i < num; i++) { const struct mtk_fixed_factor *ff =3D &clks[i]; =20 - if (!IS_ERR_OR_NULL(clk_data->clks[ff->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[ff->id])) { + pr_warn("Trying to register duplicate clock ID: %d\n", ff->id); continue; + } =20 clk =3D clk_register_fixed_factor(NULL, ff->name, ff->parent_name, CLK_SET_RATE_PARENT, ff->mult, ff->div); @@ -300,8 +304,11 @@ int mtk_clk_register_composites(const struct mtk_compo= site *mcs, int num, for (i =3D 0; i < num; i++) { const struct mtk_composite *mc =3D &mcs[i]; =20 - if (clk_data && !IS_ERR_OR_NULL(clk_data->clks[mc->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[mc->id])) { + pr_warn("Trying to register duplicate clock ID: %d\n", + mc->id); continue; + } =20 clk =3D mtk_clk_register_composite(mc, base, lock); =20 @@ -363,8 +370,11 @@ int mtk_clk_register_dividers(const struct mtk_clk_div= ider *mcds, int num, for (i =3D 0; i < num; i++) { const struct mtk_clk_divider *mcd =3D &mcds[i]; =20 - if (!IS_ERR_OR_NULL(clk_data->clks[mcd->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[mcd->id])) { + pr_warn("Trying to register duplicate clock ID: %d\n", + mcd->id); continue; + } =20 clk =3D clk_register_divider(NULL, mcd->name, mcd->parent_name, mcd->flags, base + mcd->div_reg, mcd->div_shift, diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c index f51e67650f03..21ad5a4afd65 100644 --- a/drivers/clk/mediatek/clk-mux.c +++ b/drivers/clk/mediatek/clk-mux.c @@ -208,8 +208,11 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes, for (i =3D 0; i < num; i++) { const struct mtk_mux *mux =3D &muxes[i]; =20 - if (!IS_ERR_OR_NULL(clk_data->clks[mux->id])) + if (!IS_ERR_OR_NULL(clk_data->clks[mux->id])) { + pr_warn("%pOF: Trying to register duplicate clock ID: %d\n", + node, mux->id); continue; + } =20 clk =3D mtk_clk_register_mux(mux, regmap, lock); =20 diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c index 1dd15f560659..e5e9c188be99 100644 --- a/drivers/clk/mediatek/clk-pll.c +++ b/drivers/clk/mediatek/clk-pll.c @@ -386,6 +386,12 @@ int mtk_clk_register_plls(struct device_node *node, for (i =3D 0; i < num_plls; i++) { const struct mtk_pll_data *pll =3D &plls[i]; =20 + if (!IS_ERR_OR_NULL(clk_data->clks[pll->id])) { + pr_warn("%pOF: Trying to register duplicate clock ID: %d\n", + node, pll->id); + continue; + } + clk =3D mtk_clk_register_pll(pll, base); =20 if (IS_ERR(clk)) { --=20 2.35.0.rc0.227.g00780c9af4-goog