Commit 40a16442 authored by Amadeusz Sławiński's avatar Amadeusz Sławiński Committed by Mark Brown

ASoC: topology: Cleanup soc_tplg_dapm_widget_dmixer_create

Minor cleanups to increase readability.
Signed-off-by: default avatarAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://patch.msgid.link/20240627101850.2191513-6-amadeuszx.slawinski@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 52f4f727
...@@ -1094,43 +1094,37 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg, ...@@ -1094,43 +1094,37 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg,
static int soc_tplg_dapm_widget_dmixer_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) static int soc_tplg_dapm_widget_dmixer_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc)
{ {
struct soc_mixer_control *sm;
struct snd_soc_tplg_mixer_control *mc; struct snd_soc_tplg_mixer_control *mc;
struct soc_mixer_control *sm;
int err; int err;
mc = (struct snd_soc_tplg_mixer_control *)tplg->pos; mc = (struct snd_soc_tplg_mixer_control *)tplg->pos;
/* validate kcontrol */ /* validate kcontrol */
if (strnlen(mc->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == if (strnlen(mc->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == SNDRV_CTL_ELEM_ID_NAME_MAXLEN)
SNDRV_CTL_ELEM_ID_NAME_MAXLEN)
return -EINVAL; return -EINVAL;
sm = devm_kzalloc(tplg->dev, sizeof(*sm), GFP_KERNEL); sm = devm_kzalloc(tplg->dev, sizeof(*sm), GFP_KERNEL);
if (!sm) if (!sm)
return -ENOMEM; return -ENOMEM;
tplg->pos += sizeof(struct snd_soc_tplg_mixer_control) + tplg->pos += sizeof(struct snd_soc_tplg_mixer_control) + le32_to_cpu(mc->priv.size);
le32_to_cpu(mc->priv.size);
dev_dbg(tplg->dev, " adding DAPM widget mixer control %s\n", dev_dbg(tplg->dev, "ASoC: adding mixer kcontrol %s with access 0x%x\n",
mc->hdr.name); mc->hdr.name, mc->hdr.access);
kc->private_value = (long)sm;
kc->name = devm_kstrdup(tplg->dev, mc->hdr.name, GFP_KERNEL); kc->name = devm_kstrdup(tplg->dev, mc->hdr.name, GFP_KERNEL);
if (!kc->name) if (!kc->name)
return -ENOMEM; return -ENOMEM;
kc->private_value = (long)sm;
kc->iface = SNDRV_CTL_ELEM_IFACE_MIXER; kc->iface = SNDRV_CTL_ELEM_IFACE_MIXER;
kc->access = le32_to_cpu(mc->hdr.access); kc->access = le32_to_cpu(mc->hdr.access);
/* we only support FL/FR channel mapping atm */ /* we only support FL/FR channel mapping atm */
sm->reg = tplg_chan_get_reg(tplg, mc->channel, sm->reg = tplg_chan_get_reg(tplg, mc->channel, SNDRV_CHMAP_FL);
SNDRV_CHMAP_FL); sm->rreg = tplg_chan_get_reg(tplg, mc->channel, SNDRV_CHMAP_FR);
sm->rreg = tplg_chan_get_reg(tplg, mc->channel, sm->shift = tplg_chan_get_shift(tplg, mc->channel, SNDRV_CHMAP_FL);
SNDRV_CHMAP_FR); sm->rshift = tplg_chan_get_shift(tplg, mc->channel, SNDRV_CHMAP_FR);
sm->shift = tplg_chan_get_shift(tplg, mc->channel,
SNDRV_CHMAP_FL);
sm->rshift = tplg_chan_get_shift(tplg, mc->channel,
SNDRV_CHMAP_FR);
sm->max = le32_to_cpu(mc->max); sm->max = le32_to_cpu(mc->max);
sm->min = le32_to_cpu(mc->min); sm->min = le32_to_cpu(mc->min);
...@@ -1147,17 +1141,12 @@ static int soc_tplg_dapm_widget_dmixer_create(struct soc_tplg *tplg, struct snd_ ...@@ -1147,17 +1141,12 @@ static int soc_tplg_dapm_widget_dmixer_create(struct soc_tplg *tplg, struct snd_
/* create any TLV data */ /* create any TLV data */
err = soc_tplg_create_tlv(tplg, kc, &mc->hdr); err = soc_tplg_create_tlv(tplg, kc, &mc->hdr);
if (err < 0) { if (err < 0) {
dev_err(tplg->dev, "ASoC: failed to create TLV %s\n", dev_err(tplg->dev, "ASoC: failed to create TLV %s\n", mc->hdr.name);
mc->hdr.name);
return err; return err;
} }
/* pass control to driver for optional further init */ /* pass control to driver for optional further init */
err = soc_tplg_control_load(tplg, kc, &mc->hdr); return soc_tplg_control_load(tplg, kc, &mc->hdr);
if (err < 0)
return err;
return 0;
} }
static int soc_tplg_dapm_widget_denum_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) static int soc_tplg_dapm_widget_denum_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment