Convert from timeout(9) to callout(9).

This commit is contained in:
John Baldwin 2014-09-22 14:27:26 +00:00
parent a5b1f2ab54
commit fadf3fb98c
3 changed files with 42 additions and 22 deletions

View File

@ -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 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state)
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())

View File

@ -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 @@ atkbd_init(int unit, keyboard_t **kbdp, void *arg, int flags)
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;
}

View File

@ -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
/*