All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Cc: Takashi Iwai <tiwai@suse.de>
Subject: [PATCH 4/4] ALSA: hda - Avoid possible race of beep on/off
Date: Tue,  3 Jul 2012 18:03:17 +0200	[thread overview]
Message-ID: <1341331397-21182-5-git-send-email-tiwai@suse.de> (raw)
In-Reply-To: <1341331397-21182-1-git-send-email-tiwai@suse.de>

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

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/hda/hda_beep.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c
index e6cf2a2..0bc2315 100644
--- a/sound/pci/hda/hda_beep.c
+++ b/sound/pci/hda/hda_beep.c
@@ -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)
 {
 	struct hda_beep *beep = codec->beep;
-	enable = !!enable;
-	if (beep == NULL)
+	if (!beep)
 		return 0;
+	enable = !!enable;
 	if (beep->enabled != enable) {
 		beep->enabled = enable;
 		if (!enable) {
+			cancel_work_sync(&beep->beep_work);
 			/* turn off beep */
 			snd_hda_codec_write(beep->codec, beep->nid, 0,
 						  AC_VERB_SET_BEEP_CONTROL, 0);
-- 
1.7.10.4

  parent reply	other threads:[~2012-07-03 16:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-03 16:03 [PATCH 0/4] ALSA: hda beep clean up Takashi Iwai
2012-07-03 16:03 ` [PATCH 1/4] ALSA: hda - Remove beep_mode=2 Takashi Iwai
2012-07-03 16:03 ` [PATCH 2/4] ALSA: hda - Move beep helper functions to hda_beep.c Takashi Iwai
2012-07-03 16:03 ` [PATCH 3/4] ALSA: hda - Get rid of superfluous beep->mode field Takashi Iwai
2012-07-03 16:03 ` Takashi Iwai [this message]
2012-07-03 16:31 ` [PATCH 0/4] ALSA: hda beep clean up Jaroslav Kysela
2012-07-03 20:01   ` Jaroslav Kysela
2012-07-04  5:16     ` Takashi Iwai
2012-07-04  7:43       ` Jaroslav Kysela
2012-07-04  7:46         ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1341331397-21182-5-git-send-email-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.