Skip to content

Commit

Permalink
clk: mediatek: Add API for clock resource recycle
Browse files Browse the repository at this point in the history
In order to avoid resource leak when fail clock registration appears,
so adds the common interface to handle it.

Signed-off-by: Chun-Jie Chen <chun-jie.chen@mediatek.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Link: https://lore.kernel.org/r/20210914021633.26377-5-chun-jie.chen@mediatek.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
  • Loading branch information
Chun-Jie Chen authored and Stephen Boyd committed Sep 14, 2021
1 parent cb95c16 commit 300796c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/clk/mediatek/clk-mtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ struct clk_onecell_data *mtk_alloc_clk_data(unsigned int clk_num)
return NULL;
}

void mtk_free_clk_data(struct clk_onecell_data *clk_data)
{
if (!clk_data)
return;

kfree(clk_data->clks);
kfree(clk_data);
}

void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks,
int num, struct clk_onecell_data *clk_data)
{
Expand Down
1 change: 1 addition & 0 deletions drivers/clk/mediatek/clk-mtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds,
struct clk_onecell_data *clk_data);

struct clk_onecell_data *mtk_alloc_clk_data(unsigned int clk_num);
void mtk_free_clk_data(struct clk_onecell_data *clk_data);

#define HAVE_RST_BAR BIT(0)
#define PLL_AO BIT(1)
Expand Down

0 comments on commit 300796c

Please sign in to comment.