Date: Mon, 22 Sep 2014 14:27:26 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r271963 - in head/sys: dev/acpica dev/atkbdc kern Message-ID: <201409221427.s8MERQms021363@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Mon Sep 22 14:27:26 2014 New Revision: 271963 URL: http://svnweb.freebsd.org/changeset/base/271963 Log: Convert from timeout(9) to callout(9). Modified: head/sys/dev/acpica/acpi.c head/sys/dev/atkbdc/atkbd.c head/sys/kern/kern_cons.c Modified: head/sys/dev/acpica/acpi.c ============================================================================== --- head/sys/dev/acpica/acpi.c Mon Sep 22 13:07:55 2014 (r271962) +++ head/sys/dev/acpica/acpi.c Mon Sep 22 14:27:26 2014 (r271963) @@ -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()) Modified: head/sys/dev/atkbdc/atkbd.c ============================================================================== --- head/sys/dev/atkbdc/atkbd.c Mon Sep 22 13:07:55 2014 (r271962) +++ head/sys/dev/atkbdc/atkbd.c Mon Sep 22 14:27:26 2014 (r271963) @@ -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 * 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 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; } Modified: head/sys/kern/kern_cons.c ============================================================================== --- head/sys/kern/kern_cons.c Mon Sep 22 13:07:55 2014 (r271962) +++ head/sys/kern/kern_cons.c Mon Sep 22 14:27:26 2014 (r271963) @@ -607,6 +607,7 @@ SYSINIT(cndev, SI_SUB_DRIVERS, SI_ORDER_ #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 /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409221427.s8MERQms021363>