summaryrefslogtreecommitdiff
path: root/drivers/clk/mediatek/clk-cpumux.c
diff options
context:
space:
mode:
authorChen-Yu Tsai <wenst@chromium.org>2022-02-08 15:40:34 +0300
committerStephen Boyd <sboyd@kernel.org>2022-02-17 23:12:25 +0300
commitd54bb86b89556712d92154a386b421012fecf79e (patch)
treeb76779b2ad6518cd92ad106bbac8e1012d157aa5 /drivers/clk/mediatek/clk-cpumux.c
parentcf8a482afc286dde5eaf4a08d12b63590c599764 (diff)
downloadlinux-d54bb86b89556712d92154a386b421012fecf79e.tar.xz
clk: mediatek: Warn if clk IDs are duplicated
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 <wenst@chromium.org> Reviewed-by: Miles Chen <miles.chen@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20220208124034.414635-32-wenst@chromium.org Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'drivers/clk/mediatek/clk-cpumux.c')
-rw-r--r--drivers/clk/mediatek/clk-cpumux.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/clk/mediatek/clk-cpumux.c b/drivers/clk/mediatek/clk-cpumux.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 = 0; i < num; i++) {
const struct mtk_composite *mux = &clks[i];
+ 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 = mtk_clk_register_cpumux(mux, regmap);
if (IS_ERR(clk)) {
pr_err("Failed to register clk %s: %pe\n", mux->name, clk);