diff options
author | jhb <jhb@FreeBSD.org> | 2014-09-22 14:27:26 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2014-09-22 14:27:26 +0000 |
commit | d08fb7f87738c5246eb1e0e0ec10b71a79d855be (patch) | |
tree | af06f24af9103896dd67b86a5c9a2367326e52ac /sys | |
parent | fe74bc61638e2114cbcda81fc1e045226717fe34 (diff) | |
download | FreeBSD-src-d08fb7f87738c5246eb1e0e0ec10b71a79d855be.zip FreeBSD-src-d08fb7f87738c5246eb1e0e0ec10b71a79d855be.tar.gz |
Convert from timeout(9) to callout(9).
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/acpica/acpi.c | 17 | ||||
-rw-r--r-- | sys/dev/atkbdc/atkbd.c | 37 | ||||
-rw-r--r-- | sys/kern/kern_cons.c | 10 |
3 files changed, 42 insertions, 22 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 2f30092..1913912 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -93,6 +93,7 @@ struct acpi_interface { /* Global mutex for locking access to the ACPI subsystem. */ struct mtx acpi_mutex; +struct callout acpi_sleep_timer; /* Bitmap of device quirks. */ int acpi_quirks; @@ -683,7 +684,9 @@ acpi_attach(device_t dev) AcpiFormatException(status)); /* Allow sleep request after a while. */ - timeout(acpi_sleep_enable, sc, hz * ACPI_MINIMUM_AWAKETIME); + callout_init_mtx(&acpi_sleep_timer, &acpi_mutex, 0); + callout_reset(&acpi_sleep_timer, hz * ACPI_MINIMUM_AWAKETIME, + acpi_sleep_enable, sc); error = 0; @@ -2490,8 +2493,8 @@ acpi_sleep_force(void *arg) device_printf(sc->acpi_dev, "suspend request timed out, forcing sleep now\n"); /* - * XXX Suspending from callout cause the freeze in DEVICE_SUSPEND(). - * Suspend from acpi_task thread in stead. + * XXX Suspending from callout causes freezes in DEVICE_SUSPEND(). + * Suspend from acpi_task thread instead. */ if (ACPI_FAILURE(AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_sleep_force_task, sc))) @@ -2643,15 +2646,15 @@ acpi_sleep_enable(void *arg) { struct acpi_softc *sc = (struct acpi_softc *)arg; + ACPI_LOCK_ASSERT(acpi); + /* Reschedule if the system is not fully up and running. */ if (!AcpiGbl_SystemAwakeAndRunning) { - timeout(acpi_sleep_enable, sc, hz * ACPI_MINIMUM_AWAKETIME); + callout_schedule(&acpi_sleep_timer, hz * ACPI_MINIMUM_AWAKETIME); return; } - ACPI_LOCK(acpi); sc->acpi_sleep_disabled = FALSE; - ACPI_UNLOCK(acpi); } static ACPI_STATUS @@ -2866,7 +2869,7 @@ backout: EVENTHANDLER_INVOKE(power_resume); /* Allow another sleep request after a while. */ - timeout(acpi_sleep_enable, sc, hz * ACPI_MINIMUM_AWAKETIME); + callout_schedule(&acpi_sleep_timer, hz * ACPI_MINIMUM_AWAKETIME); /* Run /etc/rc.resume after we are back. */ if (devctl_process_running()) diff --git a/sys/dev/atkbdc/atkbd.c b/sys/dev/atkbdc/atkbd.c index 199fcb1..0d2b44b 100644 --- a/sys/dev/atkbdc/atkbd.c +++ b/sys/dev/atkbdc/atkbd.c @@ -62,7 +62,20 @@ __FBSDID("$FreeBSD$"); #include <dev/atkbdc/atkbdreg.h> #include <dev/atkbdc/atkbdcreg.h> -static timeout_t atkbd_timeout; +typedef struct atkbd_state { + KBDC kbdc; /* keyboard controller */ + int ks_mode; /* input mode (K_XLATE,K_RAW,K_CODE) */ + int ks_flags; /* flags */ +#define COMPOSE (1 << 0) + int ks_polling; + int ks_state; /* shift/lock key state */ + int ks_accents; /* accent key index (> 0) */ + u_int ks_composed_char; /* composed char code (> 0) */ + u_char ks_prefix; /* AT scan code prefix */ + struct callout ks_timer; +} atkbd_state_t; + +static void atkbd_timeout(void *arg); static void atkbd_shutdown_final(void *v); int @@ -88,6 +101,7 @@ int atkbd_attach_unit(device_t dev, keyboard_t **kbd, int irq, int flags) { keyboard_switch_t *sw; + atkbd_state_t *state; int args[2]; int error; int unit; @@ -120,6 +134,8 @@ atkbd_attach_unit(device_t dev, keyboard_t **kbd, int irq, int flags) * This is a kludge to compensate for lost keyboard interrupts. * A similar code used to be in syscons. See below. XXX */ + state = (atkbd_state_t *)(*kbd)->kb_data; + callout_init(&state->ks_timer, 0); atkbd_timeout(*kbd); if (bootverbose) @@ -134,6 +150,7 @@ atkbd_attach_unit(device_t dev, keyboard_t **kbd, int irq, int flags) static void atkbd_timeout(void *arg) { + atkbd_state_t *state; keyboard_t *kbd; int s; @@ -175,25 +192,14 @@ atkbd_timeout(void *arg) kbdd_intr(kbd, NULL); } splx(s); - timeout(atkbd_timeout, arg, hz/10); + state = (atkbd_state_t *)kbd->kb_data; + callout_reset(&state->ks_timer, hz / 10, atkbd_timeout, arg); } /* LOW-LEVEL */ #define ATKBD_DEFAULT 0 -typedef struct atkbd_state { - KBDC kbdc; /* keyboard controller */ - int ks_mode; /* input mode (K_XLATE,K_RAW,K_CODE) */ - int ks_flags; /* flags */ -#define COMPOSE (1 << 0) - int ks_polling; - int ks_state; /* shift/lock key state */ - int ks_accents; /* accent key index (> 0) */ - u_int ks_composed_char; /* composed char code (> 0) */ - u_char ks_prefix; /* AT scan code prefix */ -} atkbd_state_t; - /* keyboard driver declaration */ static int atkbd_configure(int flags); static kbd_probe_t atkbd_probe; @@ -470,7 +476,10 @@ bad: static int atkbd_term(keyboard_t *kbd) { + atkbd_state_t *state = (atkbd_state_t *)kbd->kb_data; + kbd_unregister(kbd); + callout_drain(&state->ks_timer); return 0; } diff --git a/sys/kern/kern_cons.c b/sys/kern/kern_cons.c index da157ec..a6ccf62 100644 --- a/sys/kern/kern_cons.c +++ b/sys/kern/kern_cons.c @@ -607,6 +607,7 @@ SYSINIT(cndev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, cn_drvinit, NULL); #ifdef HAS_TIMER_SPKR static int beeping; +static struct callout beeping_timer; static void sysbeepstop(void *chan) @@ -629,11 +630,18 @@ sysbeep(int pitch, int period) timer_spkr_setfreq(pitch); if (!beeping) { beeping = period; - timeout(sysbeepstop, (void *)NULL, period); + callout_reset(&beeping_timer, period, sysbeepstop, NULL); } return (0); } +static void +sysbeep_init(void *unused) +{ + + callout_init(&beeping_timer, CALLOUT_MPSAFE); +} +SYSINIT(sysbeep, SI_SUB_SOFTINTR, SI_ORDER_ANY, sysbeep_init, NULL); #else /* |