summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Fitzgerald <rf@opensource.cirrus.com>2026-03-10 17:18:17 +0300
committerMark Brown <broonie@kernel.org>2026-03-10 17:52:57 +0300
commit8fc5c7895185d1119ae76b509892a1d14e0bd483 (patch)
treeea380ce7c84a93ffab5456b1773fea40ec54b6d2
parent7bca3ca55ef53ca66fdf6e663290d0596a8f520d (diff)
downloadlinux-8fc5c7895185d1119ae76b509892a1d14e0bd483.tar.xz
ASoC: wm_adsp: Combine some similar code in firmware file search
In wm_adsp_request_firmware_files() squash the if (system_name && suffix) and the following if (system_name) blocks together. This removes some duplicated code. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20260310141817.1871794-11-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/wm_adsp.c49
1 files changed, 22 insertions, 27 deletions
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index bcc77797c09a..a5fa0db250f2 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -804,47 +804,42 @@ VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
{
const char *system_name = dsp->system_name;
const char *suffix = dsp->component->name_prefix;
+ bool require_bin_suffix = false;
int ret = 0;
if (dsp->fwf_suffix)
suffix = dsp->fwf_suffix;
- if (system_name && suffix) {
+ if (system_name) {
ret = wm_adsp_request_firmware_file(dsp, &fw->wmfw,
cirrus_dir, system_name,
suffix, "wmfw");
if (ret < 0)
goto err;
- if (fw->wmfw.firmware) {
+ if (suffix) {
+ if (fw->wmfw.firmware) {
+ require_bin_suffix = true;
+ } else {
+ /* Fallback to name without suffix */
+ ret = wm_adsp_request_firmware_file(dsp, &fw->wmfw,
+ cirrus_dir, system_name,
+ NULL, "wmfw");
+ if (ret < 0)
+ goto err;
+ }
+ }
+
+ /* Look for matching .bin file */
+ if (fw->wmfw.firmware || dsp->wmfw_optional) {
ret = wm_adsp_request_firmware_file(dsp, &fw->coeff,
cirrus_dir, system_name,
suffix, "bin");
if (ret < 0)
goto err;
- return 0;
- }
- }
-
- if (system_name) {
- ret = wm_adsp_request_firmware_file(dsp, &fw->wmfw,
- cirrus_dir, system_name,
- NULL, "wmfw");
- if (ret < 0)
- goto err;
-
- if (fw->wmfw.firmware || dsp->wmfw_optional) {
- if (suffix) {
- ret = wm_adsp_request_firmware_file(dsp,
- &fw->coeff,
- cirrus_dir, system_name,
- suffix, "bin");
- if (ret < 0)
- goto err;
- }
-
- if (!fw->coeff.firmware) {
+ if (suffix && !fw->coeff.firmware && !require_bin_suffix) {
+ /* Fallback to name without suffix */
ret = wm_adsp_request_firmware_file(dsp,
&fw->coeff,
cirrus_dir, system_name,
@@ -852,10 +847,10 @@ VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
if (ret < 0)
goto err;
}
-
- if (fw->wmfw.firmware || (dsp->wmfw_optional && fw->coeff.firmware))
- return 0;
}
+
+ if (fw->wmfw.firmware || (dsp->wmfw_optional && fw->coeff.firmware))
+ return 0;
}
/* Check legacy location */