summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwangdicheng <wangdicheng@kylinos.cn>2026-03-10 05:36:49 +0300
committerTakashi Iwai <tiwai@suse.de>2026-03-10 11:34:41 +0300
commitedf04f1af05d714c7aba0cf008ded1245365fcd7 (patch)
tree47f4b84c30fc2a89844248808162d5e3556cc3a3
parentc4791ce96b88a444b04c7089ae2827a3b3ae1877 (diff)
downloadlinux-edf04f1af05d714c7aba0cf008ded1245365fcd7.tar.xz
ALSA: hda/senary: Fix beep error handling and optimize EAPD switching
This patch addresses a potential state inconsistency bug and optimizes runtime performance: 1. Fix error handling in set_beep_amp(): Previously, beep_nid was assigned before adding kcontrols. If kcontrol creation failed, the function returned error but left beep_nid set, causing inconsistent driver state. Moved the assignment to the end of the function. 2. Optimize senary_auto_turn_eapd(): Removed the redundant snd_hda_query_pin_caps() check inside the loop. The target pins are sourced from spec->eapds, which is strictly filtered during the initial parse phase. Checking capabilities again during every mute/unmute hook is unnecessary overhead. Signed-off-by: wangdicheng <wangdicheng@kylinos.cn> Link: https://patch.msgid.link/20260310023649.155858-1-wangdich9700@163.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/hda/codecs/senarytech.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sound/hda/codecs/senarytech.c b/sound/hda/codecs/senarytech.c
index f9a389df3a17..29b554cdd81d 100644
--- a/sound/hda/codecs/senarytech.c
+++ b/sound/hda/codecs/senarytech.c
@@ -76,7 +76,6 @@ static int set_beep_amp(struct senary_spec *spec, hda_nid_t nid,
unsigned int beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir);
int i;
- spec->gen.beep_nid = nid;
for (i = 0; i < ARRAY_SIZE(senary_beep_mixer); i++) {
knew = snd_hda_gen_add_kctl(&spec->gen, NULL,
&senary_beep_mixer[i]);
@@ -84,6 +83,8 @@ static int set_beep_amp(struct senary_spec *spec, hda_nid_t nid,
return -ENOMEM;
knew->private_value = beep_amp;
}
+
+ spec->gen.beep_nid = nid;
return 0;
}
@@ -138,10 +139,9 @@ static void senary_auto_turn_eapd(struct hda_codec *codec, int num_pins,
int i;
for (i = 0; i < num_pins; i++) {
- if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD)
- snd_hda_codec_write(codec, pins[i], 0,
- AC_VERB_SET_EAPD_BTLENABLE,
- on ? 0x02 : 0);
+ snd_hda_codec_write(codec, pins[i], 0,
+ AC_VERB_SET_EAPD_BTLENABLE,
+ on ? 0x02 : 0);
}
}