Skip to content

Commit 9c698e8

Browse files
morimotobroonie
authored andcommitted
ASoC: rsnd: tidyup registering method for rsnd_kctrl_new()
Current rsnd dvc.c is using flags to avoid duplicating register for MIXer case. OTOH, commit e894efe ("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 b918f1b ("ASoC: rsnd: DVC kctrl sets once") Reported-by: Nguyen Viet Dung <[email protected]> Signed-off-by: Kuninori Morimoto <[email protected]> Tested-by: Nguyen Viet Dung <[email protected]> Cc: Hiroyuki Yokoyama <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent ffdcc36 commit 9c698e8

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

sound/soc/sh/rcar/core.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,18 @@ int rsnd_kctrl_new(struct rsnd_mod *mod,
13391339
};
13401340
int ret;
13411341

1342+
/*
1343+
* 1) Avoid duplicate register (ex. MIXer case)
1344+
* 2) re-register if card was rebinded
1345+
*/
1346+
list_for_each_entry(kctrl, &card->controls, list) {
1347+
struct rsnd_kctrl_cfg *c = kctrl->private_data;
1348+
1349+
if (strcmp(kctrl->id.name, name) == 0 &&
1350+
c->mod == mod)
1351+
return 0;
1352+
}
1353+
13421354
if (size > RSND_MAX_CHANNELS)
13431355
return -EINVAL;
13441356

sound/soc/sh/rcar/dvc.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,8 @@ struct rsnd_dvc {
4040
struct rsnd_kctrl_cfg_s ren; /* Ramp Enable */
4141
struct rsnd_kctrl_cfg_s rup; /* Ramp Rate Up */
4242
struct rsnd_kctrl_cfg_s rdown; /* Ramp Rate Down */
43-
u32 flags;
4443
};
4544

46-
#define KCTRL_INITIALIZED (1 << 0)
47-
4845
#define rsnd_dvc_get(priv, id) ((struct rsnd_dvc *)(priv->dvc) + id)
4946
#define rsnd_dvc_nr(priv) ((priv)->dvc_nr)
5047

@@ -227,9 +224,6 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
227224
int channels = rsnd_rdai_channels_get(rdai);
228225
int ret;
229226

230-
if (rsnd_flags_has(dvc, KCTRL_INITIALIZED))
231-
return 0;
232-
233227
/* Volume */
234228
ret = rsnd_kctrl_new_m(mod, io, rtd,
235229
is_play ?
@@ -285,8 +279,6 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
285279
if (ret < 0)
286280
return ret;
287281

288-
rsnd_flags_set(dvc, KCTRL_INITIALIZED);
289-
290282
return 0;
291283
}
292284

0 commit comments

Comments
 (0)