Skip to content

Commit 1c6d6b6

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

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
@@ -126,6 +126,26 @@ void mtk_clk_register_factors(const struct mtk_fixed_factor *clks,
126126
}
127127
EXPORT_SYMBOL_GPL(mtk_clk_register_factors);
128128

129+
void mtk_clk_unregister_factors(const struct mtk_fixed_factor *clks, int num,
130+
struct clk_onecell_data *clk_data)
131+
{
132+
int i;
133+
134+
if (!clk_data)
135+
return;
136+
137+
for (i = num; i > 0; i--) {
138+
const struct mtk_fixed_factor *ff = &clks[i - 1];
139+
140+
if (IS_ERR_OR_NULL(clk_data->clks[ff->id]))
141+
continue;
142+
143+
clk_unregister_fixed_factor(clk_data->clks[ff->id]);
144+
clk_data->clks[ff->id] = ERR_PTR(-ENOENT);
145+
}
146+
}
147+
EXPORT_SYMBOL_GPL(mtk_clk_unregister_factors);
148+
129149
struct clk *mtk_clk_register_composite(const struct mtk_composite *mc,
130150
void __iomem *base, spinlock_t *lock)
131151
{

drivers/clk/mediatek/clk-mtk.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ struct mtk_fixed_factor {
5555
.div = _div, \
5656
}
5757

58-
void mtk_clk_register_factors(const struct mtk_fixed_factor *clks,
59-
int num, struct clk_onecell_data *clk_data);
58+
void mtk_clk_register_factors(const struct mtk_fixed_factor *clks, int num,
59+
struct clk_onecell_data *clk_data);
60+
void mtk_clk_unregister_factors(const struct mtk_fixed_factor *clks, int num,
61+
struct clk_onecell_data *clk_data);
6062

6163
struct mtk_composite {
6264
int id;

0 commit comments

Comments
 (0)