Re: [PATCH v2 3/3] clk: qcom: camcc: Add camera clock controller driver for SC7180

From: Stephen Boyd
Date: Tue Oct 13 2020 - 21:59:16 EST


Quoting Taniya Das (2020-10-13 10:11:50)
> diff --git a/drivers/clk/qcom/camcc-sc7180.c b/drivers/clk/qcom/camcc-sc7180.c
> new file mode 100644
> index 0000000..e954d21
> --- /dev/null
> +++ b/drivers/clk/qcom/camcc-sc7180.c
> @@ -0,0 +1,1737 @@
[...]
> +
> +enum {
> + P_BI_TCXO,
> + P_CAM_CC_PLL0_OUT_EVEN,
> + P_CAM_CC_PLL1_OUT_EVEN,
> + P_CAM_CC_PLL2_OUT_AUX,
> + P_CAM_CC_PLL2_OUT_EARLY,
> + P_CAM_CC_PLL3_OUT_MAIN,
> + P_CORE_BI_PLL_TEST_SE,
> +};
> +
> +static struct pll_vco agera_vco[] = {

Can this be const?

> + { 600000000, 3300000000, 0 },
> +};
> +
> +static struct pll_vco fabia_vco[] = {

Can this be const?

> + { 249600000, 2000000000, 0 },
> +};
> +
[...]
> +
> +static int cam_cc_sc7180_probe(struct platform_device *pdev)
> +{
> + struct regmap *regmap;
> + int ret;
> +
> + pm_runtime_enable(&pdev->dev);
> + ret = pm_clk_create(&pdev->dev);
> + if (ret)
> + return ret;
> +
> + ret = pm_clk_add(&pdev->dev, "xo");
> + if (ret < 0) {
> + dev_err(&pdev->dev, "Failed to acquire XO clock\n");
> + goto disable_pm_runtime;
> + }
> +
> + ret = pm_clk_add(&pdev->dev, "iface");
> + if (ret < 0) {
> + dev_err(&pdev->dev, "Failed to acquire iface clock\n");
> + goto disable_pm_runtime;
> + }
> +
> + ret = pm_clk_runtime_resume(&pdev->dev);
> + if (ret) {
> + dev_err(&pdev->dev, "pm runtime resume failed\n");
> + goto destroy_pm_clk;
> + }
> +
> + regmap = qcom_cc_map(pdev, &cam_cc_sc7180_desc);
> + if (IS_ERR(regmap)) {
> + ret = PTR_ERR(regmap);
> + goto destroy_pm_clk;
> + }
> +
> + clk_fabia_pll_configure(&cam_cc_pll0, regmap, &cam_cc_pll0_config);
> + clk_fabia_pll_configure(&cam_cc_pll1, regmap, &cam_cc_pll1_config);
> + clk_agera_pll_configure(&cam_cc_pll2, regmap, &cam_cc_pll2_config);
> + clk_fabia_pll_configure(&cam_cc_pll3, regmap, &cam_cc_pll3_config);
> +
> + ret = qcom_cc_really_probe(pdev, &cam_cc_sc7180_desc, regmap);
> + if (ret) {
> + dev_err(&pdev->dev, "Failed to register CAM CC clocks\n");
> + goto suspend_pm_runtime;

ret is non-zero here

> + }
> +
> +suspend_pm_runtime:
> + ret = pm_clk_runtime_suspend(&pdev->dev);

But then it is overwritten here.

> + if (ret)
> + dev_err(&pdev->dev, "pm runtime suspend failed\n");
> +
> + return 0;

And we return 0 when there was a failure to probe the clks?

> +
> +destroy_pm_clk:
> + pm_clk_destroy(&pdev->dev);
> +
> +disable_pm_runtime:
> + pm_runtime_disable(&pdev->dev);
> +
> + return ret;
> +}