diff options
| author | tsutsui <tsutsui@NetBSD.org> | 2008-06-11 12:59:10 +0000 |
|---|---|---|
| committer | tsutsui <tsutsui@NetBSD.org> | 2008-06-11 12:59:10 +0000 |
| commit | 937f5cd4e8a72fd67261b8a7c0a6a0a128f5de27 (patch) | |
| tree | b5fbeb9e0efd5879285e8b0ec4c8f44acaf4e9e4 /sys | |
| parent | 13a1e15f0e734b2aa6d14d0e232e04e224f27ca2 (diff) | |
Use device_private() and device_lookup_private() to get softc.
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/arch/amiga/amiga/device.h | 5 | ||||
| -rw-r--r-- | sys/arch/amiga/dev/fd.c | 8 | ||||
| -rw-r--r-- | sys/arch/amiga/dev/ite.c | 6 | ||||
| -rw-r--r-- | sys/arch/amiga/dev/mfc.c | 48 | ||||
| -rw-r--r-- | sys/arch/amiga/dev/ser.c | 15 |
5 files changed, 39 insertions, 43 deletions
diff --git a/sys/arch/amiga/amiga/device.h b/sys/arch/amiga/amiga/device.h index 2b80661ec54..1fcdbc27845 100644 --- a/sys/arch/amiga/amiga/device.h +++ b/sys/arch/amiga/amiga/device.h @@ -1,4 +1,4 @@ -/* $NetBSD: device.h,v 1.10 2005/12/11 12:16:26 christos Exp $ */ +/* $NetBSD: device.h,v 1.11 2008/06/11 12:59:10 tsutsui Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -47,7 +47,6 @@ int matchname(const char *, const char *); extern int amiga_realconfig; -#define getsoftc(cdnam, unit) \ - ((unit) >= (cdnam).cd_ndevs ? NULL : (cdnam).cd_devs[unit]) +#define getsoftc(cdnam, unit) device_lookup_private(&(cdnam), (unit)) #endif /* _AMIGA_DEVICE_H_ */ diff --git a/sys/arch/amiga/dev/fd.c b/sys/arch/amiga/dev/fd.c index 78bc6a14be0..7cfca2753e9 100644 --- a/sys/arch/amiga/dev/fd.c +++ b/sys/arch/amiga/dev/fd.c @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.78 2008/01/02 11:48:22 ad Exp $ */ +/* $NetBSD: fd.c,v 1.79 2008/06/11 12:59:10 tsutsui Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.78 2008/01/02 11:48:22 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.79 2008/06/11 12:59:10 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -396,7 +396,7 @@ fdattach(struct device *pdp, struct device *dp, void *auxp) int i; ap = auxp; - sc = (struct fd_softc *)dp; + sc = device_private(dp); bufq_alloc(&sc->bufq, "disksort", BUFQ_SORT_CYLINDER); callout_init(&sc->calibrate_ch, 0); @@ -1612,7 +1612,7 @@ fdfindwork(int unit) i = -1; continue; } - if ((sc = fd_cd.cd_devs[i]) == NULL) + if ((sc = device_lookup_private(&fd_cd, i)) == NULL) continue; /* diff --git a/sys/arch/amiga/dev/ite.c b/sys/arch/amiga/dev/ite.c index fc5cf7602cc..88d91f6256b 100644 --- a/sys/arch/amiga/dev/ite.c +++ b/sys/arch/amiga/dev/ite.c @@ -1,4 +1,4 @@ -/* $NetBSD: ite.c,v 1.83 2008/05/20 18:28:56 phx Exp $ */ +/* $NetBSD: ite.c,v 1.84 2008/06/11 12:59:10 tsutsui Exp $ */ /* * Copyright (c) 1990 The Regents of the University of California. @@ -83,7 +83,7 @@ #include "opt_ddb.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ite.c,v 1.83 2008/05/20 18:28:56 phx Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ite.c,v 1.84 2008/06/11 12:59:10 tsutsui Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -273,7 +273,7 @@ struct ite_softc * getitesp(dev_t dev) { if (amiga_realconfig && con_itesoftc.grf == NULL) - return(ite_cd.cd_devs[ITEUNIT(dev)]); + return(device_lookup_private(&ite_cd, ITEUNIT(dev))); if (con_itesoftc.grf == NULL) panic("no ite_softc for console"); diff --git a/sys/arch/amiga/dev/mfc.c b/sys/arch/amiga/dev/mfc.c index 4edfd6e2c29..50f03479373 100644 --- a/sys/arch/amiga/dev/mfc.c +++ b/sys/arch/amiga/dev/mfc.c @@ -1,4 +1,4 @@ -/* $NetBSD: mfc.c,v 1.49 2008/05/25 19:22:21 ad Exp $ */ +/* $NetBSD: mfc.c,v 1.50 2008/06/11 12:59:10 tsutsui Exp $ */ /* * Copyright (c) 1982, 1990 The Regents of the University of California. @@ -55,7 +55,7 @@ #include "opt_kgdb.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mfc.c,v 1.49 2008/05/25 19:22:21 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mfc.c,v 1.50 2008/06/11 12:59:10 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -437,8 +437,8 @@ mfcsattach(struct device *pdp, struct device *dp, void *auxp) struct mfc_args *ma; struct mfc_regs *rp; - sc = (struct mfcs_softc *) dp; - scc = (struct mfc_softc *) pdp; + sc = device_private(dp); + scc = device_private(pdp); ma = auxp; if (dp) { @@ -483,9 +483,9 @@ mfcsopen(dev_t dev, int flag, int mode, struct lwp *l) error = 0; unit = dev & 0x1f; - if (unit >= mfcs_cd.cd_ndevs || (mfcs_active & (1 << unit)) == 0) + sc = device_lookup_private(&mfcs_cd, unit); + if (sc == NULL || (mfcs_active & (1 << unit)) == 0) return (ENXIO); - sc = mfcs_cd.cd_devs[unit]; if (sc->sc_tty) tp = sc->sc_tty; @@ -574,7 +574,7 @@ mfcsclose(dev_t dev, int flag, int mode, struct lwp *l) { struct tty *tp; int unit; - struct mfcs_softc *sc = mfcs_cd.cd_devs[dev & 31]; + struct mfcs_softc *sc = device_lookup_private(&mfcs_cd, dev & 31); struct mfc_softc *scc= sc->sc_mfc; unit = dev & 31; @@ -613,7 +613,7 @@ mfcsclose(dev_t dev, int flag, int mode, struct lwp *l) int mfcsread(dev_t dev, struct uio *uio, int flag) { - struct mfcs_softc *sc = mfcs_cd.cd_devs[dev & 31]; + struct mfcs_softc *sc = device_lookup_private(&mfcs_cd, dev & 31); struct tty *tp = sc->sc_tty; if (tp == NULL) return(ENXIO); @@ -623,7 +623,7 @@ mfcsread(dev_t dev, struct uio *uio, int flag) int mfcswrite(dev_t dev, struct uio *uio, int flag) { - struct mfcs_softc *sc = mfcs_cd.cd_devs[dev & 31]; + struct mfcs_softc *sc = device_lookup_private(&mfcs_cd, dev & 31); struct tty *tp = sc->sc_tty; if (tp == NULL) @@ -634,7 +634,7 @@ mfcswrite(dev_t dev, struct uio *uio, int flag) int mfcspoll(dev_t dev, int events, struct lwp *l) { - struct mfcs_softc *sc = mfcs_cd.cd_devs[dev & 31]; + struct mfcs_softc *sc = device_lookup_private(&mfcs_cd, dev & 31); struct tty *tp = sc->sc_tty; if (tp == NULL) @@ -645,7 +645,7 @@ mfcspoll(dev_t dev, int events, struct lwp *l) struct tty * mfcstty(dev_t dev) { - struct mfcs_softc *sc = mfcs_cd.cd_devs[dev & 31]; + struct mfcs_softc *sc = device_lookup_private(&mfcs_cd, dev & 31); return (sc->sc_tty); } @@ -655,7 +655,7 @@ mfcsioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) { register struct tty *tp; register int error; - struct mfcs_softc *sc = mfcs_cd.cd_devs[dev & 31]; + struct mfcs_softc *sc = device_lookup_private(&mfcs_cd, dev & 31); tp = sc->sc_tty; if (!tp) @@ -726,7 +726,7 @@ int mfcsparam(struct tty *tp, struct termios *t) { int cflag, unit, ospeed; - struct mfcs_softc *sc = mfcs_cd.cd_devs[tp->t_dev & 31]; + struct mfcs_softc *sc = device_lookup_private(&mfcs_cd, tp->t_dev & 31); struct mfc_softc *scc= sc->sc_mfc; cflag = t->c_cflag; @@ -793,7 +793,7 @@ mfcsparam(struct tty *tp, struct termios *t) int mfcshwiflow(struct tty *tp, int flag) { - struct mfcs_softc *sc = mfcs_cd.cd_devs[tp->t_dev & 31]; + struct mfcs_softc *sc = device_lookup_private(&mfcs_cd, tp->t_dev & 31); int unit = tp->t_dev & 1; if (flag) @@ -807,7 +807,7 @@ void mfcsstart(struct tty *tp) { int cc, s, unit; - struct mfcs_softc *sc = mfcs_cd.cd_devs[tp->t_dev & 31]; + struct mfcs_softc *sc = device_lookup_private(&mfcs_cd, tp->t_dev & 31); struct mfc_softc *scc= sc->sc_mfc; if ((tp->t_state & TS_ISOPEN) == 0) @@ -878,7 +878,7 @@ mfcsmctl(dev_t dev, int bits, int how) { int unit, s; u_char ub = 0; - struct mfcs_softc *sc = mfcs_cd.cd_devs[dev & 31]; + struct mfcs_softc *sc = device_lookup_private(&mfcs_cd, dev & 31); unit = dev & 1; @@ -953,7 +953,7 @@ mfcintr(void *arg) return (0); unit = device_unit(&scc->sc_dev) * 2; if (istat & 0x02) { /* channel A receive interrupt */ - sc = mfcs_cd.cd_devs[unit]; + sc = device_lookup_private(&mfcs_cd, unit); while (1) { c = regs->du_sra << 8; if ((c & 0x0100) == 0) @@ -974,7 +974,7 @@ mfcintr(void *arg) } } if (istat & 0x20) { /* channel B receive interrupt */ - sc = mfcs_cd.cd_devs[unit + 1]; + sc = device_lookup_private(&mfcs_cd, unit + 1); while (1) { c = regs->du_srb << 8; if ((c & 0x0100) == 0) @@ -995,7 +995,7 @@ mfcintr(void *arg) } } if (istat & 0x01) { /* channel A transmit interrupt */ - sc = mfcs_cd.cd_devs[unit]; + sc = device_lookup_private(&mfcs_cd, unit); tp = sc->sc_tty; if (sc->ptr == sc->end) { tp->t_state &= ~(TS_BUSY | TS_FLUSH); @@ -1010,7 +1010,7 @@ mfcintr(void *arg) regs->du_tba = *sc->ptr++; } if (istat & 0x10) { /* channel B transmit interrupt */ - sc = mfcs_cd.cd_devs[unit + 1]; + sc = device_lookup_private(&mfcs_cd, unit + 1); tp = sc->sc_tty; if (sc->ptr == sc->end) { tp->t_state &= ~(TS_BUSY | TS_FLUSH); @@ -1034,7 +1034,7 @@ void mfcsxintr(int unit) { int s1, s2, ovfl; - struct mfcs_softc *sc = mfcs_cd.cd_devs[unit]; + struct mfcs_softc *sc = device_lookup_private(&mfcs_cd, unit); struct tty *tp = sc->sc_tty; /* @@ -1077,7 +1077,7 @@ mfcsxintr(int unit) void mfcseint(int unit, int stat) { - struct mfcs_softc *sc = mfcs_cd.cd_devs[unit]; + struct mfcs_softc *sc = device_lookup_private(&mfcs_cd, unit); struct tty *tp; u_char ch; int c; @@ -1109,7 +1109,7 @@ mfcseint(int unit, int stat) if (stat & 0x1000) log(LOG_WARNING, "%s: fifo overflow\n", - ((struct mfcs_softc *)mfcs_cd.cd_devs[unit])->sc_dev.dv_xname); + device_xname(device_lookup_private(&mfcs_cd, unit))); tp->t_linesw->l_rint(c, tp); } @@ -1124,7 +1124,7 @@ void mfcsmint(int unit) { struct tty *tp; - struct mfcs_softc *sc = mfcs_cd.cd_devs[unit]; + struct mfcs_softc *sc = device_lookup_private(&mfcs_cd, unit); u_char stat, last, istat; tp = sc->sc_tty; diff --git a/sys/arch/amiga/dev/ser.c b/sys/arch/amiga/dev/ser.c index 146e404de8e..c7319c22b97 100644 --- a/sys/arch/amiga/dev/ser.c +++ b/sys/arch/amiga/dev/ser.c @@ -1,4 +1,4 @@ -/* $NetBSD: ser.c,v 1.77 2007/11/19 18:51:37 ad Exp $ */ +/* $NetBSD: ser.c,v 1.78 2008/06/11 12:59:10 tsutsui Exp $ */ /* * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. @@ -40,7 +40,7 @@ #include "opt_kgdb.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ser.c,v 1.77 2007/11/19 18:51:37 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ser.c,v 1.78 2008/06/11 12:59:10 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -223,7 +223,7 @@ serattach(struct device *pdp, struct device *dp, void *auxp) struct tty *tp; u_short ir; - sc = (struct ser_softc *)dp; + sc = device_private(dp); ir = custom.intenar; if (serconsole == 0) @@ -281,11 +281,8 @@ seropen(dev_t dev, int flag, int mode, struct lwp *l) error = 0; unit = SERUNIT(dev); - if (unit >= ser_cd.cd_ndevs) - return (ENXIO); - - sc = ser_cd.cd_devs[unit]; - if (sc == 0) + sc = device_lookup_private(&ser_cd, unit); + if (sc == NULL) return (ENXIO); /* XXX com.c: insert KGDB check here */ @@ -372,7 +369,7 @@ serclose(dev_t dev, int flag, int mode, struct lwp *l) struct ser_softc *sc; struct tty *tp; - sc = ser_cd.cd_devs[0]; + sc = device_lookup_private(&ser_cd, SERUNIT(dev)); tp = ser_tty; /* XXX This is for cons.c, according to com.c */ |
