Skip to content

Commit 8fc5c78

Browse files
rfvirgilbroonie
authored andcommitted
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>
1 parent 7bca3ca commit 8fc5c78

1 file changed

Lines changed: 22 additions & 27 deletions

File tree

sound/soc/codecs/wm_adsp.c

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -804,58 +804,53 @@ VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
804804
{
805805
const char *system_name = dsp->system_name;
806806
const char *suffix = dsp->component->name_prefix;
807+
bool require_bin_suffix = false;
807808
int ret = 0;
808809

809810
if (dsp->fwf_suffix)
810811
suffix = dsp->fwf_suffix;
811812

812-
if (system_name && suffix) {
813+
if (system_name) {
813814
ret = wm_adsp_request_firmware_file(dsp, &fw->wmfw,
814815
cirrus_dir, system_name,
815816
suffix, "wmfw");
816817
if (ret < 0)
817818
goto err;
818819

819-
if (fw->wmfw.firmware) {
820+
if (suffix) {
821+
if (fw->wmfw.firmware) {
822+
require_bin_suffix = true;
823+
} else {
824+
/* Fallback to name without suffix */
825+
ret = wm_adsp_request_firmware_file(dsp, &fw->wmfw,
826+
cirrus_dir, system_name,
827+
NULL, "wmfw");
828+
if (ret < 0)
829+
goto err;
830+
}
831+
}
832+
833+
/* Look for matching .bin file */
834+
if (fw->wmfw.firmware || dsp->wmfw_optional) {
820835
ret = wm_adsp_request_firmware_file(dsp, &fw->coeff,
821836
cirrus_dir, system_name,
822837
suffix, "bin");
823838
if (ret < 0)
824839
goto err;
825840

826-
return 0;
827-
}
828-
}
829-
830-
if (system_name) {
831-
ret = wm_adsp_request_firmware_file(dsp, &fw->wmfw,
832-
cirrus_dir, system_name,
833-
NULL, "wmfw");
834-
if (ret < 0)
835-
goto err;
836-
837-
if (fw->wmfw.firmware || dsp->wmfw_optional) {
838-
if (suffix) {
839-
ret = wm_adsp_request_firmware_file(dsp,
840-
&fw->coeff,
841-
cirrus_dir, system_name,
842-
suffix, "bin");
843-
if (ret < 0)
844-
goto err;
845-
}
846-
847-
if (!fw->coeff.firmware) {
841+
if (suffix && !fw->coeff.firmware && !require_bin_suffix) {
842+
/* Fallback to name without suffix */
848843
ret = wm_adsp_request_firmware_file(dsp,
849844
&fw->coeff,
850845
cirrus_dir, system_name,
851846
NULL, "bin");
852847
if (ret < 0)
853848
goto err;
854849
}
855-
856-
if (fw->wmfw.firmware || (dsp->wmfw_optional && fw->coeff.firmware))
857-
return 0;
858850
}
851+
852+
if (fw->wmfw.firmware || (dsp->wmfw_optional && fw->coeff.firmware))
853+
return 0;
859854
}
860855

861856
/* Check legacy location */

0 commit comments

Comments
 (0)