From 8a21ff1c8a07ccb8ef6cb353891f133da7949168 Mon Sep 17 00:00:00 2001 From: Deepak Katragadda Date: Mon, 28 Aug 2017 13:14:34 -0700 Subject: [PATCH] clk: qcom: clk-aop-qmp: Fix issue with registering the clock provider While registering the QDSS clock provider with the framework, pass in the clk data array with references to both the QDSS clocks. In its current implementation, the QDSS clock driver only adds the clk_get callback for one of the clocks which leads to clients getting the clock handle to it when they try to reference either of the clocks. Change-Id: I41fc4c1ea57ad0f59a1af126b6025c21af72cbe2 Signed-off-by: Deepak Katragadda --- drivers/clk/qcom/clk-aop-qmp.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/clk/qcom/clk-aop-qmp.c b/drivers/clk/qcom/clk-aop-qmp.c index 903ef9e171dd..3884fd1913a8 100644 --- a/drivers/clk/qcom/clk-aop-qmp.c +++ b/drivers/clk/qcom/clk-aop-qmp.c @@ -256,6 +256,7 @@ static int aop_qmp_clk_probe(struct platform_device *pdev) struct clk *clk = NULL; struct device_node *np = pdev->dev.of_node; struct mbox_chan *mbox = NULL; + struct clk_onecell_data *clk_data; int num_clks = ARRAY_SIZE(aop_qmp_clk_hws); int ret = 0, i = 0; @@ -267,6 +268,17 @@ static int aop_qmp_clk_probe(struct platform_device *pdev) if (ret < 0) return ret; + clk_data = devm_kzalloc(&pdev->dev, sizeof(*clk_data), GFP_KERNEL); + if (!clk_data) + return -ENOMEM; + + clk_data->clks = devm_kcalloc(&pdev->dev, num_clks, + sizeof(*clk_data->clks), GFP_KERNEL); + if (!clk_data->clks) + return -ENOMEM; + + clk_data->clk_num = num_clks; + for (i = 1; i < num_clks; i++) { if (!aop_qmp_clk_hws[i]) continue; @@ -289,14 +301,16 @@ static int aop_qmp_clk_probe(struct platform_device *pdev) for (i = 0; i < num_clks; i++) { if (!aop_qmp_clk_hws[i]) continue; + clk = devm_clk_register(&pdev->dev, aop_qmp_clk_hws[i]); if (IS_ERR(clk)) { ret = PTR_ERR(clk); goto fail; } + clk_data->clks[i] = clk; } - ret = of_clk_add_provider(np, of_clk_src_simple_get, clk); + ret = of_clk_add_provider(np, of_clk_src_onecell_get, clk_data); if (ret) { dev_err(&pdev->dev, "Failed to register clock provider\n"); goto fail;