[PATCH 6.7 057/162] ASoC: cs35l56: Fix misuse of wm_adsp part string for silicon revision

Greg Kroah-Hartman
2024-03-04T21:28:23Z

From: Richard Fitzgerald <rf@opensource.cirrus.com>

[ Upstream commit f6c967941c5d6fa526fdd64733a8d86bf2bfab31 ]

Put the silicon revision and secured flag in the wm_adsp fwf_name
string instead of including them in the part string.

This changes the format of the firmware name string from

cs35l56[s]-rev-misc[-system_name]

to
cs35l56-rev[-s]-misc[-system_name]

No firmware files have been published, so this doesn't cause a
compatibility break.

Silicon revision and secured flag are included in the firmware
filename to pick a firmware compatible with the part. These strings
were being added to the part string, but that is a misuse of the
string. The correct place for these is the fwf_name string, which
is specifically intended to select between multiple firmware files
for the same part.

Backport note:
This won't apply to kernels older than v6.6.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 608f1b0dbdde ("ASoC: cs35l56: Move DSP part string generation so that it is done only once")
Link: https://msgid.link/r/20240129162737.497-12-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Stable-dep-of: eba2eb2495f4 ("ASoC: soc-card: Fix missing locking in snd_soc_card_get_kcontrol()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/soc/codecs/cs35l56.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c
index 30f4b9e9cc94c..f05fab577f037 100644
--- a/sound/soc/codecs/cs35l56.c
+++ b/sound/soc/codecs/cs35l56.c
@@ -886,6 +886,18 @@ static void cs35l56_dsp_work(struct work_struct *work)

pm_runtime_get_sync(cs35l56->base.dev);

+ /* Populate fw file qualifier with the revision and security state */
+ if (!cs35l56->dsp.fwf_name) {
+ cs35l56->dsp.fwf_name = kasprintf(GFP_KERNEL, "%02x%s-dsp1",
+ cs35l56->base.rev,
+ cs35l56->base.secured ? "-s" : "");
+ if (!cs35l56->dsp.fwf_name)
+ goto err;
+ }
+
+ dev_dbg(cs35l56->base.dev, "DSP fwf name: '%s' system name: '%s'\n",
+ cs35l56->dsp.fwf_name, cs35l56->dsp.system_name);
+
/*
* When the device is running in secure mode the firmware files can
* only contain insecure tunings and therefore we do not need to
@@ -905,7 +917,7 @@ static void cs35l56_dsp_work(struct work_struct *work)
* on the DAPM mutex.
*/
queue_work(cs35l56->dsp_wq, &cs35l56->mux_init_work);
-
+err:
pm_runtime_mark_last_busy(cs35l56->base.dev);
pm_runtime_put_autosuspend(cs35l56->base.dev);
}
@@ -958,6 +970,9 @@ static void cs35l56_component_remove(struct snd_soc_component *component)

wm_adsp2_component_remove(&cs35l56->dsp, component);

+ kfree(cs35l56->dsp.fwf_name);
+ cs35l56->dsp.fwf_name = NULL;
+
cs35l56->component = NULL;
}

@@ -1309,12 +1324,6 @@ int cs35l56_init(struct cs35l56_private *cs35l56)
if (ret)
return ret;

- /* Populate the DSP information with the revision and security state */
- cs35l56->dsp.part = devm_kasprintf(cs35l56->base.dev, GFP_KERNEL, "cs35l56%s-%02x",
- cs35l56->base.secured ? "s" : "", cs35l56->base.rev);
- if (!cs35l56->dsp.part)
- return -ENOMEM;
-
if (!cs35l56->base.reset_gpio) {
dev_dbg(cs35l56->base.dev, "No reset gpio: using soft reset\n");
cs35l56->soft_resetting = true;
--
2.43.0