Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Use device_lookup().



details:   https://anonhg.NetBSD.org/src/rev/15be21209c30
branches:  trunk
changeset: 494377:15be21209c30
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jul 06 01:47:34 2000 +0000

description:
Use device_lookup().

diffstat:

 sys/dev/ic/ca.c       |  43 ++++++++++++++++------------------------
 sys/dev/ic/cac.c      |   6 ++--
 sys/dev/ic/clmpcc.c   |  32 ++++++++++++++++--------------
 sys/dev/ic/com.c      |  31 +++++++++++++----------------
 sys/dev/ic/cy.c       |  39 ++++++++++++++----------------------
 sys/dev/ic/lpt.c      |  12 +++-------
 sys/dev/ic/midway.c   |   8 +++---
 sys/dev/ic/rrunner.c  |  54 +++++++++++++++++++++-----------------------------
 sys/dev/ic/z8530tty.c |  34 ++++++++++++-------------------
 9 files changed, 110 insertions(+), 149 deletions(-)

diffs (truncated from 842 to 300 lines):

diff -r 1c4e4ef30b5d -r 15be21209c30 sys/dev/ic/ca.c
--- a/sys/dev/ic/ca.c   Thu Jul 06 01:21:46 2000 +0000
+++ b/sys/dev/ic/ca.c   Thu Jul 06 01:47:34 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ca.c,v 1.8 2000/06/20 15:04:50 ad Exp $        */
+/*     $NetBSD: ca.c,v 1.9 2000/07/06 01:47:34 thorpej Exp $   */
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ca.c,v 1.8 2000/06/20 15:04:50 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ca.c,v 1.9 2000/07/06 01:47:34 thorpej Exp $");
 
 #include "rnd.h"
 
