Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/isa Use device_lookup().
details: https://anonhg.NetBSD.org/src/rev/ce55082bb6f9
branches: trunk
changeset: 494379:ce55082bb6f9
user: thorpej <thorpej%NetBSD.org@localhost>
date: Thu Jul 06 02:02:48 2000 +0000
description:
Use device_lookup().
diffstat:
sys/dev/isa/fd.c | 21 +++++++++------------
sys/dev/isa/mcd.c | 18 +++++++-----------
sys/dev/isa/satlink.c | 20 ++++++++------------
sys/dev/isa/seagate.c | 4 ++--
sys/dev/isa/wt.c | 19 +++++++------------
5 files changed, 33 insertions(+), 49 deletions(-)
diffs (257 lines):
diff -r dab0368aa2b3 -r ce55082bb6f9 sys/dev/isa/fd.c
--- a/sys/dev/isa/fd.c Thu Jul 06 01:56:23 2000 +0000
+++ b/sys/dev/isa/fd.c Thu Jul 06 02:02:48 2000 +0000
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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;
diff -r dab0368aa2b3 -r ce55082bb6f9 sys/dev/isa/mcd.c
--- a/sys/dev/isa/mcd.c Thu Jul 06 01:56:23 2000 +0000
+++ b/sys/dev/isa/mcd.c Thu Jul 06 02:02:48 2000 +0000
@@ -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 @@
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 @@
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 @@
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 @@
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;
diff -r dab0368aa2b3 -r ce55082bb6f9 sys/dev/isa/satlink.c
--- a/sys/dev/isa/satlink.c Thu Jul 06 01:56:23 2000 +0000
+++ b/sys/dev/isa/satlink.c Thu Jul 06 02:02:48 2000 +0000
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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);
diff -r dab0368aa2b3 -r ce55082bb6f9 sys/dev/isa/seagate.c
--- a/sys/dev/isa/seagate.c Thu Jul 06 01:56:23 2000 +0000
+++ b/sys/dev/isa/seagate.c Thu Jul 06 02:02:48 2000 +0000
@@ -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 @@
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();
diff -r dab0368aa2b3 -r ce55082bb6f9 sys/dev/isa/wt.c
--- a/sys/dev/isa/wt.c Thu Jul 06 01:56:23 2000 +0000
+++ b/sys/dev/isa/wt.c Thu Jul 06 02:02:48 2000 +0000
@@ -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 @@
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 @@
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 @@
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 @@
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;
Home |
Main Index |
Thread Index |
Old Index