ALSA: hda - Avoid possible race of beep on/off
authorTakashi Iwai <tiwai@suse.de>
Tue, 3 Jul 2012 15:36:35 +0000 (17:36 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 3 Jul 2012 16:31:37 +0000 (18:31 +0200)
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

index e6cf2a22c4074dfb8436096f97e5fa430451d590..0bc2315b181dad0ec6ed7a33af9e0a0a636c3608 100644 (file)
@@ -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);