Merge remote-tracking branches 'asoc/fix/ak4642', 'asoc/fix/atmel', 'asoc/fix/cs4271...
[sfrench/cifs-2.6.git] / sound / soc / sh / rcar / core.c
index 1b53605f7154394d1746cb0a692953e296848c2a..31202e95be1ee6dc5fde83e44ce955347bc8109c 100644 (file)
@@ -149,16 +149,29 @@ char *rsnd_mod_dma_name(struct rsnd_mod *mod)
        return mod->ops->dma_name(mod);
 }
 
-void rsnd_mod_init(struct rsnd_mod *mod,
+int rsnd_mod_init(struct rsnd_mod *mod,
                   struct rsnd_mod_ops *ops,
                   struct clk *clk,
                   enum rsnd_mod_type type,
                   int id)
 {
+       int ret = clk_prepare(clk);
+
+       if (ret)
+               return ret;
+
        mod->id         = id;
        mod->ops        = ops;
        mod->type       = type;
        mod->clk        = clk;
+
+       return ret;
+}
+
+void rsnd_mod_quit(struct rsnd_mod *mod)
+{
+       if (mod->clk)
+               clk_unprepare(mod->clk);
 }
 
 /*
@@ -1252,6 +1265,8 @@ static int rsnd_probe(struct platform_device *pdev)
                        goto exit_snd_probe;
        }
 
+       dev_set_drvdata(dev, priv);
+
        /*
         *      asoc register
         */
@@ -1268,8 +1283,6 @@ static int rsnd_probe(struct platform_device *pdev)
                goto exit_snd_soc;
        }
 
-       dev_set_drvdata(dev, priv);
-
        pm_runtime_enable(dev);
 
        dev_info(dev, "probed\n");
@@ -1290,6 +1303,12 @@ static int rsnd_remove(struct platform_device *pdev)
 {
        struct rsnd_priv *priv = dev_get_drvdata(&pdev->dev);
        struct rsnd_dai *rdai;
+       void (*remove_func[])(struct platform_device *pdev,
+                             struct rsnd_priv *priv) = {
+               rsnd_ssi_remove,
+               rsnd_src_remove,
+               rsnd_dvc_remove,
+       };
        int ret = 0, i;
 
        pm_runtime_disable(&pdev->dev);
@@ -1299,6 +1318,9 @@ static int rsnd_remove(struct platform_device *pdev)
                ret |= rsnd_dai_call(remove, &rdai->capture, priv);
        }
 
+       for (i = 0; i < ARRAY_SIZE(remove_func); i++)
+               remove_func[i](pdev, priv);
+
        snd_soc_unregister_component(&pdev->dev);
        snd_soc_unregister_platform(&pdev->dev);