Ticks to milliseconds.

I've changed "tic" to "msecs" in the backoff loop to make the units
more obvious.  I went with 10ms as the starting sleep.  A perfect
conversion would start at something like (tick / 1000), but obviously
we're trying to move away from that sort of thing.  Absent a better
idea, 10ms seems safe.

Everything else here is straightforward.

ok?

Index: ic/lpt.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/lpt.c,v
retrieving revision 1.14
diff -u -p -r1.14 lpt.c
--- ic/lpt.c    11 May 2015 02:01:01 -0000      1.14
+++ ic/lpt.c    15 Jan 2020 00:33:47 -0000
@@ -71,8 +71,8 @@
 
 #include "lpt.h"
 
-#define        TIMEOUT         hz*16   /* wait up to 16 seconds for a ready */
-#define        STEP            hz/4
+#define        TIMEOUT         16000   /* wait up to 16 seconds for a ready */
+#define        STEP            250     /* 1/4 seconds */
 
 #define        LPTPRI          (PZERO+8)
 #define        LPT_BSIZE       1024
@@ -199,7 +199,8 @@ lptopen(dev_t dev, int flag, int mode, s
                }
 
                /* wait 1/4 second, give up if we get a signal */
-               error = tsleep((caddr_t)sc, LPTPRI | PCATCH, "lptopen", STEP);
+               error = tsleep_nsec(sc, LPTPRI | PCATCH, "lptopen",
+                   MSEC_TO_NSEC(STEP));
                if (sc->sc_state == 0)
                        return (EIO);
                if (error != EWOULDBLOCK) {
@@ -256,7 +257,7 @@ lptwakeup(void *arg)
        splx(s);
 
        if (sc->sc_state != 0)
-               timeout_add(&sc->sc_wakeup_tmo, STEP);
+               timeout_add_msec(&sc->sc_wakeup_tmo, STEP);
 }
 
 /*
@@ -293,7 +294,7 @@ lptpushbytes(struct lpt_softc *sc)
        int error;
 
        if (sc->sc_flags & LPT_NOINTR) {
-               int spin, tic;
+               int msecs, spin;
                u_int8_t control = sc->sc_control;
 
                while (sc->sc_count > 0) {
@@ -303,16 +304,17 @@ lptpushbytes(struct lpt_softc *sc)
                        while (NOT_READY()) {
                                if (++spin < sc->sc_spinmax)
                                        continue;
-                               tic = 0;
+                               msecs = 10;
                                /* adapt busy-wait algorithm */
                                sc->sc_spinmax++;
                                while (NOT_READY_ERR()) {
                                        /* exponential backoff */
-                                       tic = tic + tic + 1;
-                                       if (tic > TIMEOUT)
-                                               tic = TIMEOUT;
-                                       error = tsleep((caddr_t)sc,
-                                           LPTPRI | PCATCH, "lptpsh", tic);
+                                       msecs = msecs + msecs + 1;
+                                       if (msecs > TIMEOUT)
+                                               msecs = TIMEOUT;
+                                       error = tsleep_nsec(sc,
+                                           LPTPRI | PCATCH, "lptpsh",
+                                           MSEC_TO_NSEC(msecs));
                                        if (sc->sc_state == 0)
                                                error = EIO;
                                        if (error != EWOULDBLOCK)
@@ -345,8 +347,8 @@ lptpushbytes(struct lpt_softc *sc)
                        }
                        if (sc->sc_state == 0)
                                return (EIO);
-                       error = tsleep((caddr_t)sc, LPTPRI | PCATCH,
-                           "lptwrite2", 0);
+                       error = tsleep_nsec(sc, LPTPRI | PCATCH,
+                           "lptwrite2", INFSLP);
                        if (sc->sc_state == 0)
                                error = EIO;
                        if (error)

Reply via email to