Skip to content

Commit 34c9d45

Browse files
wensbebarino
authored andcommitted
clk: mediatek: Implement mtk_clk_unregister_fixed_clks() API
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 <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-16-wenst@chromium.org Reviewed-by: Chun-Jie Chen <chun-jie.chen@mediatek.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 10174b5 commit 34c9d45

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

drivers/clk/mediatek/clk-mtk.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,26 @@ void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks,
8080
}
8181
EXPORT_SYMBOL_GPL(mtk_clk_register_fixed_clks);
8282

83+
void mtk_clk_unregister_fixed_clks(const struct mtk_fixed_clk *clks, int num,
84+
struct clk_onecell_data *clk_data)
85+
{
86+
int i;
87+
88+
if (!clk_data)
89+
return;
90+
91+
for (i = num; i > 0; i--) {
92+
const struct mtk_fixed_clk *rc = &clks[i - 1];
93+
94+
if (IS_ERR_OR_NULL(clk_data->clks[rc->id]))
95+
continue;
96+
97+
clk_unregister_fixed_rate(clk_data->clks[rc->id]);
98+
clk_data->clks[rc->id] = ERR_PTR(-ENOENT);
99+
}
100+
}
101+
EXPORT_SYMBOL_GPL(mtk_clk_unregister_fixed_clks);
102+
83103
void mtk_clk_register_factors(const struct mtk_fixed_factor *clks,
84104
int num, struct clk_onecell_data *clk_data)
85105
{

drivers/clk/mediatek/clk-mtk.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ struct mtk_fixed_clk {
3434
.rate = _rate, \
3535
}
3636

37-
void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks,
38-
int num, struct clk_onecell_data *clk_data);
37+
void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num,
38+
struct clk_onecell_data *clk_data);
39+
void mtk_clk_unregister_fixed_clks(const struct mtk_fixed_clk *clks, int num,
40+
struct clk_onecell_data *clk_data);
3941

4042
struct mtk_fixed_factor {
4143
int id;

0 commit comments

Comments
 (0)