clk: add helper functions for managing clk_onecell_data
Subsystems (5)
cover clk: add helper functions for managing clk_onecell_data
I am writing some clock drivers that use struct clk_onecell_data a few times, so I decided to write a helper function to allocate the memory since it is a two step process and can be tedious. Then I noticed that mediatek already had such a helper function, so I have moved that to the clk core and made use of it in other drivers where possible.
David Lechner (7):
clk: add helper function for allocating clk_onecell_data
clk: mediatek: make use of clk_alloc_onecell_data()
clk: qoriq: make use of clk_alloc_onecell_data()
clk: hisilicon: make use of clk_alloc_onecell_data()
clk: rockchip: make use of clk_alloc_onecell_data()
clk: st: make use of clk_alloc_onecell_data()
clk: sunxi: make use of clk_alloc_onecell_data()
drivers/clk/clk-qoriq.c | 13 +++------ drivers/clk/clk.c | 49 ++++++++++++++++++++++++++++++++ drivers/clk/hisilicon/clk-hi3620.c | 7 +---- drivers/clk/mediatek/clk-mt2701-bdp.c | 2 +- drivers/clk/mediatek/clk-mt2701-eth.c | 2 +- drivers/clk/mediatek/clk-mt2701-hif.c | 2 +- drivers/clk/mediatek/clk-mt2701-img.c | 2 +- drivers/clk/mediatek/clk-mt2701-mm.c | 2 +- drivers/clk/mediatek/clk-mt2701-vdec.c | 2 +- drivers/clk/mediatek/clk-mt2701.c | 10 +++---- drivers/clk/mediatek/clk-mt2712-bdp.c | 2 +- drivers/clk/mediatek/clk-mt2712-img.c | 2 +- drivers/clk/mediatek/clk-mt2712-jpgdec.c | 2 +- drivers/clk/mediatek/clk-mt2712-mfg.c | 2 +- drivers/clk/mediatek/clk-mt2712-mm.c | 2 +- drivers/clk/mediatek/clk-mt2712-vdec.c | 2 +- drivers/clk/mediatek/clk-mt2712-venc.c | 2 +- drivers/clk/mediatek/clk-mt2712.c | 12 ++++---- drivers/clk/mediatek/clk-mt6797-img.c | 2 +- drivers/clk/mediatek/clk-mt6797-mm.c | 2 +- drivers/clk/mediatek/clk-mt6797-vdec.c | 2 +- drivers/clk/mediatek/clk-mt6797-venc.c | 2 +- drivers/clk/mediatek/clk-mt6797.c | 8 +++--- drivers/clk/mediatek/clk-mt7622-aud.c | 2 +- drivers/clk/mediatek/clk-mt7622-eth.c | 4 +-- drivers/clk/mediatek/clk-mt7622-hif.c | 4 +-- drivers/clk/mediatek/clk-mt7622.c | 8 +++--- drivers/clk/mediatek/clk-mt8135.c | 8 +++--- drivers/clk/mediatek/clk-mt8173.c | 18 ++++++------ drivers/clk/mediatek/clk-mtk.c | 25 ---------------- drivers/clk/mediatek/clk-mtk.h | 2 -- drivers/clk/rockchip/clk-rockchip.c | 11 +------ drivers/clk/st/clk-flexgen.c | 17 ++++------- drivers/clk/st/clkgen-fsyn.c | 11 +------ drivers/clk/st/clkgen-pll.c | 12 ++------ drivers/clk/sunxi/clk-a10-pll2.c | 14 +++------ drivers/clk/sunxi/clk-mod0.c | 13 ++------- drivers/clk/sunxi/clk-simple-gates.c | 13 ++------- drivers/clk/sunxi/clk-sun8i-bus-gates.c | 13 ++------- drivers/clk/sunxi/clk-sunxi.c | 14 +++------ drivers/clk/sunxi/clk-usb.c | 8 +----- include/linux/clk-provider.h | 3 ++ 42 files changed, 138 insertions(+), 195 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/7 clk: add helper functions for managing clk_onecell_data
This adds helper functions for allocating and freeing struct clk_onecell_data.
--- drivers/clk/clk.c | 49 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/clk-provider.h | 3 +++ 2 files changed, 52 insertions(+)
drivers/clk/clk.c +49 -0
@@ -3551,6 +3551,55 @@ struct clk_hw *of_clk_hw_simple_get(struct of_phandle_args *clkspec, void *data) }EXPORT_SYMBOL_GPL (of_clk_hw_simple_get); +/** +* clk_alloc_onecell_data - allocate new struct clk_onecell_data +* @num_clks: Number of clock pointers to allocate +* +* An array of clock pointers is allocated and each clock pointer is +* initialized to ERR_PTR(-ENOENT). +* +* Returns: Pointer to struct clk_onecell_data or NULL on failure. +*/ +struct clk_onecell_data *clk_alloc_onecell_data (size_t num_clks) +{ +struct clk_onecell_data *clk_data; +int i; + + clk_data =kzalloc (sizeof (*clk_data),GFP_KERNEL ); +if (!clk_data) +return NULL ; + + clk_data->clks =kcalloc (num_clks,sizeof (*clk_data->clks),GFP_KERNEL ); +if (!clk_data->clks) { +kfree (clk_data); +return NULL ; + } + +for (i =0 ; i < num_clks; i++) + clk_data->clks[i] =ERR_PTR (-ENOENT ); + + clk_data->clk_num = num_clks; + +return clk_data; +} +EXPORT_SYMBOL_GPL (clk_alloc_onecell_data); + +/** +* clk_free_onecell_data - frees @clk_data and associated resources +* @clk_data: Pointer to struct clk_onecelldata that was allocated with +* clk_alloc_onecell_data() +* +* It is safe to call this function even if @clk_data is NULL or an error value. +*/ +void clk_free_onecell_data (struct clk_onecell_data *clk_data) +{ +if (IS_ERR_OR_NULL (clk_data)) +return ; + +kfree (clk_data->clks); +kfree (clk_data); +} +struct clk *of_clk_src_onecell_get (struct of_phandle_args *clkspec,void *data) {struct clk_onecell_data *clk_data = data;
include/linux/clk-provider.h +3 -0
@@ -786,6 +786,9 @@ struct clk_onecell_data {unsigned int clk_num; }; +struct clk_onecell_data *clk_alloc_onecell_data (size_t num_clks); +void clk_free_onecell_data (struct clk_onecell_data *clk_data); +struct clk_hw_onecell_data {unsigned int num;struct clk_hw *hws[];
Signature · 1 line
2.7.4
PATCH 2/7 clk: mediatek: make use of clk_alloc_onecell_data()
In reply to David LechnerA new function clk_alloc_onecell_data() has been added to the clk core that performs the same function as mtk_alloc_clk_data(), so we can replace all instances with the new function.
--- drivers/clk/mediatek/clk-mt2701-bdp.c | 2 +- drivers/clk/mediatek/clk-mt2701-eth.c | 2 +- drivers/clk/mediatek/clk-mt2701-hif.c | 2 +- drivers/clk/mediatek/clk-mt2701-img.c | 2 +- drivers/clk/mediatek/clk-mt2701-mm.c | 2 +- drivers/clk/mediatek/clk-mt2701-vdec.c | 2 +- drivers/clk/mediatek/clk-mt2701.c | 10 +++++----- drivers/clk/mediatek/clk-mt2712-bdp.c | 2 +- drivers/clk/mediatek/clk-mt2712-img.c | 2 +- drivers/clk/mediatek/clk-mt2712-jpgdec.c | 2 +- drivers/clk/mediatek/clk-mt2712-mfg.c | 2 +- drivers/clk/mediatek/clk-mt2712-mm.c | 2 +- drivers/clk/mediatek/clk-mt2712-vdec.c | 2 +- drivers/clk/mediatek/clk-mt2712-venc.c | 2 +- drivers/clk/mediatek/clk-mt2712.c | 12 ++++++------ drivers/clk/mediatek/clk-mt6797-img.c | 2 +- drivers/clk/mediatek/clk-mt6797-mm.c | 2 +- drivers/clk/mediatek/clk-mt6797-vdec.c | 2 +- drivers/clk/mediatek/clk-mt6797-venc.c | 2 +- drivers/clk/mediatek/clk-mt6797.c | 8 ++++---- drivers/clk/mediatek/clk-mt7622-aud.c | 2 +- drivers/clk/mediatek/clk-mt7622-eth.c | 4 ++-- drivers/clk/mediatek/clk-mt7622-hif.c | 4 ++-- drivers/clk/mediatek/clk-mt7622.c | 8 ++++---- drivers/clk/mediatek/clk-mt8135.c | 8 ++++---- drivers/clk/mediatek/clk-mt8173.c | 18 +++++++++--------- drivers/clk/mediatek/clk-mtk.c | 25 ------------------------- drivers/clk/mediatek/clk-mtk.h | 2 -- 28 files changed, 54 insertions(+), 81 deletions(-)
drivers/clk/mediatek/clk-mt2701-bdp.c +1 -1
@@ -113,7 +113,7 @@ static int clk_mt2701_bdp_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_BDP_NR ); + clk_data =clk_alloc_onecell_data (CLK_BDP_NR );mtk_clk_register_gates (node, bdp_clks,ARRAY_SIZE (bdp_clks), clk_data);
drivers/clk/mediatek/clk-mt2701-eth.c +1 -1
@@ -55,7 +55,7 @@ static int clk_mt2701_eth_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_ETHSYS_NR ); + clk_data =clk_alloc_onecell_data (CLK_ETHSYS_NR );mtk_clk_register_gates (node, eth_clks,ARRAY_SIZE (eth_clks), clk_data);
drivers/clk/mediatek/clk-mt2701-hif.c +1 -1
@@ -52,7 +52,7 @@ static int clk_mt2701_hif_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_HIFSYS_NR ); + clk_data =clk_alloc_onecell_data (CLK_HIFSYS_NR );mtk_clk_register_gates (node, hif_clks,ARRAY_SIZE (hif_clks), clk_data);
drivers/clk/mediatek/clk-mt2701-img.c +1 -1
@@ -55,7 +55,7 @@ static int clk_mt2701_img_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_IMG_NR ); + clk_data =clk_alloc_onecell_data (CLK_IMG_NR );mtk_clk_register_gates (node, img_clks,ARRAY_SIZE (img_clks), clk_data);
drivers/clk/mediatek/clk-mt2701-mm.c +1 -1
@@ -98,7 +98,7 @@ static int clk_mt2701_mm_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_MM_NR ); + clk_data =clk_alloc_onecell_data (CLK_MM_NR );mtk_clk_register_gates (node, mm_clks,ARRAY_SIZE (mm_clks), clk_data);
drivers/clk/mediatek/clk-mt2701-vdec.c +1 -1
@@ -66,7 +66,7 @@ static int clk_mt2701_vdec_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_VDEC_NR ); + clk_data =clk_alloc_onecell_data (CLK_VDEC_NR );mtk_clk_register_gates (node, vdec_clks,ARRAY_SIZE (vdec_clks), clk_data);
drivers/clk/mediatek/clk-mt2701.c +5 -5
@@ -688,7 +688,7 @@ static int mtk_topckgen_init(struct platform_device *pdev)if (IS_ERR (base))return PTR_ERR (base); - clk_data =mtk_alloc_clk_data (CLK_TOP_NR ); + clk_data =clk_alloc_onecell_data (CLK_TOP_NR );mtk_clk_register_fixed_clks (top_fixed_clks,ARRAY_SIZE (top_fixed_clks), clk_data);
@@ -755,7 +755,7 @@ static void __init mtk_infrasys_init_early(struct device_node *node)int r, i;if (!infra_clk_data) { - infra_clk_data =mtk_alloc_clk_data (CLK_INFRA_NR ); + infra_clk_data =clk_alloc_onecell_data (CLK_INFRA_NR );for (i =0 ; i <CLK_INFRA_NR ; i++) infra_clk_data->clks[i] =ERR_PTR (-EPROBE_DEFER );
@@ -781,7 +781,7 @@ static int mtk_infrasys_init(struct platform_device *pdev)struct device_node *node = pdev->dev.of_node;if (!infra_clk_data) { - infra_clk_data =mtk_alloc_clk_data (CLK_INFRA_NR ); + infra_clk_data =clk_alloc_onecell_data (CLK_INFRA_NR ); }else {for (i =0 ; i <CLK_INFRA_NR ; i++) {if (infra_clk_data->clks[i] ==ERR_PTR (-EPROBE_DEFER ))
@@ -909,7 +909,7 @@ static int mtk_pericfg_init(struct platform_device *pdev)if (IS_ERR (base))return PTR_ERR (base); - clk_data =mtk_alloc_clk_data (CLK_PERI_NR ); + clk_data =clk_alloc_onecell_data (CLK_PERI_NR );mtk_clk_register_gates (node, peri_clks,ARRAY_SIZE (peri_clks), clk_data);
@@ -981,7 +981,7 @@ static int mtk_apmixedsys_init(struct platform_device *pdev)struct clk_onecell_data *clk_data;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_APMIXED_NR ); + clk_data =clk_alloc_onecell_data (CLK_APMIXED_NR );if (!clk_data)return -ENOMEM ;
drivers/clk/mediatek/clk-mt2712-bdp.c +1 -1
@@ -72,7 +72,7 @@ static int clk_mt2712_bdp_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_BDP_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_BDP_NR_CLK );mtk_clk_register_gates (node, bdp_clks,ARRAY_SIZE (bdp_clks), clk_data);
drivers/clk/mediatek/clk-mt2712-img.c +1 -1
@@ -50,7 +50,7 @@ static int clk_mt2712_img_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_IMG_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_IMG_NR_CLK );mtk_clk_register_gates (node, img_clks,ARRAY_SIZE (img_clks), clk_data);
drivers/clk/mediatek/clk-mt2712-jpgdec.c +1 -1
@@ -46,7 +46,7 @@ static int clk_mt2712_jpgdec_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_JPGDEC_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_JPGDEC_NR_CLK );mtk_clk_register_gates (node, jpgdec_clks,ARRAY_SIZE (jpgdec_clks), clk_data);
drivers/clk/mediatek/clk-mt2712-mfg.c +1 -1
@@ -45,7 +45,7 @@ static int clk_mt2712_mfg_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_MFG_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_MFG_NR_CLK );mtk_clk_register_gates (node, mfg_clks,ARRAY_SIZE (mfg_clks), clk_data);
drivers/clk/mediatek/clk-mt2712-mm.c +1 -1
@@ -140,7 +140,7 @@ static int clk_mt2712_mm_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_MM_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_MM_NR_CLK );mtk_clk_register_gates (node, mm_clks,ARRAY_SIZE (mm_clks), clk_data);
drivers/clk/mediatek/clk-mt2712-vdec.c +1 -1
@@ -64,7 +64,7 @@ static int clk_mt2712_vdec_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_VDEC_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_VDEC_NR_CLK );mtk_clk_register_gates (node, vdec_clks,ARRAY_SIZE (vdec_clks), clk_data);
drivers/clk/mediatek/clk-mt2712-venc.c +1 -1
@@ -47,7 +47,7 @@ static int clk_mt2712_venc_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_VENC_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_VENC_NR_CLK );mtk_clk_register_gates (node, venc_clks,ARRAY_SIZE (venc_clks), clk_data);
drivers/clk/mediatek/clk-mt2712.c +6 -6
@@ -1226,7 +1226,7 @@ static int clk_mt2712_apmixed_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_APMIXED_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_APMIXED_NR_CLK );mtk_clk_register_plls (node, plls,ARRAY_SIZE (plls), clk_data);
@@ -1246,7 +1246,7 @@ static void clk_mt2712_top_init_early(struct device_node *node)int r, i;if (!top_clk_data) { - top_clk_data =mtk_alloc_clk_data (CLK_TOP_NR_CLK ); + top_clk_data =clk_alloc_onecell_data (CLK_TOP_NR_CLK );for (i =0 ; i <CLK_TOP_NR_CLK ; i++) top_clk_data->clks[i] =ERR_PTR (-EPROBE_DEFER );
@@ -1278,7 +1278,7 @@ static int clk_mt2712_top_probe(struct platform_device *pdev) }if (!top_clk_data) { - top_clk_data =mtk_alloc_clk_data (CLK_TOP_NR_CLK ); + top_clk_data =clk_alloc_onecell_data (CLK_TOP_NR_CLK ); }else {for (i =0 ; i <CLK_TOP_NR_CLK ; i++) {if (top_clk_data->clks[i] ==ERR_PTR (-EPROBE_DEFER ))
@@ -1313,7 +1313,7 @@ static int clk_mt2712_infra_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_INFRA_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_INFRA_NR_CLK );mtk_clk_register_gates (node, infra_clks,ARRAY_SIZE (infra_clks), clk_data);
@@ -1335,7 +1335,7 @@ static int clk_mt2712_peri_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_PERI_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_PERI_NR_CLK );mtk_clk_register_gates (node, peri_clks,ARRAY_SIZE (peri_clks), clk_data);
@@ -1365,7 +1365,7 @@ static int clk_mt2712_mcu_probe(struct platform_device *pdev)return PTR_ERR (base); } - clk_data =mtk_alloc_clk_data (CLK_MCU_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_MCU_NR_CLK );mtk_clk_register_composites (mcu_muxes,ARRAY_SIZE (mcu_muxes), base, &mt2712_clk_lock, clk_data);
drivers/clk/mediatek/clk-mt6797-img.c +1 -1
@@ -51,7 +51,7 @@ static int clk_mt6797_img_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_IMG_NR ); + clk_data =clk_alloc_onecell_data (CLK_IMG_NR );mtk_clk_register_gates (node, img_clks,ARRAY_SIZE (img_clks), clk_data);
drivers/clk/mediatek/clk-mt6797-mm.c +1 -1
@@ -111,7 +111,7 @@ static int clk_mt6797_mm_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_MM_NR ); + clk_data =clk_alloc_onecell_data (CLK_MM_NR );mtk_clk_register_gates (node, mm_clks,ARRAY_SIZE (mm_clks), clk_data);
drivers/clk/mediatek/clk-mt6797-vdec.c +1 -1
@@ -68,7 +68,7 @@ static int clk_mt6797_vdec_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_VDEC_NR ); + clk_data =clk_alloc_onecell_data (CLK_VDEC_NR );mtk_clk_register_gates (node, vdec_clks,ARRAY_SIZE (vdec_clks), clk_data);
drivers/clk/mediatek/clk-mt6797-venc.c +1 -1
@@ -53,7 +53,7 @@ static int clk_mt6797_venc_probe(struct platform_device *pdev)int r;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_VENC_NR ); + clk_data =clk_alloc_onecell_data (CLK_VENC_NR );mtk_clk_register_gates (node, venc_clks,ARRAY_SIZE (venc_clks), clk_data);
drivers/clk/mediatek/clk-mt6797.c +4 -4
@@ -395,7 +395,7 @@ static int mtk_topckgen_init(struct platform_device *pdev)if (IS_ERR (base))return PTR_ERR (base); - clk_data =mtk_alloc_clk_data (CLK_TOP_NR ); + clk_data =clk_alloc_onecell_data (CLK_TOP_NR );mtk_clk_register_factors (top_fixed_divs,ARRAY_SIZE (top_fixed_divs), clk_data);
@@ -553,7 +553,7 @@ static void mtk_infrasys_init_early(struct device_node *node)int r, i;if (!infra_clk_data) { - infra_clk_data =mtk_alloc_clk_data (CLK_INFRA_NR ); + infra_clk_data =clk_alloc_onecell_data (CLK_INFRA_NR );for (i =0 ; i <CLK_INFRA_NR ; i++) infra_clk_data->clks[i] =ERR_PTR (-EPROBE_DEFER );
@@ -577,7 +577,7 @@ static int mtk_infrasys_init(struct platform_device *pdev)struct device_node *node = pdev->dev.of_node;if (!infra_clk_data) { - infra_clk_data =mtk_alloc_clk_data (CLK_INFRA_NR ); + infra_clk_data =clk_alloc_onecell_data (CLK_INFRA_NR ); }else {for (i =0 ; i <CLK_INFRA_NR ; i++) {if (infra_clk_data->clks[i] ==ERR_PTR (-EPROBE_DEFER ))
@@ -656,7 +656,7 @@ static int mtk_apmixedsys_init(struct platform_device *pdev)struct clk_onecell_data *clk_data;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_APMIXED_NR ); + clk_data =clk_alloc_onecell_data (CLK_APMIXED_NR );if (!clk_data)return -ENOMEM ;
drivers/clk/mediatek/clk-mt7622-aud.c +1 -1
@@ -143,7 +143,7 @@ static int clk_mt7622_audiosys_init(struct platform_device *pdev)struct device_node *node = pdev->dev.of_node;int r; - clk_data =mtk_alloc_clk_data (CLK_AUDIO_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_AUDIO_NR_CLK );mtk_clk_register_gates (node, audio_clks,ARRAY_SIZE (audio_clks), clk_data);
drivers/clk/mediatek/clk-mt7622-eth.c +2 -2
@@ -79,7 +79,7 @@ static int clk_mt7622_ethsys_init(struct platform_device *pdev)struct device_node *node = pdev->dev.of_node;int r; - clk_data =mtk_alloc_clk_data (CLK_ETH_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_ETH_NR_CLK );mtk_clk_register_gates (node, eth_clks,ARRAY_SIZE (eth_clks), clk_data);
@@ -101,7 +101,7 @@ static int clk_mt7622_sgmiisys_init(struct platform_device *pdev)struct device_node *node = pdev->dev.of_node;int r; - clk_data =mtk_alloc_clk_data (CLK_SGMII_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_SGMII_NR_CLK );mtk_clk_register_gates (node, sgmii_clks,ARRAY_SIZE (sgmii_clks), clk_data);
drivers/clk/mediatek/clk-mt7622-hif.c +2 -2
@@ -90,7 +90,7 @@ static int clk_mt7622_ssusbsys_init(struct platform_device *pdev)struct device_node *node = pdev->dev.of_node;int r; - clk_data =mtk_alloc_clk_data (CLK_SSUSB_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_SSUSB_NR_CLK );mtk_clk_register_gates (node, ssusb_clks,ARRAY_SIZE (ssusb_clks), clk_data);
@@ -112,7 +112,7 @@ static int clk_mt7622_pciesys_init(struct platform_device *pdev)struct device_node *node = pdev->dev.of_node;int r; - clk_data =mtk_alloc_clk_data (CLK_PCIE_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_PCIE_NR_CLK );mtk_clk_register_gates (node, pcie_clks,ARRAY_SIZE (pcie_clks), clk_data);
drivers/clk/mediatek/clk-mt7622.c +4 -4
@@ -628,7 +628,7 @@ static int mtk_topckgen_init(struct platform_device *pdev)if (IS_ERR (base))return PTR_ERR (base); - clk_data =mtk_alloc_clk_data (CLK_TOP_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_TOP_NR_CLK );mtk_clk_register_fixed_clks (top_fixed_clks,ARRAY_SIZE (top_fixed_clks), clk_data);
@@ -658,7 +658,7 @@ static int __init mtk_infrasys_init(struct platform_device *pdev)struct clk_onecell_data *clk_data;int r; - clk_data =mtk_alloc_clk_data (CLK_INFRA_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_INFRA_NR_CLK );mtk_clk_register_gates (node, infra_clks,ARRAY_SIZE (infra_clks), clk_data);
@@ -681,7 +681,7 @@ static int mtk_apmixedsys_init(struct platform_device *pdev)struct clk_onecell_data *clk_data;struct device_node *node = pdev->dev.of_node; - clk_data =mtk_alloc_clk_data (CLK_APMIXED_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_APMIXED_NR_CLK );if (!clk_data)return -ENOMEM ;
@@ -709,7 +709,7 @@ static int mtk_pericfg_init(struct platform_device *pdev)if (IS_ERR (base))return PTR_ERR (base); - clk_data =mtk_alloc_clk_data (CLK_PERI_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_PERI_NR_CLK );mtk_clk_register_gates (node, peri_clks,ARRAY_SIZE (peri_clks), clk_data);
drivers/clk/mediatek/clk-mt8135.c +4 -4
@@ -533,7 +533,7 @@ static void __init mtk_topckgen_init(struct device_node *node)return ; } - clk_data =mtk_alloc_clk_data (CLK_TOP_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_TOP_NR_CLK );mtk_clk_register_factors (root_clk_alias,ARRAY_SIZE (root_clk_alias), clk_data);mtk_clk_register_factors (top_divs,ARRAY_SIZE (top_divs), clk_data);
@@ -554,7 +554,7 @@ static void __init mtk_infrasys_init(struct device_node *node)struct clk_onecell_data *clk_data;int r; - clk_data =mtk_alloc_clk_data (CLK_INFRA_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_INFRA_NR_CLK );mtk_clk_register_gates (node, infra_clks,ARRAY_SIZE (infra_clks), clk_data);
@@ -582,7 +582,7 @@ static void __init mtk_pericfg_init(struct device_node *node)return ; } - clk_data =mtk_alloc_clk_data (CLK_PERI_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_PERI_NR_CLK );mtk_clk_register_gates (node, peri_gates,ARRAY_SIZE (peri_gates), clk_data);
@@ -635,7 +635,7 @@ static void __init mtk_apmixedsys_init(struct device_node *node) {struct clk_onecell_data *clk_data; - clk_data =mtk_alloc_clk_data (CLK_APMIXED_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_APMIXED_NR_CLK );if (!clk_data)return ;
drivers/clk/mediatek/clk-mt8173.c +9 -9
@@ -941,7 +941,7 @@ static void __init mtk_topckgen_init(struct device_node *node)return ; } - mt8173_top_clk_data = clk_data =mtk_alloc_clk_data (CLK_TOP_NR_CLK ); + mt8173_top_clk_data = clk_data =clk_alloc_onecell_data (CLK_TOP_NR_CLK );mtk_clk_register_fixed_clks (fixed_clks,ARRAY_SIZE (fixed_clks), clk_data);mtk_clk_register_factors (top_divs,ARRAY_SIZE (top_divs), clk_data);
@@ -962,7 +962,7 @@ static void __init mtk_infrasys_init(struct device_node *node)struct clk_onecell_data *clk_data;int r; - clk_data =mtk_alloc_clk_data (CLK_INFRA_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_INFRA_NR_CLK );mtk_clk_register_gates (node, infra_clks,ARRAY_SIZE (infra_clks), clk_data);
@@ -992,7 +992,7 @@ static void __init mtk_pericfg_init(struct device_node *node)return ; } - clk_data =mtk_alloc_clk_data (CLK_PERI_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_PERI_NR_CLK );mtk_clk_register_gates (node, peri_gates,ARRAY_SIZE (peri_gates), clk_data);
@@ -1096,7 +1096,7 @@ static void __init mtk_apmixedsys_init(struct device_node *node)return ; } - mt8173_pll_clk_data = clk_data =mtk_alloc_clk_data (CLK_APMIXED_NR_CLK ); + mt8173_pll_clk_data = clk_data =clk_alloc_onecell_data (CLK_APMIXED_NR_CLK );if (!clk_data) {iounmap (base);return ;
@@ -1139,7 +1139,7 @@ static void __init mtk_imgsys_init(struct device_node *node)struct clk_onecell_data *clk_data;int r; - clk_data =mtk_alloc_clk_data (CLK_IMG_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_IMG_NR_CLK );mtk_clk_register_gates (node, img_clks,ARRAY_SIZE (img_clks), clk_data);
@@ -1157,7 +1157,7 @@ static void __init mtk_mmsys_init(struct device_node *node)struct clk_onecell_data *clk_data;int r; - clk_data =mtk_alloc_clk_data (CLK_MM_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_MM_NR_CLK );mtk_clk_register_gates (node, mm_clks,ARRAY_SIZE (mm_clks), clk_data);
@@ -1174,7 +1174,7 @@ static void __init mtk_vdecsys_init(struct device_node *node)struct clk_onecell_data *clk_data;int r; - clk_data =mtk_alloc_clk_data (CLK_VDEC_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_VDEC_NR_CLK );mtk_clk_register_gates (node, vdec_clks,ARRAY_SIZE (vdec_clks), clk_data);
@@ -1191,7 +1191,7 @@ static void __init mtk_vencsys_init(struct device_node *node)struct clk_onecell_data *clk_data;int r; - clk_data =mtk_alloc_clk_data (CLK_VENC_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_VENC_NR_CLK );mtk_clk_register_gates (node, venc_clks,ARRAY_SIZE (venc_clks), clk_data);
@@ -1208,7 +1208,7 @@ static void __init mtk_vencltsys_init(struct device_node *node)struct clk_onecell_data *clk_data;int r; - clk_data =mtk_alloc_clk_data (CLK_VENCLT_NR_CLK ); + clk_data =clk_alloc_onecell_data (CLK_VENCLT_NR_CLK );mtk_clk_register_gates (node, venclt_clks,ARRAY_SIZE (venclt_clks), clk_data);
drivers/clk/mediatek/clk-mtk.c +0 -25
@@ -24,31 +24,6 @@#include "clk-mtk.h" #include "clk-gate.h" -struct clk_onecell_data *mtk_alloc_clk_data (unsigned int clk_num) -{ -int i; -struct clk_onecell_data *clk_data; - - clk_data =kzalloc (sizeof (*clk_data),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; - -for (i =0 ; i < clk_num; i++) - clk_data->clks[i] =ERR_PTR (-ENOENT ); - -return clk_data; -err_out: -kfree (clk_data); - -return NULL ; -} -void mtk_clk_register_fixed_clks (const struct mtk_fixed_clk *clks,int num,struct clk_onecell_data *clk_data) {
drivers/clk/mediatek/clk-mtk.h +0 -2
@@ -190,8 +190,6 @@ void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num, void __iomem *base, spinlock_t *lock, struct clk_onecell_data *clk_data); -struct clk_onecell_data *mtk_alloc_clk_data (unsigned int clk_num); -#define HAVE_RST_BAR BIT(0)#define PLL_AO BIT(1)
Signature · 1 line
2.7.4
PATCH 3/7 clk: qoriq: make use of clk_alloc_onecell_data()
In reply to David LechnerUse helper function clk_alloc_onecell_data() to allocate struct clk_onecell_data.
--- drivers/clk/clk-qoriq.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/clk/clk-qoriq.c +4 -9
@@ -1175,13 +1175,11 @@ static void __init legacy_pll_init(struct device_node *np, int idx) count =of_property_count_strings (np,"clock-output-names" );BUILD_BUG_ON (ARRAY_SIZE (pll->div) <4 ); - subclks =kcalloc (4 ,sizeof (struct clk *),GFP_KERNEL ); -if (!subclks) + onecell_data =clk_alloc_onecell_data (4 ); +if (!onecell_data)return ; - onecell_data =kmalloc (sizeof (*onecell_data),GFP_KERNEL ); -if (!onecell_data) - goto err_clks; + subclks = onecell_data->clks;if (count <=3 ) { subclks[0 ] = pll->div[0 ].clk;
@@ -1194,7 +1192,6 @@ static void __init legacy_pll_init(struct device_node *np, int idx) subclks[3 ] = pll->div[3 ].clk; } - onecell_data->clks = subclks; onecell_data->clk_num = count; rc =of_clk_add_provider (np, of_clk_src_onecell_get, onecell_data);
@@ -1206,9 +1203,7 @@ static void __init legacy_pll_init(struct device_node *np, int idx)return ; err_cell: -kfree (onecell_data); -err_clks: -kfree (subclks); +clk_free_onecell_data (onecell_data); }/* Legacy node */
Signature · 1 line
2.7.4
PATCH 4/7 clk: hisilicon: make use of clk_alloc_onecell_data()
In reply to David LechnerUse helper function clk_alloc_onecell_data() to allocate struct clk_onecell_data.
--- drivers/clk/hisilicon/clk-hi3620.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/clk/hisilicon/clk-hi3620.c +1 -6
@@ -476,21 +476,16 @@ static void __init hi3620_mmc_clk_init(struct device_node *node)return ; } - clk_data =kzalloc (sizeof (*clk_data),GFP_KERNEL ); + clk_data =clk_alloc_onecell_data (num);if (WARN_ON (!clk_data))return ; - clk_data->clks =kcalloc (num,sizeof (*clk_data->clks),GFP_KERNEL ); -if (!clk_data->clks) -return ; -for (i =0 ; i < num; i++) {struct hisi_mmc_clock *mmc_clk = &hi3620_mmc_clks[i]; clk_data->clks[mmc_clk->id] =hisi_register_clk_mmc (mmc_clk, base, node); } - clk_data->clk_num = num;of_clk_add_provider (node, of_clk_src_onecell_get, clk_data); }
Signature · 1 line
2.7.4
PATCH 5/7 clk: rockchip: make use of clk_alloc_onecell_data()
In reply to David LechnerUse helper function clk_alloc_onecell_data() to allocate struct clk_onecell_data.
--- drivers/clk/rockchip/clk-rockchip.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/clk/rockchip/clk-rockchip.c +1 -10
@@ -52,19 +52,12 @@ static void __init rk2928_gate_clk_init(struct device_node *node)if (!reg)return ; - clk_data =kzalloc (sizeof (struct clk_onecell_data ),GFP_KERNEL ); + clk_data =clk_alloc_onecell_data (qty);if (!clk_data) {iounmap (reg);return ; } - clk_data->clks =kzalloc (qty *sizeof (struct clk *),GFP_KERNEL ); -if (!clk_data->clks) { -kfree (clk_data); -iounmap (reg); -return ; - } - flags =CLK_GATE_HIWORD_MASK |CLK_GATE_SET_TO_DISABLE ;for (i =0 ; i < qty; i++) {
@@ -91,8 +84,6 @@ static void __init rk2928_gate_clk_init(struct device_node *node)WARN_ON (IS_ERR (clk_data->clks[i])); } - clk_data->clk_num = qty; -of_clk_add_provider (node, of_clk_src_onecell_get, clk_data); }CLK_OF_DECLARE (rk2928_gate,"rockchip,rk2928-gate-clk" , rk2928_gate_clk_init);
Signature · 1 line
2.7.4
PATCH 6/7 clk: st: make use of clk_alloc_onecell_data()
In reply to David LechnerUse helper function clk_alloc_onecell_data() to allocate struct clk_onecell_data.
--- drivers/clk/st/clk-flexgen.c | 17 +++++------------ drivers/clk/st/clkgen-fsyn.c | 11 +---------- drivers/clk/st/clkgen-pll.c | 12 ++---------- 3 files changed, 8 insertions(+), 32 deletions(-)
drivers/clk/st/clk-flexgen.c +5 -12
@@ -310,7 +310,7 @@ static void __init st_of_flexgen_setup(struct device_node *np) {struct device_node *pnode;void __iomem *reg; -struct clk_onecell_data *clk_data; +struct clk_onecell_data *clk_data =NULL ;const char **parents;int num_parents, i;spinlock_t *rlock =NULL ;
@@ -341,21 +341,15 @@ static void __init st_of_flexgen_setup(struct device_node *np) clk_mode = data->mode; } - clk_data =kzalloc (sizeof (*clk_data),GFP_KERNEL ); -if (!clk_data) - goto err; - ret =of_property_count_strings (np,"clock-output-names" );if (ret <=0 ) {pr_err ("%s: Failed to get number of output clocks (%d)" , - __func__, clk_data->clk_num); + __func__, ret); goto err; } - clk_data->clk_num = ret; - clk_data->clks =kcalloc (clk_data->clk_num,sizeof (struct clk *), -GFP_KERNEL ); -if (!clk_data->clks) + clk_data =clk_alloc_onecell_data (ret); +if (!clk_data) goto err; rlock =kzalloc (sizeof (spinlock_t),GFP_KERNEL );
@@ -397,8 +391,7 @@ static void __init st_of_flexgen_setup(struct device_node *np) err:iounmap (reg); -if (clk_data) -kfree (clk_data->clks); +clk_free_onecell_data (clk_data);kfree (clk_data);kfree (parents);kfree (rlock);
drivers/clk/st/clkgen-fsyn.c +1 -10
@@ -869,19 +869,10 @@ static void __init st_of_create_quadfs_fsynths(struct clk_onecell_data *clk_data;int fschan; - clk_data =kzalloc (sizeof (*clk_data),GFP_KERNEL ); + clk_data =clk_alloc_onecell_data (QUADFS_MAX_CHAN );if (!clk_data)return ; - clk_data->clk_num =QUADFS_MAX_CHAN ; - clk_data->clks =kzalloc (QUADFS_MAX_CHAN *sizeof (struct clk *), -GFP_KERNEL ); - -if (!clk_data->clks) { -kfree (clk_data); -return ; - } -for (fschan =0 ; fschan <QUADFS_MAX_CHAN ; fschan++) {struct clk *clk;const char *clk_name;
drivers/clk/st/clkgen-pll.c +2 -10
@@ -733,17 +733,10 @@ static void __init clkgen_c32_pll_setup(struct device_node *np, num_odfs = data->num_odfs; - clk_data =kzalloc (sizeof (*clk_data),GFP_KERNEL ); + clk_data =clk_alloc_onecell_data (num_odfs);if (!clk_data)return ; - clk_data->clk_num = num_odfs; - clk_data->clks =kzalloc (clk_data->clk_num *sizeof (struct clk *), -GFP_KERNEL ); - -if (!clk_data->clks) - goto err; -for (odf =0 ; odf < num_odfs; odf++) {struct clk *clk;const char *clk_name;
@@ -768,8 +761,7 @@ static void __init clkgen_c32_pll_setup(struct device_node *np, err:kfree (pll_name); -kfree (clk_data->clks); -kfree (clk_data); +clk_free_onecell_data (clk_data); }static void __init clkgen_c32_pll0_setup (struct device_node *np) {
Signature · 1 line
2.7.4
PATCH 7/7 clk: sunxi: make use of clk_alloc_onecell_data()
In reply to David LechnerUse helper function clk_alloc_onecell_data() to allocate struct clk_onecell_data.
--- drivers/clk/sunxi/clk-a10-pll2.c | 14 ++++---------- drivers/clk/sunxi/clk-mod0.c | 13 +++---------- drivers/clk/sunxi/clk-simple-gates.c | 13 +++---------- drivers/clk/sunxi/clk-sun8i-bus-gates.c | 13 +++---------- drivers/clk/sunxi/clk-sunxi.c | 14 ++++---------- drivers/clk/sunxi/clk-usb.c | 8 +------- 6 files changed, 18 insertions(+), 57 deletions(-)
drivers/clk/sunxi/clk-a10-pll2.c +4 -10
@@ -58,13 +58,11 @@ static void __init sun4i_pll2_setup(struct device_node *node,if (IS_ERR (reg))return ; - clk_data =kzalloc (sizeof (*clk_data),GFP_KERNEL ); + clk_data =clk_alloc_onecell_data (SUN4I_PLL2_OUTPUTS );if (!clk_data) goto err_unmap; - clks =kcalloc (SUN4I_PLL2_OUTPUTS ,sizeof (struct clk *),GFP_KERNEL ); -if (!clks) - goto err_free_data; + clks = clk_data->clks; parent =of_clk_get_parent_name (node,0 ); prediv_clk = clk_register_divider(NULL, "pll2-prediv",
@@ -75,7 +73,7 @@ static void __init sun4i_pll2_setup(struct device_node *node, &sun4i_a10_pll2_lock);if (IS_ERR (prediv_clk)) {pr_err ("Couldn't register the prediv clock\n" ); - goto err_free_array; + goto err_free_data; }/* Setup the gate part of the PLL2 */
@@ -166,8 +164,6 @@ static void __init sun4i_pll2_setup(struct device_node *node, 2, 1);WARN_ON (IS_ERR (clks[SUN4I_A10_PLL2_8X ])); - clk_data->clks = clks; - clk_data->clk_num =SUN4I_PLL2_OUTPUTS ;of_clk_add_provider (node, of_clk_src_onecell_get, clk_data);return ;
@@ -178,10 +174,8 @@ static void __init sun4i_pll2_setup(struct device_node *node,kfree (gate); err_unregister_prediv:clk_unregister_divider (prediv_clk); -err_free_array: -kfree (clks); err_free_data: -kfree (clk_data); +clk_free_onecell_data (clk_data); err_unmap:iounmap (reg); }
drivers/clk/sunxi/clk-mod0.c +3 -10
@@ -315,18 +315,13 @@ static void __init sunxi_mmc_setup(struct device_node *node,return ; } - clk_data =kmalloc (sizeof (*clk_data),GFP_KERNEL ); + clk_data =clk_alloc_onecell_data (3 );if (!clk_data)return ; - clk_data->clks =kcalloc (3 ,sizeof (*clk_data->clks),GFP_KERNEL ); -if (!clk_data->clks) - goto err_free_data; - - clk_data->clk_num =3 ; clk_data->clks[0 ] =sunxi_factors_register (node, data, lock, reg);if (!clk_data->clks[0 ]) - goto err_free_clks; + goto err_free_data; parent =__clk_get_name (clk_data->clks[0 ]);
@@ -366,10 +361,8 @@ static void __init sunxi_mmc_setup(struct device_node *node,return ; -err_free_clks: -kfree (clk_data->clks); err_free_data: -kfree (clk_data); +clk_free_onecell_data (clk_data); }static DEFINE_SPINLOCK (sun4i_a10_mmc_lock);
drivers/clk/sunxi/clk-simple-gates.c +3 -10
@@ -44,16 +44,12 @@ static void __init sunxi_simple_gates_setup(struct device_node *node, clk_parent =of_clk_get_parent_name (node,0 ); - clk_data =kmalloc (sizeof (struct clk_onecell_data ),GFP_KERNEL ); -if (!clk_data) - goto err_unmap; - number =of_property_count_u32_elems (node,"clock-indices" );of_property_read_u32_index (node,"clock-indices" , number -1 , &number); - clk_data->clks =kcalloc (number +1 ,sizeof (struct clk *),GFP_KERNEL ); -if (!clk_data->clks) - goto err_free_data; + clk_data =clk_alloc_onecell_data (number +1 ); +if (!clk_data) + goto err_unmap;of_property_for_each_u32 (node,"clock-indices" , prop, p, index) { of_property_read_string_index(node, "clock-output-names",
@@ -80,13 +76,10 @@ static void __init sunxi_simple_gates_setup(struct device_node *node, } - clk_data->clk_num = number +1 ;of_clk_add_provider (node, of_clk_src_onecell_get, clk_data);return ; -err_free_data: -kfree (clk_data); err_unmap:iounmap (reg);of_address_to_resource (node,0 , &res);
drivers/clk/sunxi/clk-sun8i-bus-gates.c +3 -10
@@ -54,16 +54,12 @@ static void __init sun8i_h3_bus_gates_init(struct device_node *node) parents[i] =of_clk_get_parent_name (node, idx); } - clk_data =kmalloc (sizeof (struct clk_onecell_data ),GFP_KERNEL ); -if (!clk_data) - goto err_unmap; - number =of_property_count_u32_elems (node,"clock-indices" );of_property_read_u32_index (node,"clock-indices" , number -1 , &number); - clk_data->clks =kcalloc (number +1 ,sizeof (struct clk *),GFP_KERNEL ); -if (!clk_data->clks) - goto err_free_data; + clk_data =clk_alloc_onecell_data (number +1 ); +if (!clk_data) + goto err_unmap; i =0 ;of_property_for_each_u32 (node,"clock-indices" , prop, p, index) {
@@ -98,13 +94,10 @@ static void __init sun8i_h3_bus_gates_init(struct device_node *node) } } - clk_data->clk_num = number +1 ;of_clk_add_provider (node, of_clk_src_onecell_get, clk_data);return ; -err_free_data: -kfree (clk_data); err_unmap:iounmap (reg);of_address_to_resource (node,0 , &res);
drivers/clk/sunxi/clk-sunxi.c +4 -10
@@ -1012,15 +1012,11 @@ static struct clk ** __init sunxi_divs_clk_setup(struct device_node *node,return NULL ; } - clk_data =kmalloc (sizeof (struct clk_onecell_data ),GFP_KERNEL ); + clk_data =clk_alloc_onecell_data (ndivs);if (!clk_data) goto out_unmap; - clks =kcalloc (ndivs,sizeof (*clks),GFP_KERNEL ); -if (!clks) - goto free_clkdata; - - clk_data->clks = clks; + clks = clk_data->clks;/* It's not a good idea to have automatic reparenting changing * our RAM clock! */
@@ -1045,7 +1041,7 @@ static struct clk ** __init sunxi_divs_clk_setup(struct device_node *node,if (data->div[i].gate) { gate =kzalloc (sizeof (*gate),GFP_KERNEL );if (!gate) - goto free_clks; + goto free_clkdata; gate->reg = reg; gate->bit_idx = data->div[i].gate;
@@ -1106,10 +1102,8 @@ static struct clk ** __init sunxi_divs_clk_setup(struct device_node *node,return clks; free_gate:kfree (gate); -free_clks: -kfree (clks); free_clkdata: -kfree (clk_data); +clk_free_onecell_data (clk_data); out_unmap:iounmap (reg);return NULL ;
drivers/clk/sunxi/clk-usb.c +1 -7
@@ -118,16 +118,10 @@ static void __init sunxi_usb_clk_setup(struct device_node *node, qty =find_last_bit ((unsigned long *)&data->clk_mask,SUNXI_USB_MAX_SIZE ); - clk_data =kmalloc (sizeof (struct clk_onecell_data ),GFP_KERNEL ); + clk_data =clk_alloc_onecell_data (qty +1 );if (!clk_data)return ; - clk_data->clks =kzalloc ((qty+1 ) *sizeof (struct clk *),GFP_KERNEL ); -if (!clk_data->clks) { -kfree (clk_data); -return ; - } -for_each_set_bit (i, (unsigned long *)&data->clk_mask,SUNXI_USB_MAX_SIZE ) { of_property_read_string_index(node, "clock-output-names",
Signature · 1 line
2.7.4
Stephen Boyd
maintainerQuoting David Lechner (2018-01-04 16:38:05)
Quoted 6 lines
I am writing some clock drivers that use struct
clk_onecell_dataa few times, so I decided to write a helper function to allocate the memory since it is a two step process and can be tedious. Then I noticed that mediatek already had such a helper function, so I have moved that to the clk core and made use of it in other drivers where possible.
We're actively trying to discourage driver authors from adding more clk_onecell_data and pushing them to register clks and providers with the clk_hw structures. So thanks for doing the consolidation work, but no thanks. We can wait for the conversion to hw pointers instead.