Use device_lookup().

This commit is contained in:
thorpej 2000-07-06 02:02:48 +00:00
parent b47890a934
commit d28fe378bc
5 changed files with 33 additions and 49 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: fd.c,v 1.6 2000/06/28 16:27:53 mrg Exp $ */
/* $NetBSD: fd.c,v 1.7 2000/07/06 02:02:48 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -524,7 +524,7 @@ void
fdstrategy(bp)
register struct buf *bp; /* IO operation to perform */
{
struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(bp->b_dev)];
struct fd_softc *fd = device_lookup(&fd_cd, FDUNIT(bp->b_dev));
int sz;
int s;
@ -765,16 +765,13 @@ fdopen(dev, flags, mode, p)
int mode;
struct proc *p;
{
int unit;
struct fd_softc *fd;
struct fd_type *type;
unit = FDUNIT(dev);
if (unit >= fd_cd.cd_ndevs)
return ENXIO;
fd = fd_cd.cd_devs[unit];
if (fd == 0)
return ENXIO;
fd = device_lookup(&fd_cd, FDUNIT(dev));
if (fd == NULL)
return (ENXIO);
type = fd_dev_to_type(fd, dev);
if (type == NULL)
return ENXIO;
@ -798,7 +795,7 @@ fdclose(dev, flags, mode, p)
int mode;
struct proc *p;
{
struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(dev)];
struct fd_softc *fd = device_lookup(&fd_cd, FDUNIT(dev));
fd->sc_flags &= ~FD_OPEN;
fd->sc_opts &= ~(FDOPT_NORETRY|FDOPT_SILENT);
@ -1270,7 +1267,7 @@ fdioctl(dev, cmd, addr, flag, p)
int flag;
struct proc *p;
{
struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(dev)];
struct fd_softc *fd = device_lookup(&fd_cd, FDUNIT(dev));
struct fdformat_parms *form_parms;
struct fdformat_cmd *form_cmd;
struct ne7_fd_formb fd_formb;
@ -1443,7 +1440,7 @@ fdformat(dev, finfo, p)
struct proc *p;
{
int rv = 0, s;
struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(dev)];
struct fd_softc *fd = device_lookup(&fd_cd, FDUNIT(dev));
struct fd_type *type = fd->sc_type;
struct buf *bp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mcd.c,v 1.66 2000/03/23 07:01:35 thorpej Exp $ */
/* $NetBSD: mcd.c,v 1.67 2000/07/06 02:02:48 thorpej Exp $ */
/*
* Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved.
@ -318,15 +318,11 @@ mcdopen(dev, flag, fmt, p)
int flag, fmt;
struct proc *p;
{
int error;
int unit, part;
int error, part;
struct mcd_softc *sc;
unit = MCDUNIT(dev);
if (unit >= mcd_cd.cd_ndevs)
return ENXIO;
sc = mcd_cd.cd_devs[unit];
if (!sc)
sc = device_lookup(&mcd_cd, MCDUNIT(dev));
if (sc == NULL)
return ENXIO;
if ((error = mcdlock(sc)) != 0)
@ -424,7 +420,7 @@ mcdclose(dev, flag, fmt, p)
int flag, fmt;
struct proc *p;
{
struct mcd_softc *sc = mcd_cd.cd_devs[MCDUNIT(dev)];
struct mcd_softc *sc = device_lookup(&mcd_cd, MCDUNIT(dev));
int part = MCDPART(dev);
int error;
@ -460,7 +456,7 @@ void
mcdstrategy(bp)
struct buf *bp;
{
struct mcd_softc *sc = mcd_cd.cd_devs[MCDUNIT(bp->b_dev)];
struct mcd_softc *sc = device_lookup(&mcd_cd, MCDUNIT(bp->b_dev));
struct disklabel *lp = sc->sc_dk.dk_label;
daddr_t blkno;
int s;
@ -601,7 +597,7 @@ mcdioctl(dev, cmd, addr, flag, p)
int flag;
struct proc *p;
{
struct mcd_softc *sc = mcd_cd.cd_devs[MCDUNIT(dev)];
struct mcd_softc *sc = device_lookup(&mcd_cd, MCDUNIT(dev));
int error;
int part;

View File

@ -1,4 +1,4 @@
/* $NetBSD: satlink.c,v 1.10 2000/05/15 23:56:49 thorpej Exp $ */
/* $NetBSD: satlink.c,v 1.11 2000/07/06 02:02:49 thorpej Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -224,11 +224,11 @@ satlinkopen(dev, flags, fmt, p)
int flags, fmt;
struct proc *p;
{
int error, unit = minor(dev);
struct satlink_softc *sc;
int error;
if (unit >= satlink_cd.cd_ndevs ||
(sc = satlink_cd.cd_devs[unit]) == NULL)
sc = device_lookup(&satlink_cd, minor(dev));
if (sc == NULL)
return (ENXIO);
if (sc->sc_flags & SATF_ISOPEN)
@ -260,8 +260,7 @@ satlinkclose(dev, flags, fmt, p)
int flags, fmt;
struct proc *p;
{
int unit = minor(dev);
struct satlink_softc *sc = satlink_cd.cd_devs[unit];
struct satlink_softc *sc = device_lookup(&satlink_cd, minor(dev));
int s;
s = splsoftclock();
@ -280,8 +279,7 @@ satlinkread(dev, uio, flags)
struct uio *uio;
int flags;
{
int unit = minor(dev);
struct satlink_softc *sc = satlink_cd.cd_devs[unit];
struct satlink_softc *sc = device_lookup(&satlink_cd, minor(dev));
int error, s, count, sptr;
int wrapcnt, oresid;
@ -366,8 +364,7 @@ satlinkioctl(dev, cmd, data, flags, p)
int flags;
struct proc *p;
{
int unit = minor(dev);
struct satlink_softc *sc = satlink_cd.cd_devs[unit];
struct satlink_softc *sc = device_lookup(&satlink_cd, minor(dev));
switch (cmd) {
case SATIORESET:
@ -394,8 +391,7 @@ satlinkpoll(dev, events, p)
int events;
struct proc *p;
{
int unit = minor(dev);
struct satlink_softc *sc = satlink_cd.cd_devs[unit];
struct satlink_softc *sc = device_lookup(&satlink_cd, minor(dev));
int s, revents;
revents = events & (POLLOUT | POLLWRNORM);

View File

@ -1,4 +1,4 @@
/* $NetBSD: seagate.c,v 1.37 2000/05/03 21:20:07 mycroft Exp $ */
/* $NetBSD: seagate.c,v 1.38 2000/07/06 02:02:49 thorpej Exp $ */
/*
* ST01/02, Future Domain TMC-885, TMC-950 SCSI driver
@ -705,7 +705,7 @@ sea_main()
loop:
done = 1;
for (unit = 0; unit < sea_cd.cd_ndevs; unit++) {
sea = sea_cd.cd_devs[unit];
sea = device_lookup(&sea_cd, unit);
if (!sea)
continue;
s = splbio();

View File

@ -1,4 +1,4 @@
/* $NetBSD: wt.c,v 1.50 2000/06/26 14:59:04 mrg Exp $ */
/* $NetBSD: wt.c,v 1.51 2000/07/06 02:02:50 thorpej Exp $ */
/*
* Streamer tape driver.
@ -325,11 +325,9 @@ wtopen(dev, flag, mode, p)
struct wt_softc *sc;
int error;
if (unit >= wt_cd.cd_ndevs)
return ENXIO;
sc = wt_cd.cd_devs[unit];
if (!sc)
return ENXIO;
sc = device_lookup(&wt_cd, unit);
if (sc == NULL)
return (ENXIO);
/* Check that device is not in use */
if (sc->flags & TPINUSE)
@ -412,8 +410,7 @@ wtclose(dev, flags, mode, p)
int mode;
struct proc *p;
{
int unit = minor(dev) & T_UNIT;
struct wt_softc *sc = wt_cd.cd_devs[unit];
struct wt_softc *sc = device_lookup(&wt_cd, minor(dev) & T_UNIT);
/* If rewind is pending, do nothing */
if (sc->flags & TPREW)
@ -467,8 +464,7 @@ wtioctl(dev, cmd, addr, flag, p)
int flag;
struct proc *p;
{
int unit = minor(dev) & T_UNIT;
struct wt_softc *sc = wt_cd.cd_devs[unit];
struct wt_softc *sc = device_lookup(&wt_cd, minor(dev) & T_UNIT);
int error, count, op;
switch (cmd) {
@ -567,8 +563,7 @@ void
wtstrategy(bp)
struct buf *bp;
{
int unit = minor(bp->b_dev) & T_UNIT;
struct wt_softc *sc = wt_cd.cd_devs[unit];
struct wt_softc *sc = device_lookup(&wt_cd, minor(bp->b_dev) & T_UNIT);
int s;
bp->b_resid = bp->b_bcount;