diff mbox series

[2/9] ALSA: hda: hda_cs_dsp_ctl: Only call notify when a control has been added to a card

Message ID 20240221150507.1039979-3-rf@opensource.cirrus.com (mailing list archive)
State Superseded
Headers show
Series ALSA: cs35l56: Apply calibration from EFI | expand

Commit Message

Richard Fitzgerald Feb. 21, 2024, 3:05 p.m. UTC
From: Simon Trimmer <simont@opensource.cirrus.com>

There is a window of time where the cs_dsp_coeff_ctl has been created
but has not been registered as a control with ALSA.

The hda_cs_dsp_write_ctl() helper function can be used update the cs_dsp
coefficient before it has been registered, but it should only call
snd_ctl_notify() once the control is associated with a card.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: e414b05e724f ("ALSA: hda: hda_cs_dsp_ctl: Add apis to write the controls directly")
---
 sound/pci/hda/hda_cs_dsp_ctl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/sound/pci/hda/hda_cs_dsp_ctl.c b/sound/pci/hda/hda_cs_dsp_ctl.c
index 463ca06036bf..0f5fdd44721c 100644
--- a/sound/pci/hda/hda_cs_dsp_ctl.c
+++ b/sound/pci/hda/hda_cs_dsp_ctl.c
@@ -224,9 +224,10 @@  int hda_cs_dsp_write_ctl(struct cs_dsp *dsp, const char *name, int type,
 	if (ret == 0 || (cs_ctl->flags & WMFW_CTL_FLAG_SYS))
 		return 0;
 
+	/* Notify when a control has been added to a card */
 	ctl = cs_ctl->priv;
-
-	snd_ctl_notify(ctl->card, SNDRV_CTL_EVENT_MASK_VALUE, &ctl->kctl->id);
+	if (ctl && ctl->kctl)
+		snd_ctl_notify(ctl->card, SNDRV_CTL_EVENT_MASK_VALUE, &ctl->kctl->id);
 
 	return 0;
 }