Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/gehenna-devsw]: src/sys/kern Replace the direct-access to devsw table wi...



details:   https://anonhg.NetBSD.org/src/rev/8f2a902b4cd4
branches:  gehenna-devsw
changeset: 527041:8f2a902b4cd4
user:      gehenna <gehenna%NetBSD.org@localhost>
date:      Thu May 16 04:12:25 2002 +0000

description:
Replace the direct-access to devsw table with calling devsw APIs.

diffstat:

 sys/kern/tty.c     |  22 ++++++++++++++++------
 sys/kern/vfs_bio.c |  18 ++++++++++--------
 2 files changed, 26 insertions(+), 14 deletions(-)

diffs (120 lines):

diff -r a34171f3a998 -r 8f2a902b4cd4 sys/kern/tty.c
--- a/sys/kern/tty.c    Thu May 16 04:10:13 2002 +0000
+++ b/sys/kern/tty.c    Thu May 16 04:12:25 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.c,v 1.138 2002/05/02 13:38:57 enami Exp $  */
+/*     $NetBSD: tty.c,v 1.138.2.1 2002/05/16 04:12:25 gehenna Exp $    */
 
 /*-
  * Copyright (c) 1982, 1986, 1990, 1991, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.138 2002/05/02 13:38:57 enami Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.138.2.1 2002/05/16 04:12:25 gehenna Exp $");
 
 #include "opt_uconsole.h"
 
@@ -298,6 +298,7 @@
 int
 ttyinput(int c, struct tty *tp)
 {
+       const struct cdevsw *cdev;
        int     iflag, lflag, i, error;
        u_char  *cc;
 
@@ -441,8 +442,9 @@
                        if (CCEQ(cc[VSTOP], c)) {
                                if (!ISSET(tp->t_state, TS_TTSTOP)) {
                                        SET(tp->t_state, TS_TTSTOP);
-                                       (*cdevsw[major(tp->t_dev)].d_stop)(tp,
-                                          0);
+                                       cdev = cdevsw_lookup(tp->t_dev);
+                                       if (cdev != NULL)
+                                               (*cdev->d_stop)(tp, 0);
                                        return (0);
                                }
                                if (!CCEQ(cc[VSTART], c))
@@ -974,13 +976,18 @@
                (*tp->t_linesw->l_rint)(*(u_char *)data, tp);
                break;
        case TIOCSTOP:                  /* stop output, like ^S */
+       {
+               const struct cdevsw *cdev;
                s = spltty();
                if (!ISSET(tp->t_state, TS_TTSTOP)) {
                        SET(tp->t_state, TS_TTSTOP);
-                       (*cdevsw[major(tp->t_dev)].d_stop)(tp, 0);
+                       cdev = cdevsw_lookup(tp->t_dev);
+                       if (cdev != NULL)
+                               (*cdev->d_stop)(tp, 0);
                }
                splx(s);
                break;
+       }
        case TIOCSCTTY:                 /* become controlling tty */
                /* Session ctty vnode pointer set in vnode layer. */
                if (!SESS_LEADER(p) ||
@@ -1113,6 +1120,7 @@
 void
 ttyflush(struct tty *tp, int rw)
 {
+       const struct cdevsw *cdev;
        int     s;
 
        s = spltty();
@@ -1126,7 +1134,9 @@
        }
        if (rw & FWRITE) {
                CLR(tp->t_state, TS_TTSTOP);
-               (*cdevsw[major(tp->t_dev)].d_stop)(tp, rw);
+               cdev = cdevsw_lookup(tp->t_dev);
+               if (cdev != NULL)
+                       (*cdev->d_stop)(tp, rw);
                FLUSHQ(&tp->t_outq);
                wakeup((caddr_t)&tp->t_outq);
                selwakeup(&tp->t_wsel);
diff -r a34171f3a998 -r 8f2a902b4cd4 sys/kern/vfs_bio.c
--- a/sys/kern/vfs_bio.c        Thu May 16 04:10:13 2002 +0000
+++ b/sys/kern/vfs_bio.c        Thu May 16 04:12:25 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_bio.c,v 1.81 2002/05/12 23:06:27 matt Exp $        */
+/*     $NetBSD: vfs_bio.c,v 1.81.2.1 2002/05/16 04:12:26 gehenna Exp $ */
 
 /*-
  * Copyright (c) 1994 Christopher G. Demetriou
@@ -51,7 +51,7 @@
 #include "opt_softdep.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.81 2002/05/12 23:06:27 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.81.2.1 2002/05/16 04:12:26 gehenna Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -396,16 +396,18 @@
        struct buf *bp;
 {
        struct proc *p = (curproc != NULL ? curproc : &proc0);  /* XXX */
+       const struct bdevsw *bdev;
        int s;
 
        /* If this is a tape block, write the block now. */
        /* XXX NOTE: the memory filesystem usurpes major device */
-       /* XXX       number 255, which is a bad idea.           */
-       if (bp->b_dev != NODEV &&
-           major(bp->b_dev) != 255 &&  /* XXX - MFS buffers! */
-           bdevsw[major(bp->b_dev)].d_type == D_TAPE) {
-               bawrite(bp);
-               return;
+       /* XXX       number 4095, which is a bad idea.          */
+       if (bp->b_dev != NODEV && major(bp->b_dev) != 4095) {
+               bdev = bdevsw_lookup(bp->b_dev);
+               if (bdev != NULL && bdev->d_type == D_TAPE) {
+                       bawrite(bp);
+                       return;
+               }
        }
 
        /*



Home | Main Index | Thread Index | Old Index