30 Jun
2022
30 Jun
'22
12:37 p.m.
On Thu, Jun 30, 2022 at 01:39:11PM +0800, Shengjiu Wang wrote:
+static int fsl_micfil_reparent_rootclk(struct fsl_micfil *micfil, unsigned int sample_rate) +{
- struct device *dev = &micfil->pdev->dev;
- u64 ratio = sample_rate;
- struct clk *clk;
- int ret;
- /* Reparent clock if required condition is true */
- if (!micfil->pll8k_clk || !micfil->pll11k_clk)
return 0;
- ratio = do_div(ratio, 8000) ? CLK_11K_FREQ : CLK_8K_FREQ;
- /* Get root clock */
- clk = micfil->mclk;
- if (IS_ERR_OR_NULL(clk)) {
dev_err(dev, "no mclk clock in devicetree\n");
return PTR_ERR(clk);
- }
- /* Disable clock first, for it was enabled by pm_runtime */
- clk_disable_unprepare(clk);
- fsl_asoc_reparent_pll_clocks(dev, clk, micfil->pll8k_clk,
micfil->pll11k_clk, ratio);
- ret = clk_prepare_enable(clk);
- if (ret)
return ret;
- return 0;
+}
Seems like more of this logic could be factored out into the reparent function if the target sample rate is passed in?