The sleep duration is in milliseconds.  We can rip out the timeval and
tvtohz(9) and use MSEC_TO_NSEC() directly instead.  I've added a local
"msecs" variable because "timo" (a) feels a bit ambiguous and (b) is
used with different units earlier in the same function.

ok?

Index: pci/ips.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/ips.c,v
retrieving revision 1.113
diff -u -p -r1.113 ips.c
--- pci/ips.c   14 Aug 2016 04:08:03 -0000      1.113
+++ pci/ips.c   11 Jan 2020 08:51:00 -0000
@@ -1418,8 +1418,7 @@ ips_cmd(struct ips_softc *sc, struct ips
 int
 ips_poll(struct ips_softc *sc, struct ips_ccb *ccb)
 {
-       struct timeval tv;
-       int error, timo;
+       int error, msecs, timo;
 
        splassert(IPL_BIO);
 
@@ -1436,14 +1435,11 @@ ips_poll(struct ips_softc *sc, struct ip
                }
        } else {
                /* sleep */
-               timo = ccb->c_xfer ? ccb->c_xfer->timeout : IPS_TIMEOUT;
-               tv.tv_sec = timo / 1000;
-               tv.tv_usec = (timo % 1000) * 1000;
-               timo = tvtohz(&tv);
+               msecs = ccb->c_xfer ? ccb->c_xfer->timeout : IPS_TIMEOUT;
 
-               DPRINTF(IPS_D_XFER, ("%s: ips_poll: sleep %d hz\n",
-                   sc->sc_dev.dv_xname, timo));
-               tsleep(ccb, PRIBIO + 1, "ipscmd", timo);
+               DPRINTF(IPS_D_XFER, ("%s: ips_poll: sleep %d ms\n",
+                   sc->sc_dev.dv_xname, msecs));
+               tsleep_nsec(ccb, PRIBIO + 1, "ipscmd", MSEC_TO_NSEC(msecs));
        }
        DPRINTF(IPS_D_XFER, ("%s: ips_poll: state %d\n", sc->sc_dev.dv_xname,
            ccb->c_state));

Reply via email to