As mentioned in a prior mail, tpm(4) is the last user of tvtohz(9) in
the tree.

However, we don't need to use tvtohz(9) in tpm(4) at all.  Converting
from milliseconds to ticks is trivial.  Using an intermediary timeval
is just pointless indirection.

With this committed I will be able to remove both tvtohz(9) and
tstohz(9) from the tree in a subsequent patch.

ok?

Index: tpm.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/tpm.c,v
retrieving revision 1.10
diff -u -p -r1.10 tpm.c
--- tpm.c       22 May 2020 10:16:37 -0000      1.10
+++ tpm.c       6 Jan 2021 18:06:47 -0000
@@ -24,6 +24,7 @@
  */
 
 #include <sys/param.h>
+#include <sys/kernel.h>
 #include <sys/systm.h>
 #include <sys/device.h>
 #include <sys/malloc.h>
@@ -455,12 +456,7 @@ tpm_status(struct tpm_softc *sc)
 int
 tpm_tmotohz(int tmo)
 {
-       struct timeval tv;
-
-       tv.tv_sec = tmo / 1000;
-       tv.tv_usec = 1000 * (tmo % 1000);
-
-       return tvtohz(&tv);
+       return MIN(1, tmo * hz / 1000);
 }
 
 int

Reply via email to