Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3fd877d3 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: hda - Avoid possible race of beep on/off



Call cancel_work_sync() when turning off the beep switch so that the
mute call is executed in a proper order.

Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 257dfb41
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -165,12 +165,13 @@ static int snd_hda_do_attach(struct hda_beep *beep)
int snd_hda_enable_beep_device(struct hda_codec *codec, int enable)
int snd_hda_enable_beep_device(struct hda_codec *codec, int enable)
{
{
	struct hda_beep *beep = codec->beep;
	struct hda_beep *beep = codec->beep;
	enable = !!enable;
	if (!beep)
	if (beep == NULL)
		return 0;
		return 0;
	enable = !!enable;
	if (beep->enabled != enable) {
	if (beep->enabled != enable) {
		beep->enabled = enable;
		beep->enabled = enable;
		if (!enable) {
		if (!enable) {
			cancel_work_sync(&beep->beep_work);
			/* turn off beep */
			/* turn off beep */
			snd_hda_codec_write(beep->codec, beep->nid, 0,
			snd_hda_codec_write(beep->codec, beep->nid, 0,
						  AC_VERB_SET_BEEP_CONTROL, 0);
						  AC_VERB_SET_BEEP_CONTROL, 0);