]> git.hungrycats.org Git - linux/commitdiff
ALSA: hda: cs35l56: Fix lifecycle of codec pointer
authorSimon Trimmer <simont@opensource.cirrus.com>
Fri, 31 May 2024 11:27:16 +0000 (12:27 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jul 2024 07:53:28 +0000 (09:53 +0200)
[ Upstream commit d339131bf02d4ed918415574082caf5e8af6e664 ]

The codec should be cleared when the amp driver is unbound and when
resuming it should be tested to prevent loading firmware into the device
and ALSA in a partially configured system state.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20240531112716.25323-1-simont@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/pci/hda/cs35l56_hda.c

index 6b77c38a0e15502958ababc71472dd6ed8f30c3c..e134ede6c5aa54d98454467222c863005533801c 100644 (file)
@@ -735,6 +735,8 @@ static void cs35l56_hda_unbind(struct device *dev, struct device *master, void *
        if (comps[cs35l56->index].dev == dev)
                memset(&comps[cs35l56->index], 0, sizeof(*comps));
 
+       cs35l56->codec = NULL;
+
        dev_dbg(cs35l56->base.dev, "Unbound\n");
 }
 
@@ -840,6 +842,9 @@ static int cs35l56_hda_system_resume(struct device *dev)
 
        cs35l56->suspended = false;
 
+       if (!cs35l56->codec)
+               return 0;
+
        ret = cs35l56_is_fw_reload_needed(&cs35l56->base);
        dev_dbg(cs35l56->base.dev, "fw_reload_needed: %d\n", ret);
        if (ret > 0) {