diff options
| author | Takashi Iwai <tiwai@suse.de> | 2026-07-29 10:37:24 +0200 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2026-07-31 12:44:36 +0200 |
| commit | 185841c94accce919607e9e4ea59baf3ddec6b99 (patch) | |
| tree | c3baa710e390eee57eb60a529830560033c76544 | |
| parent | 81d3f401548921eeca98efa98248144d18672146 (diff) | |
| download | linux-next-185841c94accce919607e9e4ea59baf3ddec6b99.tar.gz linux-next-185841c94accce919607e9e4ea59baf3ddec6b99.zip | |
ALSA: hda: cs35l56: Use auto-cleanup for firmware loading
Simplify the code to manage the firmware loading with auto-cleanup.
By the use of __free(firmware), we can replace the manual mutex locks
with guard() gracefully, too.
Only the code refactoring, no functional changes.
Cc: patches@opensource.cirrus.com
Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20260729083735.120219-7-tiwai@suse.de
| -rw-r--r-- | sound/hda/codecs/side-codecs/cs35l56_hda.c | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/sound/hda/codecs/side-codecs/cs35l56_hda.c b/sound/hda/codecs/side-codecs/cs35l56_hda.c index 78c2cf387a00..bc207ab5b020 100644 --- a/sound/hda/codecs/side-codecs/cs35l56_hda.c +++ b/sound/hda/codecs/side-codecs/cs35l56_hda.c @@ -527,18 +527,6 @@ static void cs35l56_hda_request_firmware_files(struct cs35l56_hda *cs35l56, base_name, NULL, NULL, "bin"); } -static void cs35l56_hda_release_firmware_files(const struct firmware *wmfw_firmware, - char *wmfw_filename, - const struct firmware *coeff_firmware, - char *coeff_filename) -{ - release_firmware(wmfw_firmware); - kfree(wmfw_filename); - - release_firmware(coeff_firmware); - kfree(coeff_filename); -} - static int cs35l56_hda_apply_calibration(struct cs35l56_hda *cs35l56) { int ret; @@ -561,10 +549,10 @@ static int cs35l56_hda_apply_calibration(struct cs35l56_hda *cs35l56) static void cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) { - const struct firmware *coeff_firmware = NULL; - const struct firmware *wmfw_firmware = NULL; - char *coeff_filename = NULL; - char *wmfw_filename = NULL; + const struct firmware *coeff_firmware __free(firmware) = NULL; + const struct firmware *wmfw_firmware __free(firmware) = NULL; + char *coeff_filename __free(kfree) = NULL; + char *wmfw_filename __free(kfree) = NULL; unsigned int preloaded_fw_ver; bool firmware_missing; int ret; @@ -606,14 +594,14 @@ static void cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) if (firmware_missing) { if (!wmfw_firmware) { dev_err(cs35l56->base.dev, ".%s file required but not found\n", "wmfw"); - goto err_fw_release; + return; } else if (!coeff_firmware) { dev_err(cs35l56->base.dev, ".%s file required but not found\n", "bin"); - goto err_fw_release; + return; } } - mutex_lock(&cs35l56->base.irq_lock); + guard(mutex)(&cs35l56->base.irq_lock); /* * If the firmware hasn't been patched it must be shutdown before @@ -624,14 +612,14 @@ static void cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) if (firmware_missing && (wmfw_firmware || coeff_firmware)) { ret = cs35l56_firmware_shutdown(&cs35l56->base); if (ret) - goto err; + return; } ret = cs_dsp_power_up(&cs35l56->cs_dsp, wmfw_firmware, wmfw_filename, coeff_firmware, coeff_filename, "misc"); if (ret) { dev_dbg(cs35l56->base.dev, "%s: cs_dsp_power_up ret %d\n", __func__, ret); - goto err; + return; } if (wmfw_filename) @@ -679,11 +667,6 @@ static void cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) err_powered_up: if (!cs35l56->base.fw_patched) cs_dsp_power_down(&cs35l56->cs_dsp); -err: - mutex_unlock(&cs35l56->base.irq_lock); -err_fw_release: - cs35l56_hda_release_firmware_files(wmfw_firmware, wmfw_filename, - coeff_firmware, coeff_filename); } static void cs35l56_hda_dsp_work(struct work_struct *work) |
