[PATCH v2 03/11] clk: mediatek: Convert mtk_{alloc, free}_clk_data to struct clk_hw
Miles Chen
miles.chen at mediatek.com
Thu May 12 07:05:12 PDT 2022
>-struct clk_onecell_data *mtk_alloc_clk_data(unsigned int clk_num)
>+struct clk_hw_onecell_data *mtk_alloc_clk_data(unsigned int clk_num)
> {
> int i;
> struct clk_onecell_data *clk_data;
This struct clk_onecell_data also be struct clk_hw_onecell_data?
>
>- clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL);
>+ clk_data = kzalloc(struct_size(clk_data, hws, clk_num), GFP_KERNEL);
> if (!clk_data)
> return NULL;
>
>- clk_data->clks = kcalloc(clk_num, sizeof(*clk_data->clks), GFP_KERNEL);
>- if (!clk_data->clks)
>- goto err_out;
>-
>- clk_data->clk_num = clk_num;
>+ clk_data->num = clk_num;
>
> for (i = 0; i < clk_num; i++)
>- clk_data->clks[i] = ERR_PTR(-ENOENT);
>+ clk_data->hws[i] = ERR_PTR(-ENOENT);
>
> return clk_data;
>-err_out:
>- kfree(clk_data);
>-
>- return NULL;
> }
> EXPORT_SYMBOL_GPL(mtk_alloc_clk_data);
>
>-void mtk_free_clk_data(struct clk_onecell_data *clk_data)
>+void mtk_free_clk_data(struct clk_hw_onecell_data *clk_data)
> {
>- if (!clk_data)
>- return;
>-
>- kfree(clk_data->clks);
> kfree(clk_data);
> }
>+EXPORT_SYMBOL_GPL(mtk_free_clk_data);
More information about the Linux-mediatek
mailing list