]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
ASoC: rsnd: tidyup registering method for rsnd_kctrl_new()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tue, 27 Nov 2018 07:35:34 +0000 (07:35 +0000)
committerMark Brown <broonie@kernel.org>
Wed, 28 Nov 2018 09:56:45 +0000 (09:56 +0000)
Current rsnd dvc.c is using flags to avoid duplicating register for
MIXer case. OTOH, commit e894efef9ac7 ("ASoC: core: add support to card
rebind") allows to rebind sound card without rebinding all drivers.

Because of above patch and dvc.c flags, it can't re-register kctrl if
only sound card was rebinded, because dvc is keeping old flags.
(Of course it will be no problem if rsnd driver also be rebinded,
but it is not purpose of above patch).

This patch checks current card registered kctrl when registering.
In MIXer case, it can avoid duplicate register if card already has same
kctrl. In rebind case, it can re-register kctrl because card registered
kctl had been removed when unbinding.

This patch is updated version of commit b918f1bc7f1ce ("ASoC: rsnd: DVC
kctrl sets once")

Reported-by: Nguyen Viet Dung <dung.nguyen.aj@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Nguyen Viet Dung <dung.nguyen.aj@renesas.com>
Cc: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sh/rcar/core.c
sound/soc/sh/rcar/dvc.c

index f930f51b686fc95fd78c973576548582b67bb5aa..114f8f233764a065fa49c64e1ed636a42cb3d806 100644 (file)
@@ -1339,6 +1339,18 @@ int rsnd_kctrl_new(struct rsnd_mod *mod,
        };
        int ret;
 
+       /*
+        * 1) Avoid duplicate register (ex. MIXer case)
+        * 2) re-register if card was rebinded
+        */
+       list_for_each_entry(kctrl, &card->controls, list) {
+               struct rsnd_kctrl_cfg *c = kctrl->private_data;
+
+               if (strcmp(kctrl->id.name, name) == 0 &&
+                   c->mod == mod)
+                       return 0;
+       }
+
        if (size > RSND_MAX_CHANNELS)
                return -EINVAL;
 
index 2b16e0ce6bc5374aff6e3bc0ade4a3faed6a3087..024ece46bf685afe381a8594b04e6e48c03f7616 100644 (file)
@@ -40,11 +40,8 @@ struct rsnd_dvc {
        struct rsnd_kctrl_cfg_s ren;    /* Ramp Enable */
        struct rsnd_kctrl_cfg_s rup;    /* Ramp Rate Up */
        struct rsnd_kctrl_cfg_s rdown;  /* Ramp Rate Down */
-       u32 flags;
 };
 
-#define KCTRL_INITIALIZED      (1 << 0)
-
 #define rsnd_dvc_get(priv, id) ((struct rsnd_dvc *)(priv->dvc) + id)
 #define rsnd_dvc_nr(priv) ((priv)->dvc_nr)
 
@@ -227,9 +224,6 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
        int channels = rsnd_rdai_channels_get(rdai);
        int ret;
 
-       if (rsnd_flags_has(dvc, KCTRL_INITIALIZED))
-               return 0;
-
        /* Volume */
        ret = rsnd_kctrl_new_m(mod, io, rtd,
                        is_play ?
@@ -285,8 +279,6 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
        if (ret < 0)
                return ret;
 
-       rsnd_flags_set(dvc, KCTRL_INITIALIZED);
-
        return 0;
 }