Use device_lookup().
This commit is contained in:
parent
fcebfb1295
commit
cfaba33937
|
@ -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.
|
* Copyright (c) 1998 Manuel Bouyer. All rights reserved.
|
||||||
|
@ -713,16 +713,12 @@ wdopen(dev, flag, fmt, p)
|
||||||
struct proc *p;
|
struct proc *p;
|
||||||
{
|
{
|
||||||
struct wd_softc *wd;
|
struct wd_softc *wd;
|
||||||
int unit, part;
|
int part, error;
|
||||||
int error;
|
|
||||||
|
|
||||||
WDCDEBUG_PRINT(("wdopen\n"), DEBUG_FUNCS);
|
WDCDEBUG_PRINT(("wdopen\n"), DEBUG_FUNCS);
|
||||||
unit = WDUNIT(dev);
|
wd = device_lookup(&wd_cd, WDUNIT(dev));
|
||||||
if (unit >= wd_cd.cd_ndevs)
|
|
||||||
return ENXIO;
|
|
||||||
wd = wd_cd.cd_devs[unit];
|
|
||||||
if (wd == NULL)
|
if (wd == NULL)
|
||||||
return ENXIO;
|
return (ENXIO);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this is the first open of this device, add a reference
|
* If this is the first open of this device, add a reference
|
||||||
|
@ -1098,15 +1094,12 @@ wdsize(dev)
|
||||||
dev_t dev;
|
dev_t dev;
|
||||||
{
|
{
|
||||||
struct wd_softc *wd;
|
struct wd_softc *wd;
|
||||||
int part, unit, omask;
|
int part, omask;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
WDCDEBUG_PRINT(("wdsize\n"), DEBUG_FUNCS);
|
WDCDEBUG_PRINT(("wdsize\n"), DEBUG_FUNCS);
|
||||||
|
|
||||||
unit = WDUNIT(dev);
|
wd = device_lookup(&wd_cd, WDUNIT(dev));
|
||||||
if (unit >= wd_cd.cd_ndevs)
|
|
||||||
return (-1);
|
|
||||||
wd = wd_cd.cd_devs[unit];
|
|
||||||
if (wd == NULL)
|
if (wd == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
|
@ -1142,9 +1135,8 @@ wddump(dev, blkno, va, size)
|
||||||
{
|
{
|
||||||
struct wd_softc *wd; /* disk unit to do the I/O */
|
struct wd_softc *wd; /* disk unit to do the I/O */
|
||||||
struct disklabel *lp; /* disk's disklabel */
|
struct disklabel *lp; /* disk's disklabel */
|
||||||
int unit, part;
|
int part, err;
|
||||||
int nblks; /* total number of sectors left to write */
|
int nblks; /* total number of sectors left to write */
|
||||||
int err;
|
|
||||||
char errbuf[256];
|
char errbuf[256];
|
||||||
|
|
||||||
/* Check if recursive dump; if so, punt. */
|
/* Check if recursive dump; if so, punt. */
|
||||||
|
@ -1152,12 +1144,9 @@ wddump(dev, blkno, va, size)
|
||||||
return EFAULT;
|
return EFAULT;
|
||||||
wddoingadump = 1;
|
wddoingadump = 1;
|
||||||
|
|
||||||
unit = WDUNIT(dev);
|
wd = device_lookup(&wd_cd, WDUNIT(dev));
|
||||||
if (unit >= wd_cd.cd_ndevs)
|
if (wd == NULL)
|
||||||
return ENXIO;
|
return (ENXIO);
|
||||||
wd = wd_cd.cd_devs[unit];
|
|
||||||
if (wd == (struct wd_softc *)0)
|
|
||||||
return ENXIO;
|
|
||||||
|
|
||||||
part = WDPART(dev);
|
part = WDPART(dev);
|
||||||
|
|
||||||
|
|
|
@ -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.
|
* Copyright (c) 1991-1993 Regents of the University of California.
|
||||||
|
@ -555,12 +555,11 @@ audioopen(dev, flags, ifmt, p)
|
||||||
int flags, ifmt;
|
int flags, ifmt;
|
||||||
struct proc *p;
|
struct proc *p;
|
||||||
{
|
{
|
||||||
int unit = AUDIOUNIT(dev);
|
|
||||||
struct audio_softc *sc;
|
struct audio_softc *sc;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (unit >= audio_cd.cd_ndevs ||
|
sc = device_lookup(&audio_cd, AUDIOUNIT(dev));
|
||||||
(sc = audio_cd.cd_devs[unit]) == NULL)
|
if (sc == NULL)
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
|
|
||||||
if (sc->sc_dying)
|
if (sc->sc_dying)
|
||||||
|
@ -621,13 +620,12 @@ audioread(dev, uio, ioflag)
|
||||||
struct uio *uio;
|
struct uio *uio;
|
||||||
int ioflag;
|
int ioflag;
|
||||||
{
|
{
|
||||||
int unit = AUDIOUNIT(dev);
|
|
||||||
struct audio_softc *sc;
|
struct audio_softc *sc;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (unit >= audio_cd.cd_ndevs ||
|
sc = device_lookup(&audio_cd, AUDIOUNIT(dev));
|
||||||
(sc = audio_cd.cd_devs[unit]) == NULL)
|
if (sc == NULL)
|
||||||
return ENXIO;
|
return (ENXIO);
|
||||||
|
|
||||||
if (sc->sc_dying)
|
if (sc->sc_dying)
|
||||||
return (EIO);
|
return (EIO);
|
||||||
|
@ -657,13 +655,12 @@ audiowrite(dev, uio, ioflag)
|
||||||
struct uio *uio;
|
struct uio *uio;
|
||||||
int ioflag;
|
int ioflag;
|
||||||
{
|
{
|
||||||
int unit = AUDIOUNIT(dev);
|
|
||||||
struct audio_softc *sc;
|
struct audio_softc *sc;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (unit >= audio_cd.cd_ndevs ||
|
sc = device_lookup(&audio_cd, AUDIOUNIT(dev));
|
||||||
(sc = audio_cd.cd_devs[unit]) == NULL)
|
if (sc == NULL)
|
||||||
return ENXIO;
|
return (ENXIO);
|
||||||
|
|
||||||
if (sc->sc_dying)
|
if (sc->sc_dying)
|
||||||
return (EIO);
|
return (EIO);
|
||||||
|
|
|
@ -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.
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||||
|
@ -344,14 +344,14 @@ midiopen(dev, flags, ifmt, p)
|
||||||
int flags, ifmt;
|
int flags, ifmt;
|
||||||
struct proc *p;
|
struct proc *p;
|
||||||
{
|
{
|
||||||
int unit = MIDIUNIT(dev);
|
|
||||||
struct midi_softc *sc;
|
struct midi_softc *sc;
|
||||||
struct midi_hw_if *hw;
|
struct midi_hw_if *hw;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (unit >= midi_cd.cd_ndevs ||
|
sc = device_lookup(&midi_cd, MIDIUNIT(dev));
|
||||||
(sc = midi_cd.cd_devs[unit]) == NULL)
|
if (sc == NULL)
|
||||||
return ENXIO;
|
return (ENXIO);
|
||||||
|
|
||||||
DPRINTF(("midiopen %p\n", sc));
|
DPRINTF(("midiopen %p\n", sc));
|
||||||
|
|
||||||
hw = sc->hw_if;
|
hw = sc->hw_if;
|
||||||
|
@ -726,12 +726,12 @@ midi_getinfo(dev, mi)
|
||||||
dev_t dev;
|
dev_t dev;
|
||||||
struct midi_info *mi;
|
struct midi_info *mi;
|
||||||
{
|
{
|
||||||
int unit = MIDIUNIT(dev);
|
|
||||||
struct midi_softc *sc;
|
struct midi_softc *sc;
|
||||||
|
|
||||||
if (unit >= midi_cd.cd_ndevs ||
|
sc = device_lookup(&midi_cd, MIDIUNIT(dev));
|
||||||
(sc = midi_cd.cd_devs[unit]) == NULL)
|
if (sc == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sc->hw_if->getinfo(sc->hw_hdl, mi);
|
sc->hw_if->getinfo(sc->hw_hdl, mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue