Author: jkim
Date: Thu Feb 16 22:28:17 2012
New Revision: 231840
URL: http://svn.freebsd.org/changeset/base/231840

Log:
  Refine r231791.  Install the resume event handler unconditionally.

Modified:
  head/sys/amd64/acpica/acpi_wakeup.c

Modified: head/sys/amd64/acpica/acpi_wakeup.c
==============================================================================
--- head/sys/amd64/acpica/acpi_wakeup.c Thu Feb 16 21:58:47 2012        
(r231839)
+++ head/sys/amd64/acpica/acpi_wakeup.c Thu Feb 16 22:28:17 2012        
(r231840)
@@ -98,7 +98,8 @@ static void
 acpi_stop_beep(void *arg)
 {
 
-       timer_spkr_release();
+       if (acpi_resume_beep != 0)
+               timer_spkr_release();
 }
 
 #ifdef SMP
@@ -219,7 +220,6 @@ acpi_wakeup_cpus(struct acpi_softc *sc, 
 int
 acpi_sleep_machdep(struct acpi_softc *sc, int state)
 {
-       static eventhandler_tag stop_beep = NULL;
 #ifdef SMP
        cpuset_t        wakeup_cpus;
 #endif
@@ -236,21 +236,8 @@ acpi_sleep_machdep(struct acpi_softc *sc
        CPU_CLR(PCPU_GET(cpuid), &wakeup_cpus);
 #endif
 
-       if (acpi_resume_beep == 0) {
-               if (stop_beep != NULL) {
-                       EVENTHANDLER_DEREGISTER(power_resume, stop_beep);
-                       stop_beep = NULL;
-               }
-       } else {
-               if (stop_beep == NULL)
-                       stop_beep = EVENTHANDLER_REGISTER(power_resume,
-                           acpi_stop_beep, NULL, EVENTHANDLER_PRI_LAST);
-               if (stop_beep == NULL)
-                       device_printf(sc->acpi_dev,
-                           "Failed to set up event handler\n");
-               else
-                       timer_spkr_acquire();
-       }
+       if (acpi_resume_beep != 0)
+               timer_spkr_acquire();
 
        AcpiSetFirmwareWakingVector(WAKECODE_PADDR(sc));
 
@@ -267,7 +254,7 @@ acpi_sleep_machdep(struct acpi_softc *sc
                }
 #endif
 
-               WAKECODE_FIXUP(resume_beep, uint8_t, (stop_beep != NULL));
+               WAKECODE_FIXUP(resume_beep, uint8_t, (acpi_resume_beep != 0));
                WAKECODE_FIXUP(reset_video, uint8_t, (acpi_reset_video != 0));
 
                WAKECODE_FIXUP(wakeup_pcb, struct pcb *, susppcbs[0]);
@@ -343,6 +330,12 @@ acpi_alloc_wakeup_handler(void)
                printf("%s: can't alloc wake memory\n", __func__);
                return (NULL);
        }
+       if (EVENTHANDLER_REGISTER(power_resume, acpi_stop_beep, NULL,
+           EVENTHANDLER_PRI_LAST) == NULL) {
+               printf("%s: can't register event handler\n", __func__);
+               contigfree(wakeaddr, 4 * PAGE_SIZE, M_DEVBUF);
+               return (NULL);
+       }
        susppcbs = malloc(mp_ncpus * sizeof(*susppcbs), M_DEVBUF, M_WAITOK);
        suspfpusave = malloc(mp_ncpus * sizeof(void *), M_DEVBUF, M_WAITOK);
        for (i = 0; i < mp_ncpus; i++) {
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to