22 Jun
2022
22 Jun
'22
3:10 p.m.
On Wed, 22 Jun 2022 10:40:20 +0200, Amadeusz Sławiński wrote:
+static int hda_cs_dsp_add_kcontrol(struct hda_cs_dsp_coeff_ctl *ctl) +{
- struct cs_dsp_coeff_ctl *cs_ctl = ctl->cs_ctl;
- struct snd_kcontrol_new *kcontrol;
- struct snd_kcontrol *kctl;
- int ret = 0;
- if (cs_ctl->len > ADSP_MAX_STD_CTRL_SIZE) {
dev_err(cs_ctl->dsp->dev, "Control %s: length %zu exceeds maximum %d\n", ctl->name,
cs_ctl->len, ADSP_MAX_STD_CTRL_SIZE);
return -EINVAL;
- }
- kcontrol = kzalloc(sizeof(*kcontrol), GFP_KERNEL);
- if (!kcontrol)
return -ENOMEM;
- kcontrol->name = ctl->name;
- kcontrol->info = hda_cs_dsp_coeff_info;
- kcontrol->iface = SNDRV_CTL_ELEM_IFACE_MIXER;
- kcontrol->private_value = (unsigned long)ctl;
- kcontrol->access = wmfw_convert_flags(cs_ctl->flags);
- kcontrol->get = hda_cs_dsp_coeff_get;
- kcontrol->put = hda_cs_dsp_coeff_put;
- kctl = snd_ctl_new1(kcontrol, NULL);
Wouldn't kctl = snd_ctl_new1(kcontrol, ctl); work instead of kcontrol->private_value = (unsigned long)ctl; ... kctl = snd_ctl_new1(kcontrol, NULL); ?
The second argument to snd_ctl_new1() is set to private_data field, while private_value is taken from snd_kcontrol_new template.
Takashi