Commit 448425f0 authored by Stefan Binding's avatar Stefan Binding Committed by Takashi Iwai

ALSA: hda: cs35l41: Clean up Firmware Load Controls

Ensure Firmware Load control and Firmware Type control
returns 1 when the value changes.

Remove fw_mutex from firmware load control put, since it is
unnecessary, and prevents any possibility of mutex inversion.
Signed-off-by: default avatarStefan Binding <sbinding@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230606103436.455348-2-sbinding@opensource.cirrus.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 1a764994
...@@ -835,34 +835,26 @@ static int cs35l41_fw_load_ctl_put(struct snd_kcontrol *kcontrol, ...@@ -835,34 +835,26 @@ static int cs35l41_fw_load_ctl_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct cs35l41_hda *cs35l41 = snd_kcontrol_chip(kcontrol); struct cs35l41_hda *cs35l41 = snd_kcontrol_chip(kcontrol);
unsigned int ret = 0;
mutex_lock(&cs35l41->fw_mutex);
if (cs35l41->request_fw_load == ucontrol->value.integer.value[0]) if (cs35l41->request_fw_load == ucontrol->value.integer.value[0])
goto err; return 0;
if (cs35l41->fw_request_ongoing) { if (cs35l41->fw_request_ongoing) {
dev_dbg(cs35l41->dev, "Existing request not complete\n"); dev_dbg(cs35l41->dev, "Existing request not complete\n");
ret = -EBUSY; return -EBUSY;
goto err;
} }
/* Check if playback is ongoing when initial request is made */ /* Check if playback is ongoing when initial request is made */
if (cs35l41->playback_started) { if (cs35l41->playback_started) {
dev_err(cs35l41->dev, "Cannot Load/Unload firmware during Playback\n"); dev_err(cs35l41->dev, "Cannot Load/Unload firmware during Playback\n");
ret = -EBUSY; return -EBUSY;
goto err;
} }
cs35l41->fw_request_ongoing = true; cs35l41->fw_request_ongoing = true;
cs35l41->request_fw_load = ucontrol->value.integer.value[0]; cs35l41->request_fw_load = ucontrol->value.integer.value[0];
schedule_work(&cs35l41->fw_load_work); schedule_work(&cs35l41->fw_load_work);
err: return 1;
mutex_unlock(&cs35l41->fw_mutex);
return ret;
} }
static int cs35l41_fw_type_ctl_get(struct snd_kcontrol *kcontrol, static int cs35l41_fw_type_ctl_get(struct snd_kcontrol *kcontrol,
...@@ -881,8 +873,12 @@ static int cs35l41_fw_type_ctl_put(struct snd_kcontrol *kcontrol, ...@@ -881,8 +873,12 @@ static int cs35l41_fw_type_ctl_put(struct snd_kcontrol *kcontrol,
struct cs35l41_hda *cs35l41 = snd_kcontrol_chip(kcontrol); struct cs35l41_hda *cs35l41 = snd_kcontrol_chip(kcontrol);
if (ucontrol->value.enumerated.item[0] < HDA_CS_DSP_NUM_FW) { if (ucontrol->value.enumerated.item[0] < HDA_CS_DSP_NUM_FW) {
cs35l41->firmware_type = ucontrol->value.enumerated.item[0]; if (cs35l41->firmware_type != ucontrol->value.enumerated.item[0]) {
return 0; cs35l41->firmware_type = ucontrol->value.enumerated.item[0];
return 1;
} else {
return 0;
}
} }
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment