Commit 0faacc08 authored by Cássio Gabriel's avatar Cássio Gabriel Committed by Takashi Iwai
Browse files

ALSA: hda: cs35l56: Propagate ASP TX source control errors



cs35l56_hda_mixer_get() ignores regmap_read() and
cs35l56_hda_mixer_put() ignores regmap_update_bits_check().

This makes the ASP TX source controls report success when a regmap
access fails. The write path returns no change instead of an error,
and the read path continues after a failed read instead of aborting
the control callback.

Propagate the regmap errors, matching the posture and volume controls
in this driver.

Fixes: 73cfbfa9 ("ALSA: hda/cs35l56: Add driver for Cirrus Logic CS35L56 amplifier")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarCássio Gabriel <cassiogabrielcontato@gmail.com>
Reviewed-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20260423-alsa-cs35l56-asp-tx-source-errors-v1-1-17ea7c62ec31@gmail.com
parent 254f4963
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -180,11 +180,15 @@ static int cs35l56_hda_mixer_get(struct snd_kcontrol *kcontrol,
{
	struct cs35l56_hda *cs35l56 = snd_kcontrol_chip(kcontrol);
	unsigned int reg_val;
	int i;
	int i, ret;

	cs35l56_hda_wait_dsp_ready(cs35l56);

	regmap_read(cs35l56->base.regmap, kcontrol->private_value, &reg_val);
	ret = regmap_read(cs35l56->base.regmap, kcontrol->private_value,
			  &reg_val);
	if (ret)
		return ret;

	reg_val &= CS35L56_ASP_TXn_SRC_MASK;

	for (i = 0; i < CS35L56_NUM_INPUT_SRC; ++i) {
@@ -203,15 +207,20 @@ static int cs35l56_hda_mixer_put(struct snd_kcontrol *kcontrol,
	struct cs35l56_hda *cs35l56 = snd_kcontrol_chip(kcontrol);
	unsigned int item = ucontrol->value.enumerated.item[0];
	bool changed;
	int ret;

	if (item >= CS35L56_NUM_INPUT_SRC)
		return -EINVAL;

	cs35l56_hda_wait_dsp_ready(cs35l56);

	regmap_update_bits_check(cs35l56->base.regmap, kcontrol->private_value,
				 CS35L56_INPUT_MASK, cs35l56_tx_input_values[item],
	ret = regmap_update_bits_check(cs35l56->base.regmap,
				       kcontrol->private_value,
				       CS35L56_INPUT_MASK,
				       cs35l56_tx_input_values[item],
				       &changed);
	if (ret)
		return ret;

	return changed;
}