Another sbus(4) device driver.

This code converts between milliseconds and ticks.  If we strip out
the conversions we can just use milliseconds directly with
timeout_add_msec(9) and delete the conversion code, too.

This is only built for sparc64.  It ought to compile but I'm not sure.

Assuming it compiles, ok?

Index: magma.c
===================================================================
RCS file: /cvs/src/sys/dev/sbus/magma.c,v
retrieving revision 1.30
diff -u -p -r1.30 magma.c
--- magma.c     31 Dec 2019 10:05:33 -0000      1.30
+++ magma.c     10 Feb 2020 23:34:49 -0000
@@ -1410,8 +1410,8 @@ mbppopen(dev_t dev, int flags, int mode,
 
        /* set defaults */
        mp->mp_burst = BPP_BURST;
-       mp->mp_timeout = mbpp_mstohz(BPP_TIMEOUT);
-       mp->mp_delay = mbpp_mstohz(BPP_DELAY);
+       mp->mp_timeout = BPP_TIMEOUT;
+       mp->mp_delay = BPP_DELAY;
 
        /* init chips */
        if (mp->mp_cd1400) {    /* CD1400 */
@@ -1482,15 +1482,15 @@ mbppioctl(dev_t dev, u_long cmd, caddr_t
                        error = EINVAL;
                } else {
                        mp->mp_burst = bp->bp_burst;
-                       mp->mp_timeout = mbpp_mstohz(bp->bp_timeout);
-                       mp->mp_delay = mbpp_mstohz(bp->bp_delay);
+                       mp->mp_timeout = bp->bp_timeout;
+                       mp->mp_delay = bp->bp_delay;
                }
                break;
        case BPPIOCGPARAM:
                bp = (struct bpp_param *)data;
                bp->bp_burst = mp->mp_burst;
-               bp->bp_timeout = mbpp_hztoms(mp->mp_timeout);
-               bp->bp_delay = mbpp_hztoms(mp->mp_delay);
+               bp->bp_timeout = mp->mp_timeout;
+               bp->bp_delay = mp->mp_delay;
                break;
        case BPPIOCGSTAT:
                /* XXX make this more generic */
@@ -1540,7 +1540,7 @@ mbpp_rw(dev_t dev, struct uio *uio)
         */
        if (mp->mp_timeout > 0) {
                SET(mp->mp_flags, MBPPF_TIMEOUT);
-               timeout_add(&mp->mp_timeout_tmo, mp->mp_timeout);
+               timeout_add_msec(&mp->mp_timeout_tmo, mp->mp_timeout);
        }
 
        len = cnt = 0;
@@ -1588,7 +1588,7 @@ mbpp_rw(dev_t dev, struct uio *uio)
                if (mp->mp_delay > 0) {
                        s = spltty();   /* XXX */
                        SET(mp->mp_flags, MBPPF_DELAY);
-                       timeout_add(&mp->mp_start_tmo, mp->mp_delay);
+                       timeout_add_msec(&mp->mp_start_tmo, mp->mp_delay);
                        error = tsleep_nsec(mp, PCATCH | PZERO, "mbppdelay",
                            INFSLP);
                        splx(s);
@@ -1739,27 +1739,4 @@ mbpp_recv(struct mbpp_port *mp, caddr_t 
 
        /* return number of chars received */
        return (len - mp->mp_cnt);
-}
-
-int
-mbpp_hztoms(int h)
-{
-       int m = h;
-
-       if (m > 0)
-               m = m * 1000 / hz;
-       return (m);
-}
-
-int
-mbpp_mstohz(int m)
-{
-       int h = m;
-
-       if (h > 0) {
-               h = h * hz / 1000;
-               if (h == 0)
-                       h = 1000 / hz;
-       }
-       return (h);
 }
Index: magmareg.h
===================================================================
RCS file: /cvs/src/sys/dev/sbus/magmareg.h,v
retrieving revision 1.9
diff -u -p -r1.9 magmareg.h
--- magmareg.h  29 Nov 2008 01:55:06 -0000      1.9
+++ magmareg.h  10 Feb 2020 23:34:49 -0000
@@ -220,8 +220,6 @@ void mbpp_timeout(void *);
 void mbpp_start(void *);
 int mbpp_send(struct mbpp_port *, caddr_t, int);
 int mbpp_recv(struct mbpp_port *, caddr_t, int);
-int mbpp_hztoms(int);
-int mbpp_mstohz(int);
 
 #define        CD1400_REGMAPSIZE       0x80
 #define        CD1190_REGMAPSIZE       0x20

Reply via email to