28 Jan
2011
28 Jan
'11
9:45 a.m.
<<snip>>
+static int omap_dmic_set_dai_sysclk(struct snd_soc_dai *dai,
- int clk_id, unsigned int freq,
- int dir)
+{
- struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai);
- struct clk *dmic_clk, *parent_clk;
- int ret = 0;
- dmic_clk = clk_get(NULL, "dmic_fck");
It is preferred to use device pointer. instead of NULL. (Applicable elsewhere)
- if (IS_ERR(dmic_clk))
- return -ENODEV;
- switch (clk_id) {
- case OMAP_DMIC_SYSCLK_PAD_CLKS:
- parent_clk = clk_get(NULL, "pad_clks_ck");
- if (IS_ERR(parent_clk)) {
- ret = -ENODEV;
- goto err_par;
- }
- break;
- case OMAP_DMIC_SYSCLK_SLIMBLUS_CLKS:
- parent_clk = clk_get(NULL, "slimbus_clk");
- if (IS_ERR(parent_clk)) {
- ret = -ENODEV;
- goto err_par;
- }
- break;
- case OMAP_DMIC_SYSCLK_SYNC_MUX_CLKS:
- parent_clk = clk_get(NULL, "dmic_sync_mux_ck");
- if (IS_ERR(parent_clk)) {
- ret = -ENODEV;
- goto err_par;
- }
- break;
- default:
- dev_err(dai->dev, "clk_id not supported %d\n", clk_id);
- ret = -EINVAL;
- goto err_par;
- }
- if (dmic->sysclk != clk_id) {
- /* reparent not allowed if a stream is ongoing */
- if (dmic->active > 1) {
- ret = -EBUSY;
- goto err_busy;
- }
- /* disable clock while reparenting */
- if (dmic->active == 1)
- pm_runtime_put_sync(dmic->dev);
- ret = clk_set_parent(dmic_clk, parent_clk);
- if (dmic->active == 1)
- pm_runtime_get_sync(dmic->dev);
- dmic->sysclk = clk_id;
- }
- dmic->clk_freq = clk_get_rate(dmic_clk);
+err_busy:
- clk_put(parent_clk);
+err_par:
- clk_put(dmic_clk);
- return ret;
+}
<<snip>>