diff options
author | 2019-06-22 20:30:42 +0000 | |
---|---|---|
committer | 2019-06-22 20:30:42 +0000 | |
commit | e9959c3eed29c9dae133cfee8d61a9620430c8d1 (patch) | |
tree | 8f9ed2c195a4f4e8ff791cf3f7ef764021884c68 | |
parent | Make computation of re-challenge timeout more obvious (diff) | |
download | wireguard-openbsd-e9959c3eed29c9dae133cfee8d61a9620430c8d1.tar.xz wireguard-openbsd-e9959c3eed29c9dae133cfee8d61a9620430c8d1.zip |
Use timeout_add_msec(9)
hz can simply be reduced has the code wants to wait
(period * hz) / 1000 [ticks] = period / 1000 [s] = period [ms].
With the zero check, this perfectly matches the millisecond version.
This conversion by itself also lifts the implicit expection of the period
to be evenly divisible by ten; in case it was not, integer division
would truncate it.
See /sys/wscons/wskbd.c for how the period is set up.
OK mpi
-rw-r--r-- | sys/arch/sparc64/dev/beep.c | 10 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/beeper.c | 10 |
2 files changed, 6 insertions, 14 deletions
diff --git a/sys/arch/sparc64/dev/beep.c b/sys/arch/sparc64/dev/beep.c index c109e0a4e92..fcc22676615 100644 --- a/sys/arch/sparc64/dev/beep.c +++ b/sys/arch/sparc64/dev/beep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: beep.c,v 1.8 2017/09/08 05:36:52 deraadt Exp $ */ +/* $OpenBSD: beep.c,v 1.9 2019/06/22 20:30:42 kn Exp $ */ /* * Copyright (c) 2006 Jason L. Wright (jason@thought.net) @@ -218,11 +218,7 @@ void beep_bell(void *vsc, u_int pitch, u_int period, u_int volume, int poll) { struct beep_softc *sc = vsc; - int s, nticks; - - nticks = (period * hz) / 1000; - if (nticks <= 0) - nticks = 1; + int s; s = spltty(); if (sc->sc_bellactive) { @@ -239,7 +235,7 @@ beep_bell(void *vsc, u_int pitch, u_int period, u_int volume, int poll) sc->sc_belltimeout = 1; bus_space_write_1(sc->sc_iot, sc->sc_ioh, BEEP_CTRL, BEEP_CTRL_ON); - timeout_add(&sc->sc_to, nticks); + timeout_add_msec(&sc->sc_to, period); } splx(s); } diff --git a/sys/arch/sparc64/dev/beeper.c b/sys/arch/sparc64/dev/beeper.c index 895979efedf..dd545b49b1d 100644 --- a/sys/arch/sparc64/dev/beeper.c +++ b/sys/arch/sparc64/dev/beeper.c @@ -1,4 +1,4 @@ -/* $OpenBSD: beeper.c,v 1.12 2017/09/08 05:36:52 deraadt Exp $ */ +/* $OpenBSD: beeper.c,v 1.13 2019/06/22 20:30:42 kn Exp $ */ /* * Copyright (c) 2001 Jason L. Wright (jason@thought.net) @@ -147,11 +147,7 @@ beeper_bell(vsc, pitch, period, volume, poll) int poll; { struct beeper_softc *sc = vsc; - int s, nticks; - - nticks = (period * hz) / 1000; - if (nticks <= 0) - nticks = 1; + int s; s = spltty(); if (sc->sc_bellactive) { @@ -167,7 +163,7 @@ beeper_bell(vsc, pitch, period, volume, poll) sc->sc_bellactive = 1; sc->sc_belltimeout = 1; bus_space_write_4(sc->sc_iot, sc->sc_ioh, BEEP_REG, 1); - timeout_add(&sc->sc_to, nticks); + timeout_add_msec(&sc->sc_to, period); } splx(s); } |