summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkn <kn@cvs.openbsd.org>2019-06-22 20:30:43 +0000
committerkn <kn@cvs.openbsd.org>2019-06-22 20:30:43 +0000
commitc64f842d35d87419fc58144df2946b52cec43882 (patch)
tree8ca67c6687a75f0ea4d4cb134441dac652e7b2b5
parent4d364869ea6aa2735471499aa9edf7676fa5b3ac (diff)
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.c10
-rw-r--r--sys/arch/sparc64/dev/beeper.c10
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);
}