@@ -224,12 +224,10 @@
        struct proc *p;
 {
        struct ca_softc *sc;
-       int unit, part;
+       int part;
 
-       unit = CAUNIT(dev);
-       if (unit >= ca_cd.cd_ndevs)
-               return (ENXIO);
-       if ((sc = ca_cd.cd_devs[unit]) == NULL)
+       sc = device_lookup(&ca_cd, CAUNIT(dev));
+       if (sc == NULL)
                return (ENXIO);
        if ((sc->sc_flags & CAF_ENABLED) == 0)
                return (ENODEV);
@@ -270,11 +268,10 @@
        struct proc *p;
 {
        struct ca_softc *sc;
-       int part, unit;
+       int part;
 
-       unit = CAUNIT(dev);
+       sc = device_lookup(&ca_cd, CAUNIT(dev));
        part = CAPART(dev);
-       sc = ca_cd.cd_devs[unit];
        calock(sc);
        
        switch (fmt) {
@@ -321,11 +318,10 @@
        struct proc *p;
 {
        struct ca_softc *sc;
-       int part, unit, error;
+       int part, error;
 
-       unit = CAUNIT(dev);
+       sc = device_lookup(&ca_cd, CAUNIT(dev));
        part = CAPART(dev);
-       sc = ca_cd.cd_devs[unit];
        error = 0;
 
        switch (cmd) {
@@ -394,11 +390,10 @@
        struct cac_context cc;
        struct disklabel *lp;
        struct ca_softc *sc;
-       int part, unit, blkno, flg, cmd;
+       int part, blkno, flg, cmd;
 
-       unit = CAUNIT(bp->b_dev);
+       sc = device_lookup(&ca_cd, CAUNIT(bp->b_dev));
        part = CAPART(bp->b_dev);
-       sc = ca_cd.cd_devs[unit];
 
        lp = sc->sc_dk.dk_label;
 
@@ -506,12 +501,10 @@
        dev_t dev;
 {
        struct ca_softc *sc;
-       int part, unit, omask, size;
+       int part, omask, size;
 
-       unit = CAUNIT(dev);
-       if (unit >= ca_cd.cd_ndevs)
-               return (ENXIO);
-       if ((sc = ca_cd.cd_devs[unit]) == NULL)
+       sc = device_lookup(&ca_cd, CAUNIT(dev));
+       if (sc == NULL)
                return (ENXIO);
        if ((sc->sc_flags & CAF_ENABLED) == 0)
                return (ENODEV);
@@ -642,7 +635,7 @@
 {
        struct ca_softc *sc;
        struct disklabel *lp;
-       int unit, part, nsects, sectoff, totwrt, nwrt;
+       int part, nsects, sectoff, totwrt, nwrt;
        static int dumping;
 
        /* Check if recursive dump; if so, punt. */
@@ -650,10 +643,8 @@
                return (EFAULT);
        dumping = 1;
 
-       unit = CAUNIT(dev);
-       if (unit >= ca_cd.cd_ndevs)
-               return (ENXIO);
-       if ((sc = ca_cd.cd_devs[unit]) == NULL)
+       sc = device_lookup(&ca_cd, CAUNIT(dev));
+       if (sc == NULL)
                return (ENXIO);
        if ((sc->sc_flags & CAF_ENABLED) == 0)
                return (ENODEV);
diff -r 1c4e4ef30b5d -r 15be21209c30 sys/dev/ic/cac.c
--- a/sys/dev/ic/cac.c  Thu Jul 06 01:21:46 2000 +0000
+++ b/sys/dev/ic/cac.c  Thu Jul 06 01:47:34 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cac.c,v 1.6 2000/06/13 13:36:46 ad Exp $       */
+/*     $NetBSD: cac.c,v 1.7 2000/07/06 01:47:35 thorpej Exp $  */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cac.c,v 1.6 2000/06/13 13:36:46 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cac.c,v 1.7 2000/07/06 01:47:35 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -175,7 +175,7 @@
        printf("shutting down cac devices...");
 
        for (i = 0; i < cac_cd.cd_ndevs; i++) {
-               if ((sc = cac_cd.cd_devs[i]) == NULL)
+               if ((sc = device_lookup(&cac_cd, i)) == NULL)
                        continue; 
                /* XXX documentation on this is a bit fuzzy. */
                memset(buf, 0, sizeof (buf));
diff -r 1c4e4ef30b5d -r 15be21209c30 sys/dev/ic/clmpcc.c
--- a/sys/dev/ic/clmpcc.c       Thu Jul 06 01:21:46 2000 +0000
+++ b/sys/dev/ic/clmpcc.c       Thu Jul 06 01:47:34 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clmpcc.c,v 1.10 2000/03/19 10:38:43 scw Exp $ */
+/*     $NetBSD: clmpcc.c,v 1.11 2000/07/06 01:47:35 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -496,12 +496,10 @@
        struct tty *tp;
        int oldch;
        int error;
-       int unit;
- 
-       if ( (unit = CLMPCCUNIT(dev)) >= clmpcc_cd.cd_ndevs ||
-            (sc = clmpcc_cd.cd_devs[unit]) == NULL ) {
-               return ENXIO;
-       }
+
+       sc = device_lookup(&clmpcc_cd, CLMPCCUNIT(dev));
+       if (sc == NULL)
+               return (ENXIO);
 
        ch = &sc->sc_chans[CLMPCCCHAN(dev)];
 
@@ -600,7 +598,8 @@
        int flag, mode;
        struct proc *p;
 {
-       struct clmpcc_softc     *sc = clmpcc_cd.cd_devs[CLMPCCUNIT(dev)];
+       struct clmpcc_softc     *sc =
+               device_lookup(&clmpcc_cd, CLMPCCUNIT(dev));
        struct clmpcc_chan      *ch = &sc->sc_chans[CLMPCCCHAN(dev)];
        struct tty              *tp = ch->ch_tty;
        int s;
@@ -634,7 +633,7 @@
        struct uio *uio;
        int flag;
 {
-       struct clmpcc_softc *sc = clmpcc_cd.cd_devs[CLMPCCUNIT(dev)];
+       struct clmpcc_softc *sc = device_lookup(&clmpcc_cd, CLMPCCUNIT(dev));
        struct tty *tp = sc->sc_chans[CLMPCCCHAN(dev)].ch_tty;
  
        return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
@@ -646,7 +645,7 @@
        struct uio *uio;
        int flag;
 {
-       struct clmpcc_softc *sc = clmpcc_cd.cd_devs[CLMPCCUNIT(dev)];
+       struct clmpcc_softc *sc = device_lookup(&clmpcc_cd, CLMPCCUNIT(dev));
        struct tty *tp = sc->sc_chans[CLMPCCCHAN(dev)].ch_tty;
  
        return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
@@ -656,7 +655,7 @@
 clmpcctty(dev)
        dev_t dev;
 {
-       struct clmpcc_softc *sc = clmpcc_cd.cd_devs[CLMPCCUNIT(dev)];
+       struct clmpcc_softc *sc = device_lookup(&clmpcc_cd, CLMPCCUNIT(dev));
 
        return (sc->sc_chans[CLMPCCCHAN(dev)].ch_tty);
 }
@@ -669,7 +668,7 @@
        int flag;
        struct proc *p;
 {
-       struct clmpcc_softc *sc = clmpcc_cd.cd_devs[CLMPCCUNIT(dev)];
+       struct clmpcc_softc *sc = device_lookup(&clmpcc_cd, CLMPCCUNIT(dev));
        struct clmpcc_chan *ch = &sc->sc_chans[CLMPCCCHAN(dev)];
        struct tty *tp = ch->ch_tty;
        int error;
@@ -828,7 +827,8 @@
        struct tty *tp;
        struct termios *t;
 {
-       struct clmpcc_softc *sc = clmpcc_cd.cd_devs[CLMPCCUNIT(tp->t_dev)];
+       struct clmpcc_softc *sc =
+           device_lookup(&clmpcc_cd, CLMPCCUNIT(tp->t_dev));
        struct clmpcc_chan *ch = &sc->sc_chans[CLMPCCCHAN(tp->t_dev)];
        u_char cor;
        u_char oldch;
@@ -1019,7 +1019,8 @@
 clmpcc_start(tp)
        struct tty *tp;
 {
-       struct clmpcc_softc *sc = clmpcc_cd.cd_devs[CLMPCCUNIT(tp->t_dev)];
+       struct clmpcc_softc *sc =
+           device_lookup(&clmpcc_cd, CLMPCCUNIT(tp->t_dev));
        struct clmpcc_chan *ch = &sc->sc_chans[CLMPCCCHAN(tp->t_dev)];
        u_int oldch;
        int s;
@@ -1066,7 +1067,8 @@
        struct tty *tp;
        int flag;
 {
-       struct clmpcc_softc *sc = clmpcc_cd.cd_devs[CLMPCCUNIT(tp->t_dev)];
+       struct clmpcc_softc *sc =
+           device_lookup(&clmpcc_cd, CLMPCCUNIT(tp->dev));
        struct clmpcc_chan *ch = &sc->sc_chans[CLMPCCCHAN(tp->t_dev)];
        int s;
 
diff -r 1c4e4ef30b5d -r 15be21209c30 sys/dev/ic/com.c
--- a/sys/dev/ic/com.c  Thu Jul 06 01:21:46 2000 +0000
+++ b/sys/dev/ic/com.c  Thu Jul 06 01:47:34 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: com.c,v 1.172 2000/05/03 19:19:04 thorpej Exp $        */
+/*     $NetBSD: com.c,v 1.173 2000/07/06 01:47:36 thorpej Exp $        */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -744,16 +744,13 @@
        int flag, mode;
        struct proc *p;
 {
-       int unit = COMUNIT(dev);
        struct com_softc *sc;
        struct tty *tp;
        int s, s2;
        int error;
- 
-       if (unit >= com_cd.cd_ndevs)
-               return (ENXIO);
-       sc = com_cd.cd_devs[unit];
-       if (sc == 0 || !ISSET(sc->sc_hwflags, COM_HW_DEV_OK) ||
+
+       sc = device_lookup(&com_cd, COMUNIT(dev));
+       if (sc == NULL || !ISSET(sc->sc_hwflags, COM_HW_DEV_OK) ||
            sc->sc_rbuf == NULL)
                return (ENXIO);
 
@@ -895,7 +892,7 @@
        int flag, mode;
        struct proc *p;
 {
-       struct com_softc *sc = com_cd.cd_devs[COMUNIT(dev)];
+       struct com_softc *sc = device_lookup(&com_cd, COMUNIT(dev));
        struct tty *tp = sc->sc_tty;
 
        /* XXX This is for cons.c. */
@@ -926,7 +923,7 @@
        struct uio *uio;
        int flag;
 {
-       struct com_softc *sc = com_cd.cd_devs[COMUNIT(dev)];
+       struct com_softc *sc = device_lookup(&com_cd, COMUNIT(dev));
        struct tty *tp = sc->sc_tty;
 
        if (COM_ISALIVE(sc) == 0)
@@ -941,7 +938,7 @@
        struct uio *uio;
        int flag;
 {
-       struct com_softc *sc = com_cd.cd_devs[COMUNIT(dev)];
+       struct com_softc *sc = device_lookup(&com_cd, COMUNIT(dev));
        struct tty *tp = sc->sc_tty;
 
        if (COM_ISALIVE(sc) == 0)
@@ -954,7 +951,7 @@



Home | Main Index | Thread Index | Old Index