ASoC: rsnd: call missing snd_ctl_remove()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Mon, 2 Feb 2015 04:53:53 +0000 (04:53 +0000)
committerMark Brown <broonie@kernel.org>
Mon, 2 Feb 2015 18:37:56 +0000 (18:37 +0000)
Current Renesas R-Car sound driver is using snd_ctl_xxx()
functions, but it didn't call snd_ctl free_one() / snd_ctl_remove().
This patch call these functions.

Reported-by: Nguyen Viet Dung <nv-dung@jinso.co.jp>
Reported-by: Bui Duc Phuc <bd-phuc@jinso.co.jp>
Reported-by: Cao Minh Hiep <cm-hiep@jinso.co.jp>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sh/rcar/core.c
sound/soc/sh/rcar/dvc.c
sound/soc/sh/rcar/rsnd.h

index f0bb137da31b1636fd667593c1b036fa4afef88b..6fb38b879bb65fd6171871dfe84f0326f132f0a9 100644 (file)
@@ -1046,14 +1046,23 @@ static int __rsnd_kctrl_new(struct rsnd_mod *mod,
                return -ENOMEM;
 
        ret = snd_ctl_add(card, kctrl);
-       if (ret < 0)
+       if (ret < 0) {
+               snd_ctl_free_one(kctrl);
                return ret;
+       }
 
        cfg->update = update;
+       cfg->card = card;
+       cfg->kctrl = kctrl;
 
        return 0;
 }
 
+void _rsnd_kctrl_remove(struct rsnd_kctrl_cfg *cfg)
+{
+       snd_ctl_remove(cfg->card, cfg->kctrl);
+}
+
 int rsnd_kctrl_new_m(struct rsnd_mod *mod,
                     struct snd_soc_pcm_runtime *rtd,
                     const unsigned char *name,
index 38a5f334a6a75d78762322d71e7f3dbc1d7f08cf..d7f9ed959c4e208a8126174f76daee5a79af133f 100644 (file)
@@ -127,6 +127,20 @@ static int rsnd_dvc_probe_gen2(struct rsnd_mod *mod,
        return 0;
 }
 
+static int rsnd_dvc_remove_gen2(struct rsnd_mod *mod,
+                               struct rsnd_priv *priv)
+{
+       struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
+
+       rsnd_kctrl_remove(dvc->volume);
+       rsnd_kctrl_remove(dvc->mute);
+       rsnd_kctrl_remove(dvc->ren);
+       rsnd_kctrl_remove(dvc->rup);
+       rsnd_kctrl_remove(dvc->rdown);
+
+       return 0;
+}
+
 static int rsnd_dvc_init(struct rsnd_mod *dvc_mod,
                         struct rsnd_priv *priv)
 {
@@ -258,6 +272,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
 static struct rsnd_mod_ops rsnd_dvc_ops = {
        .name           = DVC_NAME,
        .probe          = rsnd_dvc_probe_gen2,
+       .remove         = rsnd_dvc_remove_gen2,
        .init           = rsnd_dvc_init,
        .quit           = rsnd_dvc_quit,
        .start          = rsnd_dvc_start,
index b57d8ace012a777e11b1c12c54714a583ea0890c..e7914bd610e2120644f616e6500bdf3ad9ec24d3 100644 (file)
@@ -436,6 +436,8 @@ struct rsnd_kctrl_cfg {
        u32 *val;
        const char * const *texts;
        void (*update)(struct rsnd_mod *mod);
+       struct snd_card *card;
+       struct snd_kcontrol *kctrl;
 };
 
 #define RSND_DVC_CHANNELS      2
@@ -449,6 +451,9 @@ struct rsnd_kctrl_cfg_s {
        u32 val;
 };
 
+void _rsnd_kctrl_remove(struct rsnd_kctrl_cfg *cfg);
+#define rsnd_kctrl_remove(_cfg)        _rsnd_kctrl_remove(&((_cfg).cfg))
+
 int rsnd_kctrl_new_m(struct rsnd_mod *mod,
                     struct snd_soc_pcm_runtime *rtd,
                     const unsigned char *name,