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 <dkatraga@codeaurora.org>
This commit is contained in:
Deepak Katragadda 2017-08-28 13:14:34 -07:00 • committed by David Collins
commit 8a21ff1c8a

View file

@ -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;