mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda/senary: Fix beep error handling and optimize EAPD  switching
@ 2026-03-10  2:36 wangdich9700
  2026-03-10  8:35 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: wangdich9700 @ 2026-03-10  2:36 UTC (permalink / raw)
  To: bo.liu, perex, tiwai; +Cc: linux-sound, linux-kernel, wangdicheng

From: wangdicheng <wangdicheng@kylinos.cn>

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>
---
 sound/hda/codecs/senarytech.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sound/hda/codecs/senarytech.c b/sound/hda/codecs/senarytech.c
index 6239a25bb8f3..61b0dcf76305 100644
--- a/sound/hda/codecs/senarytech.c
+++ b/sound/hda/codecs/senarytech.c
@@ -50,7 +50,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]);
@@ -58,6 +57,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;
 }
 
@@ -99,10 +100,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);
 	}
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ALSA: hda/senary: Fix beep error handling and optimize EAPD  switching
  2026-03-10  2:36 [PATCH] ALSA: hda/senary: Fix beep error handling and optimize EAPD switching wangdich9700
@ 2026-03-10  8:35 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-03-10  8:35 UTC (permalink / raw)
  To: wangdich9700; +Cc: bo.liu, perex, tiwai, linux-sound, linux-kernel, wangdicheng

On Tue, 10 Mar 2026 03:36:49 +0100,
wangdich9700@163.com wrote:
> 
> From: wangdicheng <wangdicheng@kylinos.cn>
> 
> 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>

Applied to for-next branch now.  Thanks.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-10  8:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-10  2:36 [PATCH] ALSA: hda/senary: Fix beep error handling and optimize EAPD switching wangdich9700
2026-03-10  8:35 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®