mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 16:53:20 -04:00
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
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user