Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/6caa39057be8
branches:  trunk
changeset: 494364:6caa39057be8
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jul 06 00:43:04 2000 +0000

description:
Use device_lookup().

diffstat:

 sys/dev/ata/wd.c |  31 ++++++++++---------------------
 sys/dev/audio.c  |  21 +++++++++------------
 sys/dev/midi.c   |  16 ++++++++--------
 3 files changed, 27 insertions(+), 41 deletions(-)

diffs (176 lines):

diff -r e3635117d7fa -r 6caa39057be8 sys/dev/ata/wd.c
--- a/sys/dev/ata/wd.c  Thu Jul 06 00:42:35 2000 +0000
+++ b/sys/dev/ata/wd.c  Thu Jul 06 00:43:04 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wd.c,v 1.207 2000/07/05 23:31:13 thorpej Exp $ */
+/*     $NetBSD: wd.c,v 1.208 2000/07/06 00:43:36 thorpej Exp $ */
 
 /*
  * Copyright (c) 1998 Manuel Bouyer.  All rights reserved.
@@ -713,16 +713,12 @@
        struct proc *p;
 {
        struct wd_softc *wd;
-       int unit, part;
-       int error;
+       int part, error;
 
        WDCDEBUG_PRINT(("wdopen\n"), DEBUG_FUNCS);
-       unit = WDUNIT(dev);
-       if (unit >= wd_cd.cd_ndevs)
-               return ENXIO;
-       wd = wd_cd.cd_devs[unit];
+       wd = device_lookup(&wd_cd, WDUNIT(dev));
        if (wd == NULL)
-               return ENXIO;
+               return (ENXIO);
 
        /*
         * If this is the first open of this device, add a reference
@@ -1098,15 +1094,12 @@
        dev_t dev;
 {
        struct wd_softc *wd;
-       int part, unit, omask;
+       int part, omask;
        int size;
 
        WDCDEBUG_PRINT(("wdsize\n"), DEBUG_FUNCS);
 
-       unit = WDUNIT(dev);
-       if (unit >= wd_cd.cd_ndevs)
-               return (-1);
-       wd = wd_cd.cd_devs[unit];
+       wd = device_lookup(&wd_cd, WDUNIT(dev));
        if (wd == NULL)
                return (-1);
 
@@ -1142,9 +1135,8 @@
 {
        struct wd_softc *wd;    /* disk unit to do the I/O */
        struct disklabel *lp;   /* disk's disklabel */
-       int unit, part;
+       int part, err;
        int nblks;      /* total number of sectors left to write */
-       int err;
        char errbuf[256];
 
        /* Check if recursive dump; if so, punt. */
@@ -1152,12 +1144,9 @@
                return EFAULT;
        wddoingadump = 1;
 
-       unit = WDUNIT(dev);
-       if (unit >= wd_cd.cd_ndevs)
-               return ENXIO;
-       wd = wd_cd.cd_devs[unit];
-       if (wd == (struct wd_softc *)0)
-               return ENXIO;
+       wd = device_lookup(&wd_cd, WDUNIT(dev));
+       if (wd == NULL)
+               return (ENXIO);
 
        part = WDPART(dev);
 
diff -r e3635117d7fa -r 6caa39057be8 sys/dev/audio.c
--- a/sys/dev/audio.c   Thu Jul 06 00:42:35 2000 +0000
+++ b/sys/dev/audio.c   Thu Jul 06 00:43:04 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio.c,v 1.129 2000/06/27 21:25:02 augustss Exp $     */
+/*     $NetBSD: audio.c,v 1.130 2000/07/06 00:43:04 thorpej Exp $      */
 
 /*
  * Copyright (c) 1991-1993 Regents of the University of California.
@@ -555,12 +555,11 @@
        int flags, ifmt;
        struct proc *p;
 {
-       int unit = AUDIOUNIT(dev);
        struct audio_softc *sc;
        int error;
 
-       if (unit >= audio_cd.cd_ndevs ||
-           (sc = audio_cd.cd_devs[unit]) == NULL)
+       sc = device_lookup(&audio_cd, AUDIOUNIT(dev));
+       if (sc == NULL)
                return (ENXIO);
 
        if (sc->sc_dying)
@@ -621,13 +620,12 @@
        struct uio *uio;
        int ioflag;
 {
-       int unit = AUDIOUNIT(dev);
        struct audio_softc *sc;
        int error;
 
-       if (unit >= audio_cd.cd_ndevs ||
-           (sc = audio_cd.cd_devs[unit]) == NULL)
-               return ENXIO;
+       sc = device_lookup(&audio_cd, AUDIOUNIT(dev));
+       if (sc == NULL)
+               return (ENXIO);
 
        if (sc->sc_dying)
                return (EIO);
@@ -657,13 +655,12 @@
        struct uio *uio;
        int ioflag;
 {
-       int unit = AUDIOUNIT(dev);
        struct audio_softc *sc;
        int error;
 
-       if (unit >= audio_cd.cd_ndevs ||
-           (sc = audio_cd.cd_devs[unit]) == NULL)
-               return ENXIO;
+       sc = device_lookup(&audio_cd, AUDIOUNIT(dev));
+       if (sc == NULL)
+               return (ENXIO);
 
        if (sc->sc_dying)
                return (EIO);
diff -r e3635117d7fa -r 6caa39057be8 sys/dev/midi.c
--- a/sys/dev/midi.c    Thu Jul 06 00:42:35 2000 +0000
+++ b/sys/dev/midi.c    Thu Jul 06 00:43:04 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: midi.c,v 1.16 2000/05/06 14:35:28 augustss Exp $       */
+/*     $NetBSD: midi.c,v 1.17 2000/07/06 00:43:04 thorpej Exp $        */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -344,14 +344,14 @@
        int flags, ifmt;
        struct proc *p;
 {
-       int unit = MIDIUNIT(dev);
        struct midi_softc *sc;
        struct midi_hw_if *hw;
        int error;
 
-       if (unit >= midi_cd.cd_ndevs ||
-           (sc = midi_cd.cd_devs[unit]) == NULL)
-               return ENXIO;
+       sc = device_lookup(&midi_cd, MIDIUNIT(dev));
+       if (sc == NULL)
+               return (ENXIO);
+
        DPRINTF(("midiopen %p\n", sc));
 
        hw = sc->hw_if;
@@ -726,12 +726,12 @@
        dev_t dev;
        struct midi_info *mi;
 {
-       int unit = MIDIUNIT(dev);
        struct midi_softc *sc;
 
-       if (unit >= midi_cd.cd_ndevs ||
-           (sc = midi_cd.cd_devs[unit]) == NULL)
+       sc = device_lookup(&midi_cd, MIDIUNIT(dev));
+       if (sc == NULL)
                return;
+
        sc->hw_if->getinfo(sc->hw_hdl, mi);
 }
 



Home | Main Index | Thread Index | Old Index