diff options
| author | matt <matt@NetBSD.org> | 2008-03-11 05:34:01 +0000 |
|---|---|---|
| committer | matt <matt@NetBSD.org> | 2008-03-11 05:34:01 +0000 |
| commit | dfba816635b288ffc525cb86146857ef1a9333c3 (patch) | |
| tree | 898fe10604ba10d8d2a1f5c5550d1440a5c64dae /sys/dev | |
| parent | 0e65dd74d1d276a3124e93332c1864e95151d7d1 (diff) | |
Rototill the vax code. Switch to devicet/PRIV_ALLOC. Cleanup vax autoconf
code. Move to prototype definitions. staticfy, constify, avoid casting.
Use device_* accessors.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/bi/bi.c | 23 | ||||
| -rw-r--r-- | sys/dev/bi/bivar.h | 4 | ||||
| -rw-r--r-- | sys/dev/bi/files.bi | 4 | ||||
| -rw-r--r-- | sys/dev/bi/if_ni.c | 8 | ||||
| -rw-r--r-- | sys/dev/bi/kdb.c | 64 | ||||
| -rw-r--r-- | sys/dev/bi/uba_bi.c | 24 | ||||
| -rw-r--r-- | sys/dev/dec/dz.c | 134 | ||||
| -rw-r--r-- | sys/dev/ic/sgec.c | 167 | ||||
| -rw-r--r-- | sys/dev/ic/sgecvar.h | 4 | ||||
| -rw-r--r-- | sys/dev/qbus/dhu.c | 225 | ||||
| -rw-r--r-- | sys/dev/qbus/dz_uba.c | 17 | ||||
| -rw-r--r-- | sys/dev/qbus/files.uba | 4 | ||||
| -rw-r--r-- | sys/dev/qbus/if_de.c | 85 | ||||
| -rw-r--r-- | sys/dev/qbus/if_qe.c | 78 | ||||
| -rw-r--r-- | sys/dev/qbus/if_qt.c | 122 | ||||
| -rw-r--r-- | sys/dev/qbus/if_uba.c | 6 | ||||
| -rw-r--r-- | sys/dev/qbus/qd.c | 26 | ||||
| -rw-r--r-- | sys/dev/qbus/rf.c | 91 | ||||
| -rw-r--r-- | sys/dev/qbus/rl.c | 161 | ||||
| -rw-r--r-- | sys/dev/qbus/rlvar.h | 10 | ||||
| -rw-r--r-- | sys/dev/qbus/ts.c | 205 | ||||
| -rw-r--r-- | sys/dev/qbus/uba.c | 27 | ||||
| -rw-r--r-- | sys/dev/qbus/ubavar.h | 14 | ||||
| -rw-r--r-- | sys/dev/qbus/uda.c | 96 | ||||
| -rw-r--r-- | sys/dev/xmi/bi_xmi.c | 9 | ||||
| -rw-r--r-- | sys/dev/xmi/files.xmi | 4 | ||||
| -rw-r--r-- | sys/dev/xmi/xmi.c | 18 | ||||
| -rw-r--r-- | sys/dev/xmi/xmivar.h | 10 |
28 files changed, 758 insertions, 882 deletions
diff --git a/sys/dev/bi/bi.c b/sys/dev/bi/bi.c index c4312b2169a..3a968124cb4 100644 --- a/sys/dev/bi/bi.c +++ b/sys/dev/bi/bi.c @@ -1,4 +1,4 @@ -/* $NetBSD: bi.c,v 1.23 2007/10/19 11:59:37 ad Exp $ */ +/* $NetBSD: bi.c,v 1.24 2008/03/11 05:34:01 matt Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bi.c,v 1.23 2007/10/19 11:59:37 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bi.c,v 1.24 2008/03/11 05:34:01 matt Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -54,7 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: bi.c,v 1.23 2007/10/19 11:59:37 ad Exp $"); static int bi_print(void *, const char *); -struct bi_list bi_list[] = { +static const struct bi_list bi_list[] = { {BIDT_MS820, DT_HAVDRV, "ms820"}, {BIDT_DRB32, DT_UNSUPP, "drb32"}, {BIDT_DWBUA, DT_HAVDRV|DT_ADAPT, "dwbua"}, @@ -74,12 +74,10 @@ struct bi_list bi_list[] = { }; int -bi_print(aux, name) - void *aux; - const char *name; +bi_print(void *aux, const char *name) { struct bi_attach_args *ba = aux; - struct bi_list *bl; + const struct bi_list *bl; u_int16_t nr; nr = bus_space_read_2(ba->ba_iot, ba->ba_ioh, 0); @@ -111,13 +109,12 @@ bi_print(aux, name) } void -bi_attach(sc) - struct bi_softc *sc; +bi_attach(struct bi_softc *sc) { struct bi_attach_args ba; int nodenr; - printf("\n"); + aprint_normal("\n"); ba.ba_iot = sc->sc_iot; ba.ba_busnr = sc->sc_busnr; @@ -133,8 +130,8 @@ bi_attach(sc) for (nodenr = 0; nodenr < NNODEBI; nodenr++) { if (bus_space_map(sc->sc_iot, sc->sc_addr + BI_NODE(nodenr), BI_NODESIZE, 0, &ba.ba_ioh)) { - printf("bi_attach: bus_space_map failed, node %d\n", - nodenr); + aprint_error_dev(sc->sc_dev, + "bus_space_map failed, node %d\n", nodenr); return; } if (badaddr((void *)ba.ba_ioh, 4) || @@ -144,6 +141,6 @@ bi_attach(sc) } ba.ba_nodenr = nodenr; ba.ba_ivec = sc->sc_lastiv + 64 + 4 * nodenr; /* all on spl5 */ - config_found(&sc->sc_dev, &ba, bi_print); + config_found(sc->sc_dev, &ba, bi_print); } } diff --git a/sys/dev/bi/bivar.h b/sys/dev/bi/bivar.h index 9bc3adcbdd0..c42dd39dd79 100644 --- a/sys/dev/bi/bivar.h +++ b/sys/dev/bi/bivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: bivar.h,v 1.12 2005/12/11 12:21:15 christos Exp $ */ +/* $NetBSD: bivar.h,v 1.13 2008/03/11 05:34:01 matt Exp $ */ /* * Copyright (c) 1996, 1999 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -37,7 +37,7 @@ * per-BI-adapter state. */ struct bi_softc { - struct device sc_dev; + device_t sc_dev; bus_space_tag_t sc_iot; /* Space tag for the BI bus */ bus_dma_tag_t sc_dmat; bus_addr_t sc_addr; /* Address base address for this bus */ diff --git a/sys/dev/bi/files.bi b/sys/dev/bi/files.bi index f7ea75c1c87..eac22fc4371 100644 --- a/sys/dev/bi/files.bi +++ b/sys/dev/bi/files.bi @@ -1,10 +1,10 @@ -# $NetBSD: files.bi,v 1.2 2000/04/09 16:49:57 ragge Exp $ +# $NetBSD: files.bi,v 1.3 2008/03/11 05:34:01 matt Exp $ # # Config file and device description for machine-independent # code for devices Digital Equipment Corp. BI bus. # Included by ports that need it. -device bi { node=-1 } +device bi { node=-1 }: bus file dev/bi/bi.c bi diff --git a/sys/dev/bi/if_ni.c b/sys/dev/bi/if_ni.c index 200d6c20c45..3c194d97dfe 100644 --- a/sys/dev/bi/if_ni.c +++ b/sys/dev/bi/if_ni.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ni.c,v 1.33 2007/10/19 11:59:37 ad Exp $ */ +/* $NetBSD: if_ni.c,v 1.34 2008/03/11 05:34:01 matt Exp $ */ /* * Copyright (c) 2000 Ludd, University of Lule}, Sweden. All rights reserved. * @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ni.c,v 1.33 2007/10/19 11:59:37 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ni.c,v 1.34 2008/03/11 05:34:01 matt Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -140,8 +140,8 @@ struct ni_softc { u_int8_t sc_enaddr[ETHER_ADDR_LEN]; }; -static int nimatch(struct device *, struct cfdata *, void *); -static void niattach(struct device *, struct device *, void *); +static int nimatch(device_t, cfdata_t, void *); +static void niattach(device_t, device_t, void *); static void niinit(struct ni_softc *); static void nistart(struct ifnet *); static void niintr(void *); diff --git a/sys/dev/bi/kdb.c b/sys/dev/bi/kdb.c index 481d0e45d4c..51637b9cc35 100644 --- a/sys/dev/bi/kdb.c +++ b/sys/dev/bi/kdb.c @@ -1,4 +1,4 @@ -/* $NetBSD: kdb.c,v 1.41 2007/10/19 11:59:37 ad Exp $ */ +/* $NetBSD: kdb.c,v 1.42 2008/03/11 05:34:01 matt Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kdb.c,v 1.41 2007/10/19 11:59:37 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kdb.c,v 1.42 2008/03/11 05:34:01 matt Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -80,24 +80,24 @@ __KERNEL_RCSID(0, "$NetBSD: kdb.c,v 1.41 2007/10/19 11:59:37 ad Exp $"); * Software status, per controller. */ struct kdb_softc { - struct device sc_dev; /* Autoconfig info */ - struct evcnt sc_intrcnt; /* Interrupt counting */ - void * sc_kdb; /* Struct for kdb communication */ - struct mscp_softc *sc_softc; /* MSCP info (per mscpvar.h) */ + device_t sc_dev; /* Autoconfig info */ + struct evcnt sc_intrcnt; /* Interrupt counting */ + void *sc_kdb; /* Struct for kdb communication */ + struct mscp_softc *sc_softc; /* MSCP info (per mscpvar.h) */ bus_dma_tag_t sc_dmat; bus_dmamap_t sc_cmap; /* Control structures */ bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; }; -int kdbmatch(struct device *, struct cfdata *, void *); -void kdbattach(struct device *, struct device *, void *); +int kdbmatch(device_t, cfdata_t, void *); +void kdbattach(device_t, device_t, void *); void kdbreset(int); void kdbintr(void *); -void kdbctlrdone(struct device *); +void kdbctlrdone(device_t ); int kdbprint(void *, const char *); -void kdbsaerror(struct device *, int); -void kdbgo(struct device *, struct mscp_xi *); +void kdbsaerror(device_t, int); +void kdbgo(device_t, struct mscp_xi *); CFATTACH_DECL(kdb, sizeof(struct kdb_softc), kdbmatch, kdbattach, NULL, NULL); @@ -112,9 +112,7 @@ struct mscp_ctlr kdb_mscp_ctlr = { }; int -kdbprint(aux, name) - void *aux; - const char *name; +kdbprint(void *aux, const char *name) { if (name) aprint_normal("%s: mscpbus", name); @@ -126,9 +124,9 @@ kdbprint(aux, name) */ int kdbmatch(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; + device_t parent; + cfdata_t cf; + void *aux; { struct bi_attach_args *ba = aux; @@ -143,13 +141,11 @@ kdbmatch(parent, cf, aux) } void -kdbattach(parent, self, aux) - struct device *parent, *self; - void *aux; +kdbattach(device_t parent, device_t self, void *aux) { - struct kdb_softc *sc = (void *)self; - struct bi_attach_args *ba = aux; - struct mscp_attach_args ma; + struct kdb_softc *sc = device_private(self); + struct bi_attach_args *ba = aux; + struct mscp_attach_args ma; volatile int i = 10000; int error, rseg; bus_dma_segment_t seg; @@ -158,7 +154,7 @@ kdbattach(parent, self, aux) bi_intr_establish(ba->ba_icookie, ba->ba_ivec, kdbintr, sc, &sc->sc_intrcnt); evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, NULL, - sc->sc_dev.dv_xname, "intr"); + device_xname(sc->sc_dev), "intr"); sc->sc_iot = ba->ba_iot; sc->sc_ioh = ba->ba_ioh; @@ -216,15 +212,13 @@ err2: bus_dmamem_unmap(sc->sc_dmat, sc->sc_kdb, KDB_WL(BIREG_BCICSR, KDB_RL(BIREG_BCICSR) | BCI_STOPEN | BCI_IDENTEN | BCI_UINTEN | BCI_INTEN); KDB_WL(BIREG_UINTRCSR, ba->ba_ivec); - config_found(&sc->sc_dev, &ma, kdbprint); + config_found(sc->sc_dev, &ma, kdbprint); } void -kdbgo(usc, mxi) - struct device *usc; - struct mscp_xi *mxi; +kdbgo(device_t usc, struct mscp_xi *mxi) { - struct kdb_softc *sc = (void *)usc; + struct kdb_softc *sc = device_private(usc); struct buf *bp = mxi->mxi_bp; struct mscp *mp = mxi->mxi_mp; u_int32_t addr = (u_int32_t)bp->b_data; @@ -280,15 +274,13 @@ kdbgo(usc, mxi) } void -kdbsaerror(usc, doreset) - struct device *usc; - int doreset; +kdbsaerror(device_t usc, int doreset) { - struct kdb_softc *sc = (void *)usc; + struct kdb_softc *sc = device_private(usc); if ((KDB_RS(KDB_SA) & MP_ERR) == 0) return; - printf("%s: controller error, sa=0x%x\n", sc->sc_dev.dv_xname, + printf("%s: controller error, sa=0x%x\n", device_xname(sc->sc_dev), KDB_RS(KDB_SA)); /* What to do now??? */ } @@ -304,7 +296,7 @@ kdbintr(void *arg) struct kdb_softc *sc = arg; if (KDB_RS(KDB_SA) & MP_ERR) { /* ctlr fatal error */ - kdbsaerror(&sc->sc_dev, 1); + kdbsaerror(sc->sc_dev, 1); return; } KERNEL_LOCK(1, NULL); @@ -343,6 +335,6 @@ kdbreset(ctlr) void kdbctlrdone(usc) - struct device *usc; + device_t usc; { } diff --git a/sys/dev/bi/uba_bi.c b/sys/dev/bi/uba_bi.c index 62ea3bbc09d..33ec6bee3a3 100644 --- a/sys/dev/bi/uba_bi.c +++ b/sys/dev/bi/uba_bi.c @@ -1,4 +1,4 @@ -/* $NetBSD: uba_bi.c,v 1.11 2005/12/11 12:21:15 christos Exp $ */ +/* $NetBSD: uba_bi.c,v 1.12 2008/03/11 05:34:01 matt Exp $ */ /* * Copyright (c) 1998 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uba_bi.c,v 1.11 2005/12/11 12:21:15 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uba_bi.c,v 1.12 2008/03/11 05:34:01 matt Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -62,8 +62,8 @@ __KERNEL_RCSID(0, "$NetBSD: uba_bi.c,v 1.11 2005/12/11 12:21:15 christos Exp $") #define BUA(uba) ((struct dwbua_regs *)(uba)) -static int uba_bi_match(struct device *, struct cfdata *, void *); -static void uba_bi_attach(struct device *, struct device *, void *); +static int uba_bi_match(device_t, cfdata_t, void *); +static void uba_bi_attach(device_t, device_t, void *); static void bua_init(struct uba_softc *); static void bua_purge(struct uba_softc *, int); @@ -92,7 +92,7 @@ static void bua_purge(struct uba_softc *, int); static int allocvec; -CFATTACH_DECL(uba_bi, sizeof(struct uba_softc), +CFATTACH_DECL_NEW(uba_bi, sizeof(struct uba_softc), uba_bi_match, uba_bi_attach, NULL, NULL); struct dwbua_regs { @@ -114,10 +114,7 @@ struct dwbua_regs { * Poke at a supposed DWBUA to see if it is there. */ static int -uba_bi_match(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; +uba_bi_match(device_t parent, cfdata_t cf, void *aux) { struct bi_attach_args *ba = aux; @@ -133,12 +130,10 @@ uba_bi_match(parent, cf, aux) } void -uba_bi_attach(parent, self, aux) - struct device *parent, *self; - void *aux; +uba_bi_attach(device_t parent, device_t self, void *aux) { - struct uba_softc *sc = (void *)self; - struct bi_attach_args *ba = aux; + struct uba_softc *sc = device_private(self); + struct bi_attach_args *ba = aux; volatile int timo; if (ba->ba_node->biic.bi_dtype == BIDT_DWBUA) @@ -149,6 +144,7 @@ uba_bi_attach(parent, self, aux) /* * Fill in bus specific data. */ + sc->uh_dev = self; sc->uh_uba = (void *)ba->ba_node; sc->uh_nbdp = NBDPBUA; /* sc->uh_nr is 0; uninteresting here */ diff --git a/sys/dev/dec/dz.c b/sys/dev/dec/dz.c index e399b8a7810..f1482a04e36 100644 --- a/sys/dev/dec/dz.c +++ b/sys/dev/dec/dz.c @@ -1,4 +1,4 @@ -/* $NetBSD: dz.c,v 1.33 2007/11/20 09:16:53 yamt Exp $ */ +/* $NetBSD: dz.c,v 1.34 2008/03/11 05:34:01 matt Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dz.c,v 1.33 2007/11/20 09:16:53 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dz.c,v 1.34 2008/03/11 05:34:01 matt Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -177,14 +177,14 @@ static int dzparam(struct tty *, struct termios *); static unsigned dzmctl(struct dz_softc *, int, int, int); static void dzscan(void *); -dev_type_open(dzopen); -dev_type_close(dzclose); -dev_type_read(dzread); -dev_type_write(dzwrite); -dev_type_ioctl(dzioctl); -dev_type_stop(dzstop); -dev_type_tty(dztty); -dev_type_poll(dzpoll); +static dev_type_open(dzopen); +static dev_type_close(dzclose); +static dev_type_read(dzread); +static dev_type_write(dzwrite); +static dev_type_ioctl(dzioctl); +static dev_type_stop(dzstop); +static dev_type_tty(dztty); +static dev_type_poll(dzpoll); const struct cdevsw dz_cdevsw = { dzopen, dzclose, dzread, dzwrite, dzioctl, @@ -222,9 +222,9 @@ dzattach(struct dz_softc *sc, struct evcnt *parent_evcnt, int consline) } evcnt_attach_dynamic(&sc->sc_rintrcnt, EVCNT_TYPE_INTR, parent_evcnt, - sc->sc_dev.dv_xname, "rintr"); + device_xname(&sc->sc_dev), "rintr"); evcnt_attach_dynamic(&sc->sc_tintrcnt, EVCNT_TYPE_INTR, parent_evcnt, - sc->sc_dev.dv_xname, "tintr"); + device_xname(&sc->sc_dev), "tintr"); /* Console magic keys */ cn_init_magic(&dz_cnm_state); @@ -277,7 +277,7 @@ dzrint(void *arg) if ((c & DZ_RBUF_OVERRUN_ERR) && overrun == 0) { log(LOG_WARNING, "%s: silo overflow, line %d\n", - sc->sc_dev.dv_xname, line); + device_xname(&sc->sc_dev), line); overrun = 1; } @@ -359,19 +359,12 @@ dzxint(void *arg) int dzopen(dev_t dev, int flag, int mode, struct lwp *l) { + const int line = DZ_PORT(minor(dev)); + struct dz_softc *sc = device_lookup(&dz_cd, DZ_I2C(minor(dev))); struct tty *tp; - int unit, line; - struct dz_softc *sc; int error = 0; - unit = DZ_I2C(minor(dev)); - line = DZ_PORT(minor(dev)); - if (unit >= dz_cd.cd_ndevs || dz_cd.cd_devs[unit] == NULL) - return (ENXIO); - - sc = dz_cd.cd_devs[unit]; - - if (line >= sc->sc_type) + if (sc == NULL || line >= sc->sc_type) return ENXIO; /* if some other device is using the line, it's busy */ @@ -381,8 +374,8 @@ dzopen(dev_t dev, int flag, int mode, struct lwp *l) tp = sc->sc_dz[line].dz_tty; if (tp == NULL) return (ENODEV); - tp->t_oproc = dzstart; - tp->t_param = dzparam; + tp->t_oproc = dzstart; + tp->t_param = dzparam; tp->t_dev = dev; if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) @@ -423,16 +416,9 @@ dzopen(dev_t dev, int flag, int mode, struct lwp *l) int dzclose(dev_t dev, int flag, int mode, struct lwp *l) { - struct dz_softc *sc; - struct tty *tp; - int unit, line; - - - unit = DZ_I2C(minor(dev)); - line = DZ_PORT(minor(dev)); - sc = dz_cd.cd_devs[unit]; - - tp = sc->sc_dz[line].dz_tty; + const int line = DZ_PORT(minor(dev)); + struct dz_softc *sc = device_lookup(&dz_cd, DZ_I2C(minor(dev))); + struct tty *tp = sc->sc_dz[line].dz_tty; (*tp->t_linesw->l_close)(tp, flag); @@ -443,44 +429,32 @@ dzclose(dev_t dev, int flag, int mode, struct lwp *l) if ((tp->t_cflag & HUPCL) || tp->t_wopen || !(tp->t_state & TS_ISOPEN)) (void) dzmctl(sc, line, 0, DMSET); - return (ttyclose(tp)); + return ttyclose(tp); } int dzread(dev_t dev, struct uio *uio, int flag) { - struct tty *tp; - struct dz_softc *sc; + struct dz_softc *sc = device_lookup(&dz_cd, DZ_I2C(minor(dev))); + struct tty *tp = sc->sc_dz[DZ_PORT(minor(dev))].dz_tty; - sc = dz_cd.cd_devs[DZ_I2C(minor(dev))]; - - tp = sc->sc_dz[DZ_PORT(minor(dev))].dz_tty; return ((*tp->t_linesw->l_read)(tp, uio, flag)); } int dzwrite(dev_t dev, struct uio *uio, int flag) { - struct tty *tp; - struct dz_softc *sc; - - sc = dz_cd.cd_devs[DZ_I2C(minor(dev))]; - tp = sc->sc_dz[DZ_PORT(minor(dev))].dz_tty; + struct dz_softc *sc = device_lookup(&dz_cd, DZ_I2C(minor(dev))); + struct tty *tp = sc->sc_dz[DZ_PORT(minor(dev))].dz_tty; return ((*tp->t_linesw->l_write)(tp, uio, flag)); } int -dzpoll(dev, events, l) - dev_t dev; - int events; - struct lwp *l; +dzpoll(dev_t dev, int events, struct lwp *l) { - struct tty *tp; - struct dz_softc *sc; - - sc = dz_cd.cd_devs[DZ_I2C(minor(dev))]; - tp = sc->sc_dz[DZ_PORT(minor(dev))].dz_tty; + struct dz_softc *sc = device_lookup(&dz_cd, DZ_I2C(minor(dev))); + struct tty *tp = sc->sc_dz[DZ_PORT(minor(dev))].dz_tty; return ((*tp->t_linesw->l_poll)(tp, events, l)); } @@ -489,16 +463,11 @@ dzpoll(dev, events, l) int dzioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) { - struct dz_softc *sc; - struct tty *tp; - int unit, line; + struct dz_softc *sc = device_lookup(&dz_cd, DZ_I2C(minor(dev))); + const int line = DZ_PORT(minor(dev)); + struct tty *tp = sc->sc_dz[line].dz_tty; int error; - unit = DZ_I2C(minor(dev)); - line = DZ_PORT(minor(dev)); - sc = dz_cd.cd_devs[unit]; - tp = sc->sc_dz[line].dz_tty; - error = (*tp->t_linesw->l_ioctl)(tp, cmd, data, flag, l); if (error >= 0) return (error); @@ -549,20 +518,15 @@ dzioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) struct tty * dztty(dev_t dev) { - struct dz_softc *sc; - struct tty *tp; + struct dz_softc *sc = device_lookup(&dz_cd, DZ_I2C(minor(dev))); - sc = dz_cd.cd_devs[DZ_I2C(minor(dev))]; - tp = sc->sc_dz[DZ_PORT(minor(dev))].dz_tty; - - return (tp); + return sc->sc_dz[DZ_PORT(minor(dev))].dz_tty; } /*ARGSUSED*/ void dzstop(struct tty *tp, int flag) { - if ((tp->t_state & (TS_BUSY | TS_TTSTOP)) == TS_BUSY) tp->t_state |= TS_FLUSH; } @@ -571,20 +535,23 @@ void dzstart(struct tty *tp) { struct dz_softc *sc; - int unit, line, s; + int line; + int s; char state; - unit = DZ_I2C(minor(tp->t_dev)); - line = DZ_PORT(minor(tp->t_dev)); - sc = dz_cd.cd_devs[unit]; - s = spltty(); if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)) { splx(s); return; } - if (!ttypull(tp)) + if (!ttypull(tp)) { + splx(s); return; + } + + line = DZ_PORT(minor(tp->t_dev)); + sc = device_lookup(&dz_cd, DZ_I2C(minor(tp->t_dev))); + tp->t_state |= TS_BUSY; state = dz_read2(sc, sc->sc_dr.dr_tcrw) & 255; if ((state & (1 << line)) == 0) @@ -596,18 +563,14 @@ dzstart(struct tty *tp) static int dzparam(struct tty *tp, struct termios *t) { - struct dz_softc *sc; + struct dz_softc *sc = device_lookup(&dz_cd, DZ_I2C(minor(tp->t_dev))); + const int line = DZ_PORT(minor(tp->t_dev)); int cflag = t->c_cflag; - int unit, line; int ispeed = ttspeedtab(t->c_ispeed, dzspeedtab); int ospeed = ttspeedtab(t->c_ospeed, dzspeedtab); unsigned lpr; int s; - unit = DZ_I2C(minor(tp->t_dev)); - line = DZ_PORT(minor(tp->t_dev)); - sc = dz_cd.cd_devs[unit]; - /* check requested parameters */ if (ospeed < 0 || ispeed < 0 || ispeed != ospeed) return (EINVAL); @@ -732,12 +695,13 @@ dzscan(void *arg) struct dz_softc *sc; struct tty *tp; int n, bit, port; - unsigned csr, tmp; + unsigned int csr; + unsigned int tmp; int s; s = spltty(); for (n = 0; n < dz_cd.cd_ndevs; n++) { - if ((sc = dz_cd.cd_devs[n]) == NULL) + if ((sc = device_lookup(&dz_cd, n)) == NULL) continue; for (port = 0; port < sc->sc_type; port++) { @@ -785,7 +749,7 @@ dzscan(void *arg) * No DMA setup to care about. */ void -dzreset(struct device *dev) +dzreset(device_t dev) { struct dz_softc *sc = (void *)dev; struct tty *tp; diff --git a/sys/dev/ic/sgec.c b/sys/dev/ic/sgec.c index 1e22ad61469..afcaa429a31 100644 --- a/sys/dev/ic/sgec.c +++ b/sys/dev/ic/sgec.c @@ -1,4 +1,4 @@ -/* $NetBSD: sgec.c,v 1.34 2007/10/19 12:00:00 ad Exp $ */ +/* $NetBSD: sgec.c,v 1.35 2008/03/11 05:34:01 matt Exp $ */ /* * Copyright (c) 1999 Ludd, University of Lule}, Sweden. All rights reserved. * @@ -45,7 +45,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sgec.c,v 1.34 2007/10/19 12:00:00 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sgec.c,v 1.35 2008/03/11 05:34:01 matt Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -82,7 +82,7 @@ static int zeioctl(struct ifnet *, u_long, void *); static int ze_add_rxbuf(struct ze_softc *, int); static void ze_setup(struct ze_softc *); static void zetimeout(struct ifnet *); -static int zereset(struct ze_softc *); +static bool zereset(struct ze_softc *); #define ZE_WCSR(csr, val) \ bus_space_write_4(sc->sc_iot, sc->sc_ioh, csr, val) @@ -95,46 +95,47 @@ static int zereset(struct ze_softc *); * to accept packets. */ void -sgec_attach(sc) - struct ze_softc *sc; +sgec_attach(struct ze_softc *sc) { - struct ifnet *ifp = (struct ifnet *)&sc->sc_if; - struct ze_tdes *tp; - struct ze_rdes *rp; + struct ifnet *ifp = &sc->sc_if; + struct ze_tdes *tp; + struct ze_rdes *rp; bus_dma_segment_t seg; int i, rseg, error; /* * Allocate DMA safe memory for descriptors and setup memory. */ - if ((error = bus_dmamem_alloc(sc->sc_dmat, - sizeof(struct ze_cdata), PAGE_SIZE, 0, &seg, 1, &rseg, - BUS_DMA_NOWAIT)) != 0) { - printf(": unable to allocate control data, error = %d\n", + error = bus_dmamem_alloc(sc->sc_dmat, sizeof(struct ze_cdata), + PAGE_SIZE, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT); + if (error) { + aprint_error(": unable to allocate control data, error = %d\n", error); goto fail_0; } - if ((error = bus_dmamem_map(sc->sc_dmat, &seg, rseg, - sizeof(struct ze_cdata), (void **)&sc->sc_zedata, - BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) { - printf(": unable to map control data, error = %d\n", error); + error = bus_dmamem_map(sc->sc_dmat, &seg, rseg, sizeof(struct ze_cdata), + (void **)&sc->sc_zedata, BUS_DMA_NOWAIT|BUS_DMA_COHERENT); + if (error) { + aprint_error( + ": unable to map control data, error = %d\n", error); goto fail_1; } - if ((error = bus_dmamap_create(sc->sc_dmat, - sizeof(struct ze_cdata), 1, - sizeof(struct ze_cdata), 0, BUS_DMA_NOWAIT, - &sc->sc_cmap)) != 0) { - printf(": unable to create control data DMA map, error = %d\n", + error = bus_dmamap_create(sc->sc_dmat, sizeof(struct ze_cdata), 1, + sizeof(struct ze_cdata), 0, BUS_DMA_NOWAIT, &sc->sc_cmap); + if (error) { + aprint_error( + ": unable to create control data DMA map, error = %d\n", error); goto fail_2; } - if ((error = bus_dmamap_load(sc->sc_dmat, sc->sc_cmap, - sc->sc_zedata, sizeof(struct ze_cdata), NULL, - BUS_DMA_NOWAIT)) != 0) { - printf(": unable to load control data DMA map, error = %d\n", + error = bus_dmamap_load(sc->sc_dmat, sc->sc_cmap, sc->sc_zedata, + sizeof(struct ze_cdata), NULL, BUS_DMA_NOWAIT); + if (error) { + aprint_error( + ": unable to load control data DMA map, error = %d\n", error); goto fail_3; } @@ -143,56 +144,62 @@ sgec_attach(sc) * Zero the newly allocated memory. */ memset(sc->sc_zedata, 0, sizeof(struct ze_cdata)); + /* * Create the transmit descriptor DMA maps. */ - for (i = 0; i < TXDESCS; i++) { - if ((error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, + for (i = 0; error == 0 && i < TXDESCS; i++) { + error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, TXDESCS - 1, MCLBYTES, 0, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW, - &sc->sc_xmtmap[i]))) { - printf(": unable to create tx DMA map %d, error = %d\n", - i, error); - goto fail_4; - } + &sc->sc_xmtmap[i]); + } + if (error) { + aprint_error(": unable to create tx DMA map %d, error = %d\n", + i, error); + goto fail_4; } /* * Create receive buffer DMA maps. */ - for (i = 0; i < RXDESCS; i++) { - if ((error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1, - MCLBYTES, 0, BUS_DMA_NOWAIT, - &sc->sc_rcvmap[i]))) { - printf(": unable to create rx DMA map %d, error = %d\n", - i, error); - goto fail_5; - } + for (i = 0; error == 0 && i < RXDESCS; i++) { + error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1, + MCLBYTES, 0, BUS_DMA_NOWAIT, &sc->sc_rcvmap[i]); + } + if (error) { + aprint_error(": unable to create rx DMA map %d, error = %d\n", + i, error); + goto fail_5; } + /* * Pre-allocate the receive buffers. */ - for (i = 0; i < RXDESCS; i++) { - if ((error = ze_add_rxbuf(sc, i)) != 0) { - printf(": unable to allocate or map rx buffer %d\n," - " error = %d\n", i, error); - goto fail_6; - } + for (i = 0; error == 0 && i < RXDESCS; i++) { + error = ze_add_rxbuf(sc, i); + } + + if (error) { + aprint_error( + ": unable to allocate or map rx buffer %d, error = %d\n", + i, error); + goto fail_6; } /* For vmstat -i */ evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, NULL, - sc->sc_dev.dv_xname, "intr"); + device_xname(sc->sc_dev), "intr"); evcnt_attach_dynamic(&sc->sc_rxintrcnt, EVCNT_TYPE_INTR, - &sc->sc_intrcnt, sc->sc_dev.dv_xname, "rx intr"); + &sc->sc_intrcnt, device_xname(sc->sc_dev), "rx intr"); evcnt_attach_dynamic(&sc->sc_txintrcnt, EVCNT_TYPE_INTR, - &sc->sc_intrcnt, sc->sc_dev.dv_xname, "tx intr"); + &sc->sc_intrcnt, device_xname(sc->sc_dev), "tx intr"); evcnt_attach_dynamic(&sc->sc_txdraincnt, EVCNT_TYPE_INTR, - &sc->sc_intrcnt, sc->sc_dev.dv_xname, "tx drain"); + &sc->sc_intrcnt, device_xname(sc->sc_dev), "tx drain"); evcnt_attach_dynamic(&sc->sc_nobufintrcnt, EVCNT_TYPE_INTR, - &sc->sc_intrcnt, sc->sc_dev.dv_xname, "nobuf intr"); + &sc->sc_intrcnt, device_xname(sc->sc_dev), "nobuf intr"); evcnt_attach_dynamic(&sc->sc_nointrcnt, EVCNT_TYPE_INTR, - &sc->sc_intrcnt, sc->sc_dev.dv_xname, "no intr"); + &sc->sc_intrcnt, device_xname(sc->sc_dev), "no intr"); /* * Create ring loops of the buffer chains. @@ -213,7 +220,7 @@ sgec_attach(sc) if (zereset(sc)) return; - strcpy(ifp->if_xname, sc->sc_dev.dv_xname); + strcpy(ifp->if_xname, device_xname(sc->sc_dev)); ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_start = zestart; @@ -227,7 +234,8 @@ sgec_attach(sc) if_attach(ifp); ether_ifattach(ifp, sc->sc_enaddr); - printf("\n%s: hardware address %s\n", sc->sc_dev.dv_xname, + aprint_normal("\n"); + aprint_normal_dev(sc->sc_dev, "hardware address %s\n", ether_sprintf(sc->sc_enaddr)); return; @@ -268,10 +276,9 @@ sgec_attach(sc) * Initialization of interface. */ void -zeinit(sc) - struct ze_softc *sc; +zeinit(struct ze_softc *sc) { - struct ifnet *ifp = (struct ifnet *)&sc->sc_if; + struct ifnet *ifp = &sc->sc_if; struct ze_cdata *zc = sc->sc_zedata; int i; @@ -321,8 +328,7 @@ zeinit(sc) * Start output on interface. */ void -zestart(ifp) - struct ifnet *ifp; +zestart(struct ifnet *ifp) { struct ze_softc *sc = ifp->if_softc; struct ze_cdata *zc = sc->sc_zedata; @@ -353,7 +359,8 @@ zestart(ifp) error = bus_dmamap_load_mbuf(sc->sc_dmat, map, m, BUS_DMA_WRITE); if (error) { - printf("zestart: load_mbuf failed: %d", error); + aprint_error_dev(sc->sc_dev, + "zestart: load_mbuf failed: %d", error); goto out; } @@ -428,8 +435,7 @@ out: if (old_inq < sc->sc_inq) } int -sgec_intr(sc) - struct ze_softc *sc; +sgec_intr(struct ze_softc *sc) { struct ze_cdata *zc = sc->sc_zedata; struct ifnet *ifp = &sc->sc_if; @@ -533,13 +539,10 @@ sgec_intr(sc) * Process an ioctl request. */ int -zeioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +zeioctl(struct ifnet *ifp, u_long cmd, void *data) { struct ze_softc *sc = ifp->if_softc; - struct ifaddr *ifa = (struct ifaddr *)data; + struct ifaddr *ifa = data; int s = splnet(), error = 0; switch (cmd) { @@ -610,9 +613,7 @@ zeioctl(ifp, cmd, data) * Add a receive buffer to the indicated descriptor. */ int -ze_add_rxbuf(sc, i) - struct ze_softc *sc; - int i; +ze_add_rxbuf(struct ze_softc *sc, int i) { struct mbuf *m; struct ze_rdes *rp; @@ -637,7 +638,7 @@ ze_add_rxbuf(sc, i) BUS_DMA_READ|BUS_DMA_NOWAIT); if (error) panic("%s: can't load rx DMA map %d, error = %d", - sc->sc_dev.dv_xname, i, error); + device_xname(sc->sc_dev), i, error); sc->sc_rxmbuf[i] = m; bus_dmamap_sync(sc->sc_dmat, sc->sc_rcvmap[i], 0, @@ -660,8 +661,7 @@ ze_add_rxbuf(sc, i) * Create a setup packet and put in queue for sending. */ void -ze_setup(sc) - struct ze_softc *sc; +ze_setup(struct ze_softc *sc) { struct ether_multi *enm; struct ether_multistep step; @@ -746,15 +746,14 @@ ze_setup(sc) * Check for dead transmit logic. */ void -zetimeout(ifp) - struct ifnet *ifp; +zetimeout(struct ifnet *ifp) { struct ze_softc *sc = ifp->if_softc; if (sc->sc_inq == 0) return; - printf("%s: xmit logic died, resetting...\n", sc->sc_dev.dv_xname); + aprint_error_dev(sc->sc_dev, "xmit logic died, resetting...\n"); /* * Do a reset of interface, to get it going again. * Will it work by just restart the transmit logic? @@ -769,17 +768,16 @@ zetimeout(ifp) * Write ring buffer addresses. * Write SBR. */ -int -zereset(sc) - struct ze_softc *sc; +bool +zereset(struct ze_softc *sc) { int reg, i; ZE_WCSR(ZE_CSR6, ZE_NICSR6_RE); DELAY(50000); if (ZE_RCSR(ZE_CSR6) & ZE_NICSR5_SF) { - printf("%s: selftest failed\n", sc->sc_dev.dv_xname); - return 1; + aprint_error_dev(sc->sc_dev, "selftest failed\n"); + return true; } /* @@ -791,13 +789,14 @@ zereset(sc) i = 10; do { if (i-- == 0) { - printf("Failing SGEC CSR0 init\n"); - return 1; + aprint_error_dev(sc->sc_dev, + "failing SGEC CSR0 init\n"); + return true; } ZE_WCSR(ZE_CSR0, reg); } while (ZE_RCSR(ZE_CSR0) != reg); ZE_WCSR(ZE_CSR3, (vaddr_t)sc->sc_pzedata->zc_recv); ZE_WCSR(ZE_CSR4, (vaddr_t)sc->sc_pzedata->zc_xmit); - return 0; + return false; } diff --git a/sys/dev/ic/sgecvar.h b/sys/dev/ic/sgecvar.h index 9ce1a360206..877690a535d 100644 --- a/sys/dev/ic/sgecvar.h +++ b/sys/dev/ic/sgecvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: sgecvar.h,v 1.7 2007/04/26 23:08:22 matt Exp $ */ +/* $NetBSD: sgecvar.h,v 1.8 2008/03/11 05:34:01 matt Exp $ */ /* * Copyright (c) 1999 Ludd, University of Lule}, Sweden. All rights reserved. * @@ -45,7 +45,7 @@ struct ze_cdata { }; struct ze_softc { - struct device sc_dev; /* Configuration common part */ + device_t sc_dev; /* Configuration common part */ struct evcnt sc_intrcnt; /* Interrupt counters */ struct evcnt sc_rxintrcnt; /* Interrupt counters */ struct evcnt sc_txintrcnt; /* Interrupt counters */ diff --git a/sys/dev/qbus/dhu.c b/sys/dev/qbus/dhu.c index 2822e19e8d1..8fb19b0fde2 100644 --- a/sys/dev/qbus/dhu.c +++ b/sys/dev/qbus/dhu.c @@ -1,4 +1,4 @@ -/* $NetBSD: dhu.c,v 1.51 2007/12/03 15:34:32 ad Exp $ */ +/* $NetBSD: dhu.c,v 1.52 2008/03/11 05:34:01 matt Exp $ */ /* * Copyright (c) 2003, Hugh Graham. * Copyright (c) 1992, 1993 @@ -68,7 +68,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dhu.c,v 1.51 2007/12/03 15:34:32 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dhu.c,v 1.52 2008/03/11 05:34:01 matt Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -100,10 +100,10 @@ __KERNEL_RCSID(0, "$NetBSD: dhu.c,v 1.51 2007/12/03 15:34:32 ad Exp $"); #define DHU_M2U(c) ((c)>>4) /* convert minor(dev) to unit # */ #define DHU_LINE(u) ((u)&0xF) /* extract line # from minor(dev) */ -struct dhu_softc { - struct device sc_dev; /* Device struct used by config */ - struct evcnt sc_rintrcnt; /* Interrupt statistics */ - struct evcnt sc_tintrcnt; /* Interrupt statistics */ +struct dhu_softc { + device_t sc_dev; /* Device struct used by config */ + struct evcnt sc_rintrcnt; /* Interrupt statistics */ + struct evcnt sc_tintrcnt; /* Interrupt statistics */ int sc_type; /* controller type, DHU or DHV */ int sc_lines; /* number of lines */ bus_space_tag_t sc_iot; @@ -171,8 +171,8 @@ static const struct speedtab dhuspeedtab[] = { { -1, -1 } }; -static int dhu_match(struct device *, struct cfdata *, void *); -static void dhu_attach(struct device *, struct device *, void *); +static int dhu_match(device_t, cfdata_t, void *); +static void dhu_attach(device_t, device_t, void *); static void dhurint(void *); static void dhuxint(void *); static void dhustart(struct tty *); @@ -180,31 +180,37 @@ static int dhuparam(struct tty *, struct termios *); static int dhuiflow(struct tty *, int); static unsigned dhumctl(struct dhu_softc *,int, int, int); -CFATTACH_DECL(dhu, sizeof(struct dhu_softc), +CFATTACH_DECL_NEW(dhu, sizeof(struct dhu_softc), dhu_match, dhu_attach, NULL, NULL); -dev_type_open(dhuopen); -dev_type_close(dhuclose); -dev_type_read(dhuread); -dev_type_write(dhuwrite); -dev_type_ioctl(dhuioctl); -dev_type_stop(dhustop); -dev_type_tty(dhutty); -dev_type_poll(dhupoll); +static dev_type_open(dhuopen); +static dev_type_close(dhuclose); +static dev_type_read(dhuread); +static dev_type_write(dhuwrite); +static dev_type_ioctl(dhuioctl); +static dev_type_stop(dhustop); +static dev_type_tty(dhutty); +static dev_type_poll(dhupoll); const struct cdevsw dhu_cdevsw = { - dhuopen, dhuclose, dhuread, dhuwrite, dhuioctl, - dhustop, dhutty, dhupoll, nommap, ttykqfilter, D_TTY + .d_open = dhuopen, + .d_close = dhuclose, + .d_read = dhuread, + .d_write = dhuwrite, + .d_ioctl = dhuioctl, + .d_stop = dhustop, + .d_tty = dhutty, + .d_poll = dhupoll, + .d_mmap = nommap, + .d_kqfilter = ttykqfilter, + .d_flag = D_TTY }; /* Autoconfig handles: setup the controller to interrupt, */ /* then complete the housecleaning for full operation */ static int -dhu_match(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; +dhu_match(device_t parent, cfdata_t cf, void *aux) { struct uba_attach_args *ua = aux; int n; @@ -240,31 +246,30 @@ dhu_match(parent, cf, aux) } static void -dhu_attach(parent, self, aux) - struct device *parent, *self; - void *aux; +dhu_attach(device_t parent, device_t self, void *aux) { struct dhu_softc *sc = device_private(self); struct uba_attach_args *ua = aux; unsigned c; int n, i; + sc->sc_dev = self; sc->sc_iot = ua->ua_iot; sc->sc_ioh = ua->ua_ioh; sc->sc_dmat = ua->ua_dmat; /* Process the 8 bytes of diagnostic info put into */ /* the FIFO following the master reset operation. */ - printf("\n%s:", self->dv_xname); + aprint_normal("\n"); for (n = 0; n < 8; n++) { c = DHU_READ_WORD(DHU_UBA_RBUF); if ((c&DHU_DIAG_CODE) == DHU_DIAG_CODE) { if ((c&0200) == 0000) - printf(" rom(%d) version %d", + aprint_error_dev(self, "rom(%d) version %d\n", ((c>>1)&01), ((c>>2)&037)); else if (((c>>2)&07) != 0) - printf(" diag-error(proc%d)=%x", + aprint_error_dev(self, "diag-error(proc%d)=%x\n", ((c>>1)&01), ((c>>2)&07)); } } @@ -277,7 +282,7 @@ dhu_attach(parent, self, aux) if (sc->sc_type == IS_DHU && (c & DHU_STAT_MDL)) sc->sc_lines = 16; - printf("\n%s: DH%s-11\n", self->dv_xname, + aprint_normal_dev(self, "DH%s-11\n", sc->sc_type == IS_DHU ? "U" : "V"); for (i = 0; i < sc->sc_lines; i++) { @@ -299,18 +304,17 @@ dhu_attach(parent, self, aux) uba_intr_establish(ua->ua_icookie, ua->ua_cvec + 4, dhuxint, sc, &sc->sc_tintrcnt); evcnt_attach_dynamic(&sc->sc_rintrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt, - sc->sc_dev.dv_xname, "rintr"); + device_xname(sc->sc_dev), "rintr"); evcnt_attach_dynamic(&sc->sc_tintrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt, - sc->sc_dev.dv_xname, "tintr"); + device_xname(sc->sc_dev), "tintr"); } /* Receiver Interrupt */ static void -dhurint(arg) - void *arg; +dhurint(void *arg) { - struct dhu_softc *sc = arg; + struct dhu_softc *sc = arg; struct tty *tp; int cc, line; unsigned c, delta; @@ -364,7 +368,7 @@ dhurint(arg) if ((c & DHU_RBUF_OVERRUN_ERR) && overrun == 0) { log(LOG_WARNING, "%s: silo overflow, line %d\n", - sc->sc_dev.dv_xname, line); + device_xname(sc->sc_dev), line); overrun = 1; } /* A BREAK key will appear as a NULL with a framing error */ @@ -380,10 +384,9 @@ dhurint(arg) /* Transmitter Interrupt */ static void -dhuxint(arg) - void *arg; +dhuxint(void *arg) { - struct dhu_softc *sc = arg; + struct dhu_softc *sc = arg; struct tty *tp; int line, i; @@ -394,10 +397,10 @@ dhuxint(arg) if (i & (DHU_CSR_TX_DMA_ERROR >> 8)) printf("%s: DMA ERROR on line: %d\n", - sc->sc_dev.dv_xname, line); + device_xname(sc->sc_dev), line); if (i & (DHU_CSR_DIAG_FAIL >> 8)) printf("%s: DIAG FAIL on line: %d\n", - sc->sc_dev.dv_xname, line); + device_xname(sc->sc_dev), line); tp->t_state &= ~TS_BUSY; if (tp->t_state & TS_FLUSH) @@ -417,10 +420,7 @@ dhuxint(arg) } int -dhuopen(dev, flag, mode, l) - dev_t dev; - int flag, mode; - struct lwp *l; +dhuopen(dev_t dev, int flag, int mode, struct lwp *l) { struct tty *tp; int unit, line; @@ -489,21 +489,12 @@ dhuopen(dev, flag, mode, l) /*ARGSUSED*/ int -dhuclose(dev, flag, mode, l) - dev_t dev; - int flag, mode; - struct lwp *l; +dhuclose(dev_t dev, int flag, int mode, struct lwp *l) { - struct tty *tp; - int unit, line; - struct dhu_softc *sc; - - unit = DHU_M2U(minor(dev)); - line = DHU_LINE(minor(dev)); - - sc = dhu_cd.cd_devs[unit]; - - tp = sc->sc_dhu[line].dhu_tty; + const int unit = DHU_M2U(minor(dev)); + const int line = DHU_LINE(minor(dev)); + struct dhu_softc *sc = device_lookup_private(&dhu_cd, unit); + struct tty *tp = sc->sc_dhu[line].dhu_tty; (*tp->t_linesw->l_close)(tp, flag); @@ -513,77 +504,49 @@ dhuclose(dev, flag, mode, l) /* Do a hangup if so required. */ - if ((tp->t_cflag & HUPCL) || tp->t_wopen || - !(tp->t_state & TS_ISOPEN)) + if ((tp->t_cflag & HUPCL) || tp->t_wopen || !(tp->t_state & TS_ISOPEN)) (void) dhumctl(sc, line, 0, DMSET); return (ttyclose(tp)); } int -dhuread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; +dhuread(dev_t dev, struct uio *uio, int flag) { - struct dhu_softc *sc; - struct tty *tp; - - sc = dhu_cd.cd_devs[DHU_M2U(minor(dev))]; + struct dhu_softc *sc = device_lookup_private(&dhu_cd, DHU_M2U(minor(dev))); + struct tty *tp = sc->sc_dhu[DHU_LINE(minor(dev))].dhu_tty; - tp = sc->sc_dhu[DHU_LINE(minor(dev))].dhu_tty; return ((*tp->t_linesw->l_read)(tp, uio, flag)); } int -dhuwrite(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; +dhuwrite(dev_t dev, struct uio *uio, int flag) { - struct dhu_softc *sc; - struct tty *tp; - - sc = dhu_cd.cd_devs[DHU_M2U(minor(dev))]; + struct dhu_softc *sc = device_lookup_private(&dhu_cd, DHU_M2U(minor(dev))); + struct tty *tp = sc->sc_dhu[DHU_LINE(minor(dev))].dhu_tty; - tp = sc->sc_dhu[DHU_LINE(minor(dev))].dhu_tty; return ((*tp->t_linesw->l_write)(tp, uio, flag)); } int -dhupoll(dev, events, l) - dev_t dev; - int events; - struct lwp *l; +dhupoll(dev_t dev, int events, struct lwp *l) { - struct dhu_softc *sc; - struct tty *tp; - - sc = dhu_cd.cd_devs[DHU_M2U(minor(dev))]; + struct dhu_softc *sc = device_lookup_private(&dhu_cd, DHU_M2U(minor(dev))); + struct tty *tp = sc->sc_dhu[DHU_LINE(minor(dev))].dhu_tty; - tp = sc->sc_dhu[DHU_LINE(minor(dev))].dhu_tty; return ((*tp->t_linesw->l_poll)(tp, events, l)); } /*ARGSUSED*/ int -dhuioctl(dev, cmd, data, flag, l) - dev_t dev; - u_long cmd; - void *data; - int flag; - struct lwp *l; +dhuioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) { - struct dhu_softc *sc; - struct tty *tp; - int unit, line; + const int unit = DHU_M2U(minor(dev)); + const int line = DHU_LINE(minor(dev)); + struct dhu_softc *sc = device_lookup_private(&dhu_cd, unit); + struct tty *tp = sc->sc_dhu[line].dhu_tty; int error; - unit = DHU_M2U(minor(dev)); - line = DHU_LINE(minor(dev)); - sc = dhu_cd.cd_devs[unit]; - tp = sc->sc_dhu[line].dhu_tty; - error = (*tp->t_linesw->l_ioctl)(tp, cmd, data, flag, l); if (error != EPASSTHROUGH) return (error); @@ -633,30 +596,25 @@ dhuioctl(dev, cmd, data, flag, l) } struct tty * -dhutty(dev) - dev_t dev; +dhutty(dev_t dev) { - struct dhu_softc *sc = dhu_cd.cd_devs[DHU_M2U(minor(dev))]; - struct tty *tp = sc->sc_dhu[DHU_LINE(minor(dev))].dhu_tty; - return (tp); + struct dhu_softc *sc = device_lookup_private(&dhu_cd, DHU_M2U(minor(dev))); + + return sc->sc_dhu[DHU_LINE(minor(dev))].dhu_tty; } /*ARGSUSED*/ void -dhustop(tp, flag) - struct tty *tp; - int flag; +dhustop(struct tty *tp, int flag) { - struct dhu_softc *sc; - int line; int s; s = spltty(); if (tp->t_state & TS_BUSY) { - - sc = dhu_cd.cd_devs[DHU_M2U(minor(tp->t_dev))]; - line = DHU_LINE(minor(tp->t_dev)); + const int unit = DHU_M2U(minor(tp->t_dev)); + const int line = DHU_LINE(minor(tp->t_dev)); + struct dhu_softc *sc = device_lookup_private(&dhu_cd, unit); if (sc->sc_dhu[line].dhu_state == STATE_DMA_RUNNING) { @@ -675,8 +633,7 @@ dhustop(tp, flag) } static void -dhustart(tp) - struct tty *tp; +dhustart(struct tty *tp) { struct dhu_softc *sc; int line, cc; @@ -694,7 +651,7 @@ dhustart(tp) tp->t_state |= TS_BUSY; - sc = dhu_cd.cd_devs[DHU_M2U(minor(tp->t_dev))]; + sc = device_lookup_private(&dhu_cd,DHU_M2U(minor(tp->t_dev))); line = DHU_LINE(minor(tp->t_dev)); @@ -731,22 +688,18 @@ out: } static int -dhuparam(tp, t) - struct tty *tp; - struct termios *t; +dhuparam(struct tty *tp, struct termios *t) { - struct dhu_softc *sc; int cflag = t->c_cflag; int ispeed = ttspeedtab(t->c_ispeed, dhuspeedtab); int ospeed = ttspeedtab(t->c_ospeed, dhuspeedtab); - unsigned lpr, lnctrl; - int unit, line; + unsigned int lpr; + unsigned int lnctrl; + const int unit = DHU_M2U(minor(tp->t_dev)); + const int line = DHU_LINE(minor(tp->t_dev)); + struct dhu_softc * const sc = device_lookup_private(&dhu_cd, unit); int s; - unit = DHU_M2U(minor(tp->t_dev)); - line = DHU_LINE(minor(tp->t_dev)); - - sc = dhu_cd.cd_devs[unit]; /* check requested parameters */ if (ospeed < 0 || ispeed < 0) @@ -822,25 +775,21 @@ dhuparam(tp, t) } static int -dhuiflow(tp, flag) - struct tty *tp; - int flag; +dhuiflow(struct tty *tp, int flag) { - struct dhu_softc *sc; - int line = DHU_LINE(minor(tp->t_dev)); if (tp->t_cflag & CRTSCTS) { - sc = dhu_cd.cd_devs[DHU_M2U(minor(tp->t_dev))]; + const int unit = DHU_M2U(minor(tp->t_dev)); + const int line = DHU_LINE(minor(tp->t_dev)); + struct dhu_softc * const sc = device_lookup_private(&dhu_cd, unit); (void) dhumctl(sc, line, DML_RTS, ((flag)? DMBIC: DMBIS)); return (1); } return (0); } -static unsigned -dhumctl(sc, line, bits, how) - struct dhu_softc *sc; - int line, bits, how; +static unsigned int +dhumctl(struct dhu_softc *sc, int line, int bits, int how) { unsigned status; unsigned lnctrl; diff --git a/sys/dev/qbus/dz_uba.c b/sys/dev/qbus/dz_uba.c index 17a5d46a49b..eeb1bd3e884 100644 --- a/sys/dev/qbus/dz_uba.c +++ b/sys/dev/qbus/dz_uba.c @@ -1,4 +1,4 @@ -/* $NetBSD: dz_uba.c,v 1.26 2007/10/19 12:01:08 ad Exp $ */ +/* $NetBSD: dz_uba.c,v 1.27 2008/03/11 05:34:01 matt Exp $ */ /* * Copyright (c) 1998 Ludd, University of Lule}, Sweden. All rights reserved. * Copyright (c) 1996 Ken C. Wellsch. All rights reserved. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dz_uba.c,v 1.26 2007/10/19 12:01:08 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dz_uba.c,v 1.27 2008/03/11 05:34:01 matt Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -58,8 +58,8 @@ __KERNEL_RCSID(0, "$NetBSD: dz_uba.c,v 1.26 2007/10/19 12:01:08 ad Exp $"); #include "ioconf.h" -static int dz_uba_match(struct device *, struct cfdata *, void *); -static void dz_uba_attach(struct device *, struct device *, void *); +static int dz_uba_match(device_t, cfdata_t, void *); +static void dz_uba_attach(device_t, device_t, void *); CFATTACH_DECL(dz_uba, sizeof(struct dz_softc), dz_uba_match, dz_uba_attach, NULL, NULL); @@ -68,10 +68,7 @@ CFATTACH_DECL(dz_uba, sizeof(struct dz_softc), /* then complete the housecleaning for full operation */ static int -dz_uba_match(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; +dz_uba_match(device_t parent, cfdata_t cf, void *aux) { struct uba_attach_args *ua = aux; bus_space_tag_t iot = ua->ua_iot; @@ -110,9 +107,7 @@ dz_uba_match(parent, cf, aux) } static void -dz_uba_attach(parent, self, aux) - struct device *parent, *self; - void *aux; +dz_uba_attach(device_t parent, device_t self, void *aux) { struct dz_softc *sc = device_private(self); struct uba_attach_args *ua = aux; diff --git a/sys/dev/qbus/files.uba b/sys/dev/qbus/files.uba index e44d8377f56..20c6e0c3d2b 100644 --- a/sys/dev/qbus/files.uba +++ b/sys/dev/qbus/files.uba @@ -1,9 +1,9 @@ -# $NetBSD: files.uba,v 1.16 2005/12/11 12:23:29 christos Exp $ +# $NetBSD: files.uba,v 1.17 2008/03/11 05:34:01 matt Exp $ # # Config file and device description for machine-independent # code for devices Digital Equipment Corp. Unibus and Q22 bus. # Included by ports that need it. -device uba { csr } +device uba { csr }: bus define qfont define ifuba diff --git a/sys/dev/qbus/if_de.c b/sys/dev/qbus/if_de.c index add4bae496a..c7871cf110e 100644 --- a/sys/dev/qbus/if_de.c +++ b/sys/dev/qbus/if_de.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_de.c,v 1.22 2007/10/19 12:01:08 ad Exp $ */ +/* $NetBSD: if_de.c,v 1.23 2008/03/11 05:34:01 matt Exp $ */ /* * Copyright (c) 1982, 1986, 1989 Regents of the University of California. @@ -81,7 +81,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_de.c,v 1.22 2007/10/19 12:01:08 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_de.c,v 1.23 2008/03/11 05:34:01 matt Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -151,42 +151,43 @@ struct de_cdata { * efficiently. */ struct de_softc { - struct device sc_dev; /* Configuration common part */ - struct evcnt sc_intrcnt; /* Interrupt counting */ - struct ethercom sc_ec; /* Ethernet common part */ + device_t sc_dev; /* Configuration common part */ + struct uba_softc *sc_uh; /* our parent */ + struct evcnt sc_intrcnt; /* Interrupt counting */ + struct ethercom sc_ec; /* Ethernet common part */ #define sc_if sc_ec.ec_if /* network-visible interface */ bus_space_tag_t sc_iot; bus_addr_t sc_ioh; bus_dma_tag_t sc_dmat; - int sc_flags; + int sc_flags; #define DSF_MAPPED 1 struct ubinfo sc_ui; struct de_cdata *sc_dedata; /* Control structure */ struct de_cdata *sc_pdedata; /* Bus-mapped control structure */ - struct ifubinfo sc_ifuba; /* UNIBUS resources */ - struct ifrw sc_ifr[NRCV]; /* UNIBUS receive buffer maps */ - struct ifxmt sc_ifw[NXMT]; /* UNIBUS receive buffer maps */ - - int sc_xindex; /* UNA index into transmit chain */ - int sc_rindex; /* UNA index into receive chain */ - int sc_xfree; /* index for next transmit buffer */ - int sc_nxmit; /* # of transmits in progress */ + struct ifubinfo sc_ifuba; /* UNIBUS resources */ + struct ifrw sc_ifr[NRCV]; /* UNIBUS receive buffer maps */ + struct ifxmt sc_ifw[NXMT]; /* UNIBUS receive buffer maps */ + + int sc_xindex; /* UNA index into transmit chain */ + int sc_rindex; /* UNA index into receive chain */ + int sc_xfree; /* index for next transmit buffer */ + int sc_nxmit; /* # of transmits in progress */ void *sc_sh; /* shutdownhook cookie */ }; -static int dematch(struct device *, struct cfdata *, void *); -static void deattach(struct device *, struct device *, void *); +static int dematch(device_t, cfdata_t, void *); +static void deattach(device_t, device_t, void *); static void dewait(struct de_softc *, const char *); static int deinit(struct ifnet *); static int deioctl(struct ifnet *, u_long, void *); -static void dereset(struct device *); +static void dereset(device_t ); static void destop(struct ifnet *, int); static void destart(struct ifnet *); static void derecv(struct de_softc *); static void deintr(void *); static void deshutdown(void *); -CFATTACH_DECL(de, sizeof(struct de_softc), +CFATTACH_DECL_NEW(de, sizeof(struct de_softc), dematch, deattach, NULL, NULL); #define DE_WCSR(csr, val) \ @@ -206,7 +207,7 @@ CFATTACH_DECL(de, sizeof(struct de_softc), * to accept packets. We get the ethernet address here. */ void -deattach(struct device *parent, struct device *self, void *aux) +deattach(device_t parent, device_t self, void *aux) { struct uba_attach_args *ua = aux; struct de_softc *sc = device_private(self); @@ -215,6 +216,8 @@ deattach(struct device *parent, struct device *self, void *aux) int csr1, error; const char *c; + sc->sc_dev = self; + sc->sc_uh = device_private(parent); sc->sc_iot = ua->ua_iot; sc->sc_ioh = ua->ua_ioh; sc->sc_dmat = ua->ua_dmat; @@ -242,7 +245,7 @@ deattach(struct device *parent, struct device *self, void *aux) dewait(sc, "reset"); sc->sc_ui.ui_size = sizeof(struct de_cdata); - if ((error = ubmemalloc((struct uba_softc *)parent, &sc->sc_ui, 0))) + if ((error = ubmemalloc(sc->sc_uh, &sc->sc_ui, 0))) return printf(": failed ubmemalloc(), error = %d\n", error); sc->sc_dedata = (struct de_cdata *)sc->sc_ui.ui_vaddr; @@ -259,16 +262,15 @@ deattach(struct device *parent, struct device *self, void *aux) dewait(sc, "read addr "); bcopy((void *)&sc->sc_dedata->dc_pcbb.pcbb2, myaddr, sizeof (myaddr)); - printf("\n%s: %s, hardware address %s\n", sc->sc_dev.dv_xname, c, - ether_sprintf(myaddr)); + printf(": %s, hardware address %s\n", c, ether_sprintf(myaddr)); uba_intr_establish(ua->ua_icookie, ua->ua_cvec, deintr, sc, &sc->sc_intrcnt); - uba_reset_establish(dereset, &sc->sc_dev); + uba_reset_establish(dereset, sc->sc_dev); evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt, - sc->sc_dev.dv_xname, "intr"); + device_xname(sc->sc_dev), "intr"); - strcpy(ifp->if_xname, sc->sc_dev.dv_xname); + strcpy(ifp->if_xname, device_xname(sc->sc_dev)); ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI; ifp->if_ioctl = deioctl; @@ -279,7 +281,7 @@ deattach(struct device *parent, struct device *self, void *aux) if_attach(ifp); ether_ifattach(ifp, myaddr); - ubmemfree((struct uba_softc *)parent, &sc->sc_ui); + ubmemfree(sc->sc_uh, &sc->sc_ui); sc->sc_sh = shutdownhook_establish(deshutdown, sc); } @@ -299,7 +301,7 @@ destop(struct ifnet *ifp, int a) * Reset of interface after UNIBUS reset. */ void -dereset(struct device *dev) +dereset(device_t dev) { struct de_softc *sc = (void *)dev; @@ -328,17 +330,16 @@ deinit(struct ifnet *ifp) if (ifp->if_flags & IFF_RUNNING) return 0; if ((sc->sc_flags & DSF_MAPPED) == 0) { - if (if_ubaminit(&sc->sc_ifuba, - (void *)device_parent(&sc->sc_dev), - MCLBYTES, sc->sc_ifr, NRCV, sc->sc_ifw, NXMT)) { - printf("%s: can't initialize\n", sc->sc_dev.dv_xname); + if (if_ubaminit(&sc->sc_ifuba, sc->sc_uh, MCLBYTES, + sc->sc_ifr, NRCV, sc->sc_ifw, NXMT)) { + aprint_error_dev(sc->sc_dev, " can't initialize\n"); ifp->if_flags &= ~IFF_UP; return 0; } sc->sc_ui.ui_size = sizeof(struct de_cdata); - if ((error = ubmemalloc((void *)device_parent(&sc->sc_dev), - &sc->sc_ui, 0))) { - printf(": unable to ubmemalloc(), error = %d\n", error); + if ((error = ubmemalloc(sc->sc_uh, &sc->sc_ui, 0))) { + aprint_error(": unable to ubmemalloc(), error = %d\n", + error); return 0; } sc->sc_pdedata = (struct de_cdata *)sc->sc_ui.ui_baddr; @@ -604,23 +605,25 @@ deioctl(struct ifnet *ifp, u_long cmd, void *data) void dewait(struct de_softc *sc, const char *fn) { - int csr0; + int csr0, csr1; while ((DE_RCSR(DE_PCSR0) & PCSR0_INTR) == 0) ; csr0 = DE_RCSR(DE_PCSR0); DE_WHIGH(csr0 >> 8); if (csr0 & PCSR0_PCEI) { - char bits[64]; - printf("%s: %s failed, csr0=%s ", sc->sc_dev.dv_xname, fn, - bitmask_snprintf(csr0, PCSR0_BITS, bits, sizeof(bits))); - printf("csr1=%s\n", bitmask_snprintf(DE_RCSR(DE_PCSR1), - PCSR1_BITS, bits, sizeof(bits))); + char bits0[64]; + char bits1[64]; + csr1 = DE_RCSR(DE_PCSR1); + aprint_error_dev(sc->sc_dev, "%s failed, csr0=%s csr1=%s\n", + fn, + bitmask_snprintf(csr0, PCSR0_BITS, bits0, sizeof(bits0)), + bitmask_snprintf(csr1, PCSR1_BITS, bits1, sizeof(bits1))); } } int -dematch(struct device *parent, struct cfdata *cf, void *aux) +dematch(device_t parent, cfdata_t cf, void *aux) { struct uba_attach_args *ua = aux; struct de_softc ssc; diff --git a/sys/dev/qbus/if_qe.c b/sys/dev/qbus/if_qe.c index 1950064c7a6..71b3f7a0093 100644 --- a/sys/dev/qbus/if_qe.c +++ b/sys/dev/qbus/if_qe.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_qe.c,v 1.66 2007/12/22 08:23:01 tsutsui Exp $ */ +/* $NetBSD: if_qe.c,v 1.67 2008/03/11 05:34:01 matt Exp $ */ /* * Copyright (c) 1999 Ludd, University of Lule}, Sweden. All rights reserved. * @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_qe.c,v 1.66 2007/12/22 08:23:01 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_qe.c,v 1.67 2008/03/11 05:34:01 matt Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -82,7 +82,8 @@ struct qe_cdata { }; struct qe_softc { - struct device sc_dev; /* Configuration common part */ + device_t sc_dev; /* Configuration common part */ + struct uba_softc *sc_uh; /* our parent */ struct evcnt sc_intrcnt; /* Interrupt counting */ struct ethercom sc_ec; /* Ethernet common part */ #define sc_if sc_ec.ec_if /* network-visible interface */ @@ -105,8 +106,8 @@ struct qe_softc { int sc_setup; /* Setup packet in queue */ }; -static int qematch(struct device *, struct cfdata *, void *); -static void qeattach(struct device *, struct device *, void *); +static int qematch(device_t, cfdata_t, void *); +static void qeattach(device_t, device_t, void *); static void qeinit(struct qe_softc *); static void qestart(struct ifnet *); static void qeintr(void *); @@ -115,7 +116,7 @@ static int qe_add_rxbuf(struct qe_softc *, int); static void qe_setup(struct qe_softc *); static void qetimeout(struct ifnet *); -CFATTACH_DECL(qe, sizeof(struct qe_softc), +CFATTACH_DECL_NEW(qe, sizeof(struct qe_softc), qematch, qeattach, NULL, NULL); #define QE_WCSR(csr, val) \ @@ -133,12 +134,12 @@ CFATTACH_DECL(qe, sizeof(struct qe_softc), * and wait for interrupt. */ int -qematch(struct device *parent, struct cfdata *cf, void *aux) +qematch(device_t parent, cfdata_t cf, void *aux) { struct qe_softc ssc; struct qe_softc *sc = &ssc; struct uba_attach_args *ua = aux; - struct uba_softc *ubasc = (struct uba_softc *)parent; + struct uba_softc *uh = device_private(parent); struct ubinfo ui; #define PROBESIZE 4096 @@ -146,16 +147,15 @@ qematch(struct device *parent, struct cfdata *cf, void *aux) struct qe_ring *rp; int error; - ring = malloc(PROBESIZE, M_TEMP, M_WAITOK); - bzero(sc, sizeof(struct qe_softc)); - bzero(ring, PROBESIZE); + ring = malloc(PROBESIZE, M_TEMP, M_WAITOK|M_ZERO); + bzero(sc, sizeof(*sc)); sc->sc_iot = ua->ua_iot; sc->sc_ioh = ua->ua_ioh; sc->sc_dmat = ua->ua_dmat; - ubasc->uh_lastiv -= 4; + uh->uh_lastiv -= 4; QE_WCSR(QE_CSR_CSR, QE_RESET); - QE_WCSR(QE_CSR_VECTOR, ubasc->uh_lastiv); + QE_WCSR(QE_CSR_VECTOR, uh->uh_lastiv); /* * Map the ring area. Actually this is done only to be able to @@ -164,7 +164,7 @@ qematch(struct device *parent, struct cfdata *cf, void *aux) */ ui.ui_size = PROBESIZE; ui.ui_vaddr = (void *)&ring[0]; - if ((error = uballoc((void *)parent, &ui, UBA_CANTWAIT))) + if ((error = uballoc(uh, &ui, UBA_CANTWAIT))) return 0; /* @@ -198,7 +198,7 @@ qematch(struct device *parent, struct cfdata *cf, void *aux) /* * All done with the bus resources. */ - ubfree((void *)parent, &ui); + ubfree(uh, &ui); free(ring, M_TEMP); return 1; } @@ -209,17 +209,18 @@ qematch(struct device *parent, struct cfdata *cf, void *aux) * to accept packets. */ void -qeattach(struct device *parent, struct device *self, void *aux) +qeattach(device_t parent, device_t self, void *aux) { - struct uba_attach_args *ua = aux; - struct uba_softc *ubasc = (struct uba_softc *)parent; - struct qe_softc *sc = device_private(self); - struct ifnet *ifp = (struct ifnet *)&sc->sc_if; - struct qe_ring *rp; + struct uba_attach_args *ua = aux; + struct qe_softc *sc = device_private(self); + struct ifnet *ifp = &sc->sc_if; + struct qe_ring *rp; u_int8_t enaddr[ETHER_ADDR_LEN]; int i, error; char *nullbuf; + sc->sc_dev = self; + sc->sc_uh = device_private(parent); sc->sc_iot = ua->ua_iot; sc->sc_ioh = ua->ua_ioh; sc->sc_dmat = ua->ua_dmat; @@ -229,8 +230,8 @@ qeattach(struct device *parent, struct device *self, void *aux) */ sc->sc_ui.ui_size = sizeof(struct qe_cdata) + ETHER_PAD_LEN; - if ((error = ubmemalloc((struct uba_softc *)parent, &sc->sc_ui, 0))) { - printf(": unable to ubmemalloc(), error = %d\n", error); + if ((error = ubmemalloc(sc->sc_uh, &sc->sc_ui, 0))) { + aprint_error(": unable to ubmemalloc(), error = %d\n", error); return; } sc->sc_pqedata = (struct qe_cdata *)sc->sc_ui.ui_baddr; @@ -251,7 +252,8 @@ qeattach(struct device *parent, struct device *self, void *aux) if ((error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1, MCLBYTES, 0, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW, &sc->sc_xmtmap[i]))) { - printf(": unable to create tx DMA map %d, error = %d\n", + aprint_error( + ": unable to create tx DMA map %d, error = %d\n", i, error); goto fail_4; } @@ -264,7 +266,8 @@ qeattach(struct device *parent, struct device *self, void *aux) if ((error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1, MCLBYTES, 0, BUS_DMA_NOWAIT, &sc->sc_rcvmap[i]))) { - printf(": unable to create rx DMA map %d, error = %d\n", + aprint_error( + ": unable to create rx DMA map %d, error = %d\n", i, error); goto fail_5; } @@ -274,7 +277,8 @@ qeattach(struct device *parent, struct device *self, void *aux) */ for (i = 0; i < RXDESCS; i++) { if ((error = qe_add_rxbuf(sc, i)) != 0) { - printf(": unable to allocate or map rx buffer %d\n," + aprint_error( + ": unable to allocate or map rx buffer %d," " error = %d\n", i, error); goto fail_6; } @@ -282,14 +286,16 @@ qeattach(struct device *parent, struct device *self, void *aux) if ((error = bus_dmamap_create(sc->sc_dmat, ETHER_PAD_LEN, 1, ETHER_PAD_LEN, 0, BUS_DMA_NOWAIT,&sc->sc_nulldmamap)) != 0) { - printf("%s: unable to create pad buffer DMA map, " - "error = %d\n", sc->sc_dev.dv_xname, error); + aprint_error( + ": unable to create pad buffer DMA map, error = %d\n", + error); goto fail_6; } if ((error = bus_dmamap_load(sc->sc_dmat, sc->sc_nulldmamap, nullbuf, ETHER_PAD_LEN, NULL, BUS_DMA_NOWAIT)) != 0) { - printf("%s: unable to load pad buffer DMA map, " - "error = %d\n", sc->sc_dev.dv_xname, error); + aprint_error( + ": unable to load pad buffer DMA map, error = %d\n", + error); goto fail_7; } bus_dmamap_sync(sc->sc_dmat, sc->sc_nulldmamap, 0, ETHER_PAD_LEN, @@ -315,7 +321,7 @@ qeattach(struct device *parent, struct device *self, void *aux) /* * Get the vector that were set at match time, and remember it. */ - sc->sc_intvec = ubasc->uh_lastiv; + sc->sc_intvec = sc->sc_uh->uh_lastiv; QE_WCSR(QE_CSR_CSR, QE_RESET); DELAY(1000); QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) & ~QE_RESET); @@ -327,7 +333,7 @@ qeattach(struct device *parent, struct device *self, void *aux) enaddr[i] = QE_RCSR(i * 2) & 0xff; QE_WCSR(QE_CSR_VECTOR, sc->sc_intvec | 1); - printf("\n%s: %s, hardware address %s\n", sc->sc_dev.dv_xname, + aprint_normal(": %s, hardware address %s\n", QE_RCSR(QE_CSR_VECTOR) & 1 ? "delqa":"deqna", ether_sprintf(enaddr)); @@ -336,9 +342,9 @@ qeattach(struct device *parent, struct device *self, void *aux) uba_intr_establish(ua->ua_icookie, ua->ua_cvec, qeintr, sc, &sc->sc_intrcnt); evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt, - sc->sc_dev.dv_xname, "intr"); + device_xname(sc->sc_dev), "intr"); - strcpy(ifp->if_xname, sc->sc_dev.dv_xname); + strcpy(ifp->if_xname, device_xname(sc->sc_dev)); ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_start = qestart; @@ -744,7 +750,7 @@ qe_add_rxbuf(struct qe_softc *sc, int i) m->m_ext.ext_buf, m->m_ext.ext_size, NULL, BUS_DMA_NOWAIT); if (error) panic("%s: can't load rx DMA map %d, error = %d", - sc->sc_dev.dv_xname, i, error); + device_xname(sc->sc_dev), i, error); sc->sc_rxmbuf[i] = m; bus_dmamap_sync(sc->sc_dmat, sc->sc_rcvmap[i], 0, @@ -862,7 +868,7 @@ qetimeout(struct ifnet *ifp) if (sc->sc_inq == 0) return; - printf("%s: xmit logic died, resetting...\n", sc->sc_dev.dv_xname); + aprint_error_dev(sc->sc_dev, "xmit logic died, resetting...\n"); /* * Do a reset of interface, to get it going again. * Will it work by just restart the transmit logic? diff --git a/sys/dev/qbus/if_qt.c b/sys/dev/qbus/if_qt.c index 7e789d4711d..be61bb1e6a1 100644 --- a/sys/dev/qbus/if_qt.c +++ b/sys/dev/qbus/if_qt.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_qt.c,v 1.13 2008/01/04 21:58:51 joerg Exp $ */ +/* $NetBSD: if_qt.c,v 1.14 2008/03/11 05:34:01 matt Exp $ */ /* * Copyright (c) 1992 Steven M. Schultz * All rights reserved. @@ -80,7 +80,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_qt.c,v 1.13 2008/01/04 21:58:51 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_qt.c,v 1.14 2008/03/11 05:34:01 matt Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -138,8 +138,9 @@ struct qt_cdata { }; struct qt_softc { - struct device sc_dev; /* Configuration common part */ + device_t sc_dev; /* Configuration common part */ struct ethercom is_ec; /* common part - must be first */ + struct uba_softc *sc_uh; struct evcnt sc_intrcnt; /* Interrupt counting */ #define is_if is_ec.ec_if /* network-visible interface */ u_int8_t is_addr[ETHER_ADDR_LEN]; /* hardware Ethernet address */ @@ -165,8 +166,8 @@ struct qt_softc { short vector; /* Interrupt vector assigned */ }; -static int qtmatch(struct device *, struct cfdata *, void *); -static void qtattach(struct device *, struct device *, void *); +static int qtmatch(device_t, cfdata_t, void *); +static void qtattach(device_t, device_t, void *); static void qtintr(void *); static int qtinit(struct ifnet *); static int qtioctl(struct ifnet *, u_long, void *); @@ -179,7 +180,7 @@ static void qttint(struct qt_softc *sc); /* static void qtrestart(struct qt_softc *sc); */ -CFATTACH_DECL(qt, sizeof(struct qt_softc), +CFATTACH_DECL_NEW(qt, sizeof(struct qt_softc), qtmatch, qtattach, NULL, NULL); /* @@ -197,19 +198,18 @@ CFATTACH_DECL(qt, sizeof(struct qt_softc), #define loint(x) ((int)(x) & 0xffff) #define hiint(x) (((int)(x) >> 16) & 0x3f) -#define XNAME sc->sc_dev.dv_xname /* * Check if this card is a turbo delqa. */ int -qtmatch(struct device *parent, struct cfdata *cf, void *aux) +qtmatch(device_t parent, cfdata_t cf, void *aux) { - struct qt_softc ssc; - struct qt_softc *sc = &ssc; - struct uba_attach_args *ua = aux; - struct uba_softc *ubasc = (struct uba_softc *)parent; - struct qt_init *qi; + struct qt_softc ssc; + struct qt_softc *sc = &ssc; + struct uba_attach_args *ua = aux; + struct uba_softc *uh = device_private(parent); + struct qt_init *qi; struct ubinfo ui; sc->sc_iot = ua->ua_iot; @@ -219,11 +219,11 @@ qtmatch(struct device *parent, struct cfdata *cf, void *aux) /* Force the card to interrupt */ ui.ui_size = sizeof(struct qt_init); - if (ubmemalloc((void *)parent, &ui, 0)) + if (ubmemalloc(uh, &ui, 0)) return 0; /* Failed */ qi = (struct qt_init *)ui.ui_vaddr; memset(qi, 0, sizeof(struct qt_init)); - qi->vector = ubasc->uh_lastiv - 4; + qi->vector = uh->uh_lastiv - 4; qi->options = INIT_OPTIONS_INT; QT_WCSR(CSR_IBAL, loint(ui.ui_baddr)); @@ -232,7 +232,7 @@ qtmatch(struct device *parent, struct cfdata *cf, void *aux) delay(100000); /* Wait some time for interrupt */ QT_WCSR(CSR_SRQR, 3); /* Stop card */ - ubmemfree((void *)parent, &ui); + ubmemfree(uh, &ui); return 10; } @@ -252,22 +252,23 @@ qtmatch(struct device *parent, struct cfdata *cf, void *aux) */ void -qtattach(struct device *parent, struct device *self, void *aux) - { - struct uba_softc *ubasc = (struct uba_softc *)parent; - register struct qt_softc *sc = device_private(self); - register struct ifnet *ifp = &sc->is_if; +qtattach(device_t parent, device_t self, void *aux) +{ + struct qt_softc *sc = device_private(self); + struct ifnet *ifp = &sc->is_if; struct uba_attach_args *ua = aux; uba_intr_establish(ua->ua_icookie, ua->ua_cvec, qtintr, sc, &sc->sc_intrcnt); evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt, - sc->sc_dev.dv_xname, "intr"); + device_xname(sc->sc_dev), "intr"); + sc->sc_dev = self; + sc->sc_uh = device_private(parent); sc->sc_iot = ua->ua_iot; sc->sc_ioh = ua->ua_ioh; - ubasc->uh_lastiv -= 4; - sc->vector = ubasc->uh_lastiv; + sc->sc_uh->uh_lastiv -= 4; + sc->vector = sc->sc_uh->uh_lastiv; /* * Now allocate the buffers and initialize the buffers. This should _never_ @@ -281,7 +282,7 @@ qtattach(struct device *parent, struct device *self, void *aux) sc->is_addr[4] = QT_RCSR(8); sc->is_addr[5] = QT_RCSR(10); - strcpy(ifp->if_xname, sc->sc_dev.dv_xname); + strcpy(ifp->if_xname, device_xname(sc->sc_dev)); ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST|IFF_MULTICAST; ifp->if_ioctl = qtioctl; @@ -291,16 +292,15 @@ qtattach(struct device *parent, struct device *self, void *aux) IFQ_SET_READY(&ifp->if_snd); printf("\n%s: delqa-plus in Turbo mode, hardware address %s\n", - XNAME, ether_sprintf(sc->is_addr)); + device_xname(sc->sc_dev), ether_sprintf(sc->is_addr)); if_attach(ifp); ether_ifattach(ifp, sc->is_addr); - } +} int -qtturbo(sc) - register struct qt_softc *sc; - { - register int i; +qtturbo(struct qt_softc *sc) +{ + int i; /* * Issue the software reset. Delay 150us. The board should now be in @@ -314,11 +314,8 @@ qtturbo(sc) QT_WCSR(CSR_SRR, 0x8001); /* MS | ITB */ i = QT_RCSR(CSR_SRR); QT_WCSR(CSR_SRR, 0x8000); /* Turn off ITB, set DELQA select */ - if (i != 0x8001) - { - printf("qt !-YM\n"); + if (i != 0x8001) return(0); - } /* * Board is a DELQA-YM. Send the commands to enable Turbo mode. Delay * 1 second, testing the SRR register every millisecond to see if the @@ -338,18 +335,18 @@ qtturbo(sc) return(0); } return(1); - } +} int qtinit(struct ifnet *ifp) - { - register struct qt_softc *sc = ifp->if_softc; - register struct qt_init *iniblk; +{ + struct qt_softc *sc = ifp->if_softc; + struct qt_init *iniblk; struct ifrw *ifrw; struct ifxmt *ifxp; struct qt_rring *rp; struct qt_tring *tp; - register int i, error; + int i, error; if (ifp->if_flags & IFF_RUNNING) { /* Cancel any pending I/O. */ @@ -357,16 +354,14 @@ qtinit(struct ifnet *ifp) } if (sc->sc_ib == NULL) { - if (if_ubaminit(&sc->sc_ifuba, - (void *)device_parent(&sc->sc_dev), + if (if_ubaminit(&sc->sc_ifuba, sc->sc_uh, MCLBYTES, sc->sc_ifr, NRCV, sc->sc_ifw, NXMT)) { - printf("%s: can't initialize\n", XNAME); + printf("%s: can't initialize\n", device_xname(sc->sc_dev)); ifp->if_flags &= ~IFF_UP; return 0; } sc->sc_ui.ui_size = sizeof(struct qt_cdata); - if ((error = ubmemalloc((void *)device_parent(&sc->sc_dev), - &sc->sc_ui, 0))) { + if ((error = ubmemalloc(sc->sc_uh, &sc->sc_ui, 0))) { printf(": failed ubmemalloc(), error = %d\n", error); return error; } @@ -452,8 +447,8 @@ void qtstart(struct ifnet *ifp) { int len, nxmit; - register struct qt_softc *sc = ifp->if_softc; - register struct qt_tring *rp; + struct qt_softc *sc = ifp->if_softc; + struct qt_tring *rp; struct mbuf *m = NULL; for (nxmit = sc->nxmit; nxmit < NXMT; nxmit++) { @@ -521,7 +516,7 @@ qtintr(void *arg) void qttint(struct qt_softc *sc) { - register struct qt_tring *rp; + struct qt_tring *rp; while (sc->nxmit > 0) { @@ -541,7 +536,7 @@ qttint(struct qt_softc *sc) #ifdef QTDEBUG char buf[100]; bitmask_snprintf(rp->tmd2, TMD2_BITS, buf, 100); - printf("%s: tmd2 %s\n", XNAME, buf); + printf("%s: tmd2 %s\n", device_xname(sc->sc_dev), buf); #endif sc->is_if.if_oerrors++; } @@ -559,8 +554,8 @@ qttint(struct qt_softc *sc) void qtrint(struct qt_softc *sc) - { - register struct qt_rring *rp; +{ + struct qt_rring *rp; struct ifnet *ifp = &sc->is_ec.ec_if; struct mbuf *m; int len; @@ -570,7 +565,7 @@ qtrint(struct qt_softc *sc) rp = &sc->sc_ib->qc_r[(int)sc->rindex]; if ((rp->rmd0 & (RMD0_STP|RMD0_ENP)) != (RMD0_STP|RMD0_ENP)) { - printf("%s: chained packet\n", XNAME); + printf("%s: chained packet\n", device_xname(sc->sc_dev)); sc->is_if.if_ierrors++; goto rnext; } @@ -582,9 +577,9 @@ qtrint(struct qt_softc *sc) #ifdef QTDEBUG char buf[100]; bitmask_snprintf(rp->rmd0, RMD0_BITS, buf, 100); - printf("%s: rmd0 %s\n", XNAME, buf); + printf("%s: rmd0 %s\n", device_xname(sc->sc_dev), buf); bitmask_snprintf(rp->rmd2, RMD2_BITS, buf, 100); - printf("%s: rmd2 %s\n", XNAME, buf); + printf("%s: rmd2 %s\n", device_xname(sc->sc_dev), buf); #endif sc->is_if.if_ierrors++; goto rnext; @@ -611,11 +606,8 @@ rnext: } int -qtioctl(ifp, cmd, data) - register struct ifnet *ifp; - u_long cmd; - void * data; - { +qtioctl(struct ifnet *ifp, u_long cmd, void *data) +{ int s, error; s = splnet(); @@ -632,14 +624,12 @@ qtioctl(ifp, cmd, data) } void -qtsrr(sc, srrbits) - struct qt_softc *sc; - int srrbits; - { +qtsrr(struct qt_softc *sc, int srrbits) +{ char buf[100]; bitmask_snprintf(srrbits, SRR_BITS, buf, sizeof buf); - printf("%s: srr=%s\n", sc->sc_dev.dv_xname, buf); - } + printf("%s: srr=%s\n", device_xname(sc->sc_dev), buf); +} /* * Stop activity on the interface. @@ -679,7 +669,7 @@ qtstop(struct ifnet *ifp, int disable) void qtreset(sc) - register struct qt_softc *sc; + struct qt_softc *sc; { qtturbo(sc); diff --git a/sys/dev/qbus/if_uba.c b/sys/dev/qbus/if_uba.c index f2b0746235e..d1fc62d8065 100644 --- a/sys/dev/qbus/if_uba.c +++ b/sys/dev/qbus/if_uba.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_uba.c,v 1.29 2007/10/19 12:01:09 ad Exp $ */ +/* $NetBSD: if_uba.c,v 1.30 2008/03/11 05:34:01 matt Exp $ */ /* * Copyright (c) 1982, 1986, 1988 Regents of the University of California. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_uba.c,v 1.29 2007/10/19 12:01:09 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_uba.c,v 1.30 2008/03/11 05:34:01 matt Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -161,7 +161,7 @@ bad: } struct mbuf * -getmcl() +getmcl(void) { struct mbuf *m; diff --git a/sys/dev/qbus/qd.c b/sys/dev/qbus/qd.c index d8c60a5264e..f95a2d2dd65 100644 --- a/sys/dev/qbus/qd.c +++ b/sys/dev/qbus/qd.c @@ -1,4 +1,4 @@ -/* $NetBSD: qd.c,v 1.42 2008/03/01 14:16:50 rmind Exp $ */ +/* $NetBSD: qd.c,v 1.43 2008/03/11 05:34:01 matt Exp $ */ /*- * Copyright (c) 1988 Regents of the University of California. @@ -58,7 +58,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: qd.c,v 1.42 2008/03/01 14:16:50 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: qd.c,v 1.43 2008/03/11 05:34:01 matt Exp $"); #include "opt_ddb.h" @@ -234,8 +234,8 @@ int QDlast_DMAtype; /* type of the last DMA operation */ */ #define TOY ((time.tv_sec * 100) + (time.tv_usec / 10000)) -void qd_attach(struct device *, struct device *, void *); -static int qd_match(struct device *, struct cfdata *, void *); +void qd_attach(device_t, device_t, void *); +static int qd_match(device_t, cfdata_t, void *); static void qddint(void *); /* DMA gate array intrpt service */ static void qdaint(void *); /* Dragon ADDER intrpt service */ @@ -550,8 +550,8 @@ CFATTACH_DECL(qd, sizeof(struct qd_softc), */ static int qd_match(parent, match, aux) - struct device *parent; - struct cfdata *match; + device_t parent; + cfdata_t match; void *aux; { struct qd_softc ssc; @@ -729,7 +729,7 @@ qd_match(parent, match, aux) void qd_attach(parent, self, aux) - struct device *parent, *self; + device_t parent, *self; void *aux; { struct uba_attach_args *ua = aux; @@ -900,7 +900,7 @@ qdclose(dev, flag, mode, p) qd = &qdmap[unit]; uh = (struct uba_softc *) - device_parent((struct device *)(qd_cd.cd_devs[unit])); + device_parent((device_t )(qd_cd.cd_devs[unit])); if ((minor_dev & 0x03) == 2) { @@ -1103,7 +1103,7 @@ qdioctl(dev, cmd, datap, flags, p) struct uba_softc *uh; uh = (struct uba_softc *) - device_parent((struct device *)(qd_cd.cd_devs[unit])); + device_parent((device_t )(qd_cd.cd_devs[unit])); /* * service graphic device ioctl commands @@ -1719,7 +1719,7 @@ qd_strategy(bp) unit = (minor(bp->b_dev) >> 2) & 0x07; uh = (struct uba_softc *) - device_parent((struct device *)(qd_cd.cd_devs[unit])); + device_parent((device_t )(qd_cd.cd_devs[unit])); /* * init pointers @@ -2051,7 +2051,7 @@ static void qddint(arg) void *arg; { - struct device *dv = arg; + device_t dv = arg; struct DMAreq_header *header; struct DMAreq *request; volatile struct dga *dga; @@ -2229,7 +2229,7 @@ static void qdaint(arg) void *arg; { - struct device *dv = arg; + device_t dv = arg; volatile struct adder *adder; struct color_buf *cbuf; int i; @@ -2316,7 +2316,7 @@ static void qdiint(arg) void *arg; { - struct device *dv = arg; + device_t dv = arg; struct _vs_event *event; struct qdinput *eqh; volatile struct dga *dga; diff --git a/sys/dev/qbus/rf.c b/sys/dev/qbus/rf.c index 3367b03317a..4f283288877 100644 --- a/sys/dev/qbus/rf.c +++ b/sys/dev/qbus/rf.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf.c,v 1.18 2008/01/04 22:04:59 joerg Exp $ */ +/* $NetBSD: rf.c,v 1.19 2008/03/11 05:34:02 matt Exp $ */ /* * Copyright (c) 2002 Jochen Kunz. * All rights reserved. @@ -36,7 +36,7 @@ TODO: */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf.c,v 1.18 2008/01/04 22:04:59 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf.c,v 1.19 2008/03/11 05:34:02 matt Exp $"); /* autoconfig stuff */ #include <sys/param.h> @@ -98,10 +98,10 @@ __KERNEL_RCSID(0, "$NetBSD: rf.c,v 1.18 2008/01/04 22:04:59 joerg Exp $"); /* autoconfig stuff */ -static int rfc_match(struct device *, struct cfdata *, void *); -static void rfc_attach(struct device *, struct device *, void *); -static int rf_match(struct device *, struct cfdata *, void *); -static void rf_attach(struct device *, struct device *, void *); +static int rfc_match(device_t, cfdata_t, void *); +static void rfc_attach(device_t, device_t, void *); +static int rf_match(device_t, cfdata_t, void *); +static void rf_attach(device_t, device_t, void *); static int rf_print(void *, const char *); /* device interface functions / interface to disk(9) */ @@ -143,8 +143,8 @@ const struct cdevsw rf_cdevsw = { struct rfc_softc { - struct device sc_dev; /* common device data */ - struct device *sc_childs[2]; /* child devices */ + device_t sc_dev; /* common device data */ + device_t sc_childs[2]; /* child devices */ struct evcnt sc_intr_count; /* Interrupt counter for statistics */ struct buf *sc_curbuf; /* buf that is currently in work */ bus_space_tag_t sc_iot; /* bus_space I/O tag */ @@ -159,7 +159,7 @@ struct rfc_softc { -CFATTACH_DECL( +CFATTACH_DECL_NEW( rfc, sizeof(struct rfc_softc), rfc_match, @@ -171,8 +171,9 @@ CFATTACH_DECL( struct rf_softc { - struct device sc_dev; /* common device data */ + device_t sc_dev; /* common device data */ struct disk sc_disk; /* common disk device data */ + struct rfc_softc *sc_rfc; /* our parent */ struct bufq_state *sc_bufq; /* queue of pending transfers */ int sc_state; /* state of drive */ u_int8_t sc_dnum; /* drive number, 0 or 1 */ @@ -180,7 +181,7 @@ struct rf_softc { -CFATTACH_DECL( +CFATTACH_DECL_NEW( rf, sizeof(struct rf_softc), rf_match, @@ -198,7 +199,7 @@ struct rfc_attach_args { -struct dkdriver rfdkdriver = { +const struct dkdriver rfdkdriver = { rfstrategy }; @@ -218,7 +219,7 @@ static void rfc_intr(void *); * RX2ES has to be set, all other bits must be 0 */ int -rfc_match(struct device *parent, struct cfdata *match, void *aux) +rfc_match(device_t parent, cfdata_t match, void *aux) { struct uba_attach_args *ua = aux; int i; @@ -292,7 +293,7 @@ rfcprobedens(struct rfc_softc *rfc_sc, int dnum) if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2CS) & RX2CS_TR) == 0) { printf("%s: did not respond to Read Sector CMD(1)\n", - rfc_sc->sc_dev.dv_xname); + device_xname(rfc_sc->sc_dev)); return(-1); } bus_space_write_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2SA, 1); @@ -301,7 +302,7 @@ rfcprobedens(struct rfc_softc *rfc_sc, int dnum) if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2CS) & RX2CS_TR) == 0) { printf("%s: did not respond to Read Sector CMD(2)\n", - rfc_sc->sc_dev.dv_xname); + device_xname(rfc_sc->sc_dev)); return(-1); } bus_space_write_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2TA, 1); @@ -314,7 +315,7 @@ rfcprobedens(struct rfc_softc *rfc_sc, int dnum) } if (i >= 200) { printf("%s: did not respond to Read Sector CMD(3)\n", - rfc_sc->sc_dev.dv_xname); + device_xname(rfc_sc->sc_dev)); return(-1); } if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2CS) @@ -328,13 +329,14 @@ rfcprobedens(struct rfc_softc *rfc_sc, int dnum) void -rfc_attach(struct device *parent, struct device *self, void *aux) +rfc_attach(device_t parent, device_t self, void *aux) { struct rfc_softc *rfc_sc = device_private(self); struct uba_attach_args *ua = aux; struct rfc_attach_args rfc_aa; int i; + rfc_sc->sc_dev = self; rfc_sc->sc_iot = ua->ua_iot; rfc_sc->sc_ioh = ua->ua_ioh; rfc_sc->sc_dmat = ua->ua_dmat; @@ -344,7 +346,7 @@ rfc_attach(struct device *parent, struct device *self, void *aux) &rfc_sc->sc_intr_count); /* Attach to the interrupt counter, see evcnt(9) */ evcnt_attach_dynamic(&rfc_sc->sc_intr_count, EVCNT_TYPE_INTR, - ua->ua_evcnt, rfc_sc->sc_dev.dv_xname, "intr"); + ua->ua_evcnt, device_xname(rfc_sc->sc_dev), "intr"); /* get a bus_dma(9) handle */ i = bus_dmamap_create(rfc_sc->sc_dmat, RX2_BYTE_DD, 1, RX2_BYTE_DD, 0, BUS_DMA_ALLOCNOW, &rfc_sc->sc_dmam); @@ -393,9 +395,9 @@ rfc_attach(struct device *parent, struct device *self, void *aux) * So attach them. */ rfc_aa.dnum = 0; - rfc_sc->sc_childs[0] = config_found(&rfc_sc->sc_dev, &rfc_aa,rf_print); + rfc_sc->sc_childs[0] = config_found(rfc_sc->sc_dev, &rfc_aa, rf_print); rfc_aa.dnum = 1; - rfc_sc->sc_childs[1] = config_found(&rfc_sc->sc_dev, &rfc_aa,rf_print); + rfc_sc->sc_childs[1] = config_found(rfc_sc->sc_dev, &rfc_aa, rf_print); #else /* RX02_PROBE */ /* * There are clones of the DEC RX system with standard shugart @@ -425,7 +427,7 @@ rfc_attach(struct device *parent, struct device *self, void *aux) int -rf_match(struct device *parent, struct cfdata *match, void *aux) +rf_match(device_t parent, cfdata_t match, void *aux) { struct rfc_attach_args *rfc_aa = aux; @@ -442,17 +444,18 @@ rf_match(struct device *parent, struct cfdata *match, void *aux) void -rf_attach(struct device *parent, struct device *self, void *aux) +rf_attach(device_t parent, device_t self, void *aux) { struct rf_softc *rf_sc = device_private(self); + struct rfc_softc *rfc_sc = device_private(parent); struct rfc_attach_args *rfc_aa = (struct rfc_attach_args *)aux; - struct rfc_softc *rfc_sc; struct disklabel *dl; - rfc_sc = (struct rfc_softc *)device_parent(&rf_sc->sc_dev); + rf_sc->sc_dev = self; + rf_sc->sc_rfc = rfc_sc; rf_sc->sc_dnum = rfc_aa->dnum; rf_sc->sc_state = 0; - disk_init(&rf_sc->sc_disk, rf_sc->sc_dev.dv_xname, &rfdkdriver); + disk_init(&rf_sc->sc_disk, device_xname(rf_sc->sc_dev), &rfdkdriver); disk_attach(&rf_sc->sc_disk); dl = rf_sc->sc_disk.dk_label; dl->d_type = DTYPE_FLOPPY; /* drive type */ @@ -530,7 +533,7 @@ rfc_sendcmd(struct rfc_softc *rfc_sc, int cmd, int data1, int data2) if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2CS) & RX2CS_TR) == 0) { printf("%s: did not respond to CMD %x (1)\n", - rfc_sc->sc_dev.dv_xname, cmd); + device_xname(rfc_sc->sc_dev), cmd); return(-1); } bus_space_write_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2DB, @@ -544,7 +547,7 @@ rfc_sendcmd(struct rfc_softc *rfc_sc, int cmd, int data1, int data2) if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2CS) & RX2CS_TR) == 0) { printf("%s: did not respond to CMD %x (2)\n", - rfc_sc->sc_dev.dv_xname, cmd); + device_xname(rfc_sc->sc_dev), cmd); return(-1); } bus_space_write_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2DB, @@ -560,20 +563,19 @@ rfstrategy(struct buf *buf) { struct rf_softc *rf_sc; struct rfc_softc *rfc_sc; - int i; + int s; - i = DISKUNIT(buf->b_dev); - if (i >= rf_cd.cd_ndevs || (rf_sc = rf_cd.cd_devs[i]) == NULL) { + if ((rf_sc = device_lookup_private(&rf_cd, DISKUNIT(buf->b_dev))) == NULL) { buf->b_error = ENXIO; biodone(buf); return; } - rfc_sc = (struct rfc_softc *)device_parent(&rf_sc->sc_dev); + rfc_sc = rf_sc->sc_rfc; /* We are going to operate on a non-open dev? PANIC! */ - if ((rf_sc->sc_state & 1 << (DISKPART(buf->b_dev) + RFS_OPEN_SHIFT)) + if ((rf_sc->sc_state & (1 << (DISKPART(buf->b_dev) + RFS_OPEN_SHIFT))) == 0) panic("rfstrategy: can not operate on non-open drive %s " - "partition %d", rf_sc->sc_dev.dv_xname, + "partition %d", device_xname(rf_sc->sc_dev), DISKPART(buf->b_dev)); if (buf->b_bcount == 0) { biodone(buf); @@ -590,7 +592,7 @@ rfstrategy(struct buf *buf) * Seek sort for disks. We depend on the driver which calls us using * b_resid as the current cylinder number. */ - i = splbio(); + s = splbio(); if (rfc_sc->sc_curbuf == NULL) { rfc_sc->sc_curchild = rf_sc->sc_dnum; rfc_sc->sc_curbuf = buf; @@ -602,12 +604,9 @@ rfstrategy(struct buf *buf) BUFQ_PUT(rf_sc->sc_bufq, buf); buf->b_resid = 0; } - splx(i); - return; + splx(s); } - - /* * Look if there is another buffer in the bufferqueue of this drive * and start to process it if there is one. @@ -685,7 +684,7 @@ rfc_intr(void *intarg) } } else { printf("%s: density error.\n", - rf_sc->sc_dev.dv_xname); + device_xname(rf_sc->sc_dev)); RFS_SETCMD(rf_sc->sc_state,RFS_NOTINIT); wakeup(rf_sc); } @@ -962,13 +961,11 @@ rfopen(dev_t dev, int oflags, int devtype, struct lwp *l) struct rf_softc *rf_sc; struct rfc_softc *rfc_sc; struct disklabel *dl; - int unit; - unit = DISKUNIT(dev); - if (unit >= rf_cd.cd_ndevs || (rf_sc = rf_cd.cd_devs[unit]) == NULL) { - return(ENXIO); - } - rfc_sc = (struct rfc_softc *)device_parent(&rf_sc->sc_dev); + if ((rf_sc = device_lookup_private(&rf_cd, DISKUNIT(dev))) == NULL) + return ENXIO; + + rfc_sc = rf_sc->sc_rfc; dl = rf_sc->sc_disk.dk_label; switch (DISKPART(dev)) { case 0: /* Part. a is single density. */ @@ -1061,7 +1058,7 @@ rfclose(dev_t dev, int fflag, int devtype, struct lwp *l) } if ((rf_sc->sc_state & 1 << (DISKPART(dev) + RFS_OPEN_SHIFT)) == 0) panic("rfclose: can not close non-open drive %s " - "partition %d", rf_sc->sc_dev.dv_xname, DISKPART(dev)); + "partition %d", device_xname(rf_sc->sc_dev), DISKPART(dev)); else rf_sc->sc_state &= ~(1 << (DISKPART(dev) + RFS_OPEN_SHIFT)); if ((rf_sc->sc_state & RFS_OPEN_MASK) == 0) @@ -1102,7 +1099,7 @@ rfioctl(dev_t dev, u_long cmd, void *data, int fflag, struct lwp *l) /* We are going to operate on a non-open dev? PANIC! */ if ((rf_sc->sc_state & 1 << (DISKPART(dev) + RFS_OPEN_SHIFT)) == 0) panic("rfioctl: can not operate on non-open drive %s " - "partition %d", rf_sc->sc_dev.dv_xname, DISKPART(dev)); + "partition %d", device_xname(rf_sc->sc_dev), DISKPART(dev)); switch (cmd) { /* get and set disklabel; DIOCGPART used internally */ case DIOCGDINFO: /* get */ diff --git a/sys/dev/qbus/rl.c b/sys/dev/qbus/rl.c index 0bb05f6220b..41b9f475e7d 100644 --- a/sys/dev/qbus/rl.c +++ b/sys/dev/qbus/rl.c @@ -1,4 +1,4 @@ -/* $NetBSD: rl.c,v 1.37 2007/10/19 12:01:09 ad Exp $ */ +/* $NetBSD: rl.c,v 1.38 2008/03/11 05:34:02 matt Exp $ */ /* * Copyright (c) 2000 Ludd, University of Lule}, Sweden. All rights reserved. @@ -43,7 +43,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rl.c,v 1.37 2007/10/19 12:01:09 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rl.c,v 1.38 2008/03/11 05:34:02 matt Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -70,33 +70,33 @@ __KERNEL_RCSID(0, "$NetBSD: rl.c,v 1.37 2007/10/19 12:01:09 ad Exp $"); #include "ioconf.h" #include "locators.h" -static int rlcmatch(struct device *, struct cfdata *, void *); -static void rlcattach(struct device *, struct device *, void *); +static int rlcmatch(device_t, cfdata_t, void *); +static void rlcattach(device_t, device_t, void *); static int rlcprint(void *, const char *); static void rlcintr(void *); -static int rlmatch(struct device *, struct cfdata *, void *); -static void rlattach(struct device *, struct device *, void *); +static int rlmatch(device_t, cfdata_t, void *); +static void rlattach(device_t, device_t, void *); static void rlcstart(struct rlc_softc *, struct buf *); static void waitcrdy(struct rlc_softc *); -static void rlcreset(struct device *); +static void rlcreset(device_t); -CFATTACH_DECL(rlc, sizeof(struct rlc_softc), +CFATTACH_DECL_NEW(rlc, sizeof(struct rlc_softc), rlcmatch, rlcattach, NULL, NULL); -CFATTACH_DECL(rl, sizeof(struct rl_softc), +CFATTACH_DECL_NEW(rl, sizeof(struct rl_softc), rlmatch, rlattach, NULL, NULL); -dev_type_open(rlopen); -dev_type_close(rlclose); -dev_type_read(rlread); -dev_type_write(rlwrite); -dev_type_ioctl(rlioctl); -dev_type_strategy(rlstrategy); -dev_type_dump(rldump); -dev_type_size(rlsize); +static dev_type_open(rlopen); +static dev_type_close(rlclose); +static dev_type_read(rlread); +static dev_type_write(rlwrite); +static dev_type_ioctl(rlioctl); +static dev_type_strategy(rlstrategy); +static dev_type_dump(rldump); +static dev_type_size(rlpsize); const struct bdevsw rl_bdevsw = { - rlopen, rlclose, rlstrategy, rlioctl, rldump, rlsize, D_DISK + rlopen, rlclose, rlstrategy, rlioctl, rldump, rlpsize, D_DISK }; const struct cdevsw rl_cdevsw = { @@ -111,7 +111,7 @@ const struct cdevsw rl_cdevsw = { #define RL_RREG(reg) \ bus_space_read_2(sc->sc_iot, sc->sc_ioh, (reg)) -static const char *rlstates[] = { +static const char * const rlstates[] = { "drive not loaded", "drive spinning up", "drive brushes out", @@ -122,7 +122,7 @@ static const char *rlstates[] = { "drive spun down", }; -static struct dkdriver rldkdriver = { +static const struct dkdriver rldkdriver = { rlstrategy, minphys }; @@ -152,7 +152,7 @@ waitcrdy(struct rlc_softc *sc) if (RL_RREG(RL_CS) & RLCS_CRDY) return; } - printf("%s: never got ready\n", sc->sc_dev.dv_xname); /* ?panic? */ + aprint_error_dev(sc->sc_dev, "never got ready\n"); /* ?panic? */ } int @@ -171,7 +171,7 @@ rlcprint(void *aux, const char *name) * Force the controller to interrupt. */ int -rlcmatch(struct device *parent, struct cfdata *cf, void *aux) +rlcmatch(device_t parent, cfdata_t cf, void *aux) { struct uba_attach_args *ua = aux; struct rlc_softc ssc, *sc = &ssc; @@ -192,20 +192,22 @@ rlcmatch(struct device *parent, struct cfdata *cf, void *aux) } void -rlcattach(struct device *parent, struct device *self, void *aux) +rlcattach(device_t parent, device_t self, void *aux) { struct rlc_softc *sc = device_private(self); struct uba_attach_args *ua = aux; struct rlc_attach_args ra; int i, error; + sc->sc_dev = self; + sc->sc_uh = device_private(parent); sc->sc_iot = ua->ua_iot; sc->sc_ioh = ua->ua_ioh; sc->sc_dmat = ua->ua_dmat; uba_intr_establish(ua->ua_icookie, ua->ua_cvec, rlcintr, sc, &sc->sc_intrcnt); evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt, - sc->sc_dev.dv_xname, "intr"); + device_xname(sc->sc_dev), "intr"); uba_reset_establish(rlcreset, self); printf("\n"); @@ -218,7 +220,7 @@ rlcattach(struct device *parent, struct device *self, void *aux) error = bus_dmamap_create(sc->sc_dmat, MAXRLXFER, 1, MAXRLXFER, 0, BUS_DMA_ALLOCNOW, &sc->sc_dmam); if (error) { - printf(": Failed to allocate DMA map, error %d\n", error); + aprint_error(": Failed to allocate DMA map, error %d\n", error); return; } bufq_alloc(&sc->sc_q, "disksort", BUFQ_SORT_CYLINDER); @@ -230,12 +232,12 @@ rlcattach(struct device *parent, struct device *self, void *aux) ra.type = RL_RREG(RL_MP); ra.hwid = i; if ((RL_RREG(RL_CS) & RLCS_ERR) == 0) - config_found(&sc->sc_dev, &ra, rlcprint); + config_found(sc->sc_dev, &ra, rlcprint); } } int -rlmatch(struct device *parent, struct cfdata *cf, void *aux) +rlmatch(device_t parent, cfdata_t cf, void *aux) { struct rlc_attach_args *ra = aux; @@ -246,14 +248,16 @@ rlmatch(struct device *parent, struct cfdata *cf, void *aux) } void -rlattach(struct device *parent, struct device *self, void *aux) +rlattach(device_t parent, device_t self, void *aux) { struct rl_softc *rc = device_private(self); struct rlc_attach_args *ra = aux; struct disklabel *dl; + rc->rc_dev = self; + rc->rc_rlc = device_private(parent); rc->rc_hwid = ra->hwid; - disk_init(&rc->rc_disk, rc->rc_dev.dv_xname, &rldkdriver); + disk_init(&rc->rc_disk, device_xname(rc->rc_dev), &rldkdriver); disk_attach(&rc->rc_disk); dl = rc->rc_disk.dk_label; dl->d_npartitions = 3; @@ -274,8 +278,7 @@ rlattach(struct device *parent, struct device *self, void *aux) dl->d_sbsize = SBLOCKSIZE; dl->d_rpm = 2400; dl->d_type = DTYPE_DEC; - printf(": %s, %s\n", dl->d_typename, - rlstate((struct rlc_softc *)parent, ra->hwid)); + printf(": %s, %s\n", dl->d_typename, rlstate(rc->rc_rlc, ra->hwid)); /* * XXX We should try to discovery wedges here, but @@ -287,22 +290,19 @@ rlattach(struct device *parent, struct device *self, void *aux) int rlopen(dev_t dev, int flag, int fmt, struct lwp *l) { - int error, part, unit, mask; - struct disklabel *dl; + struct rl_softc * const rc = device_lookup_private(&rl_cd, DISKUNIT(dev)); struct rlc_softc *sc; - struct rl_softc *rc; + int error, part, mask; + struct disklabel *dl; const char *msg; /* * Make sure this is a reasonable open request. */ - unit = DISKUNIT(dev); - if (unit >= rl_cd.cd_ndevs) - return ENXIO; - rc = rl_cd.cd_devs[unit]; - if (rc == 0) + if (rc == NULL) return ENXIO; + sc = rc->rc_rlc; part = DISKPART(dev); mutex_enter(&rc->rc_disk.dk_openlock); @@ -316,7 +316,6 @@ rlopen(dev_t dev, int flag, int fmt, struct lwp *l) goto bad1; } - sc = (struct rlc_softc *)device_parent(&rc->rc_dev); /* Check that the disk actually is useable */ msg = rlstate(sc, rc->rc_hwid); if (msg == NULL || msg == rlstates[RLMP_UNLOAD] || @@ -338,12 +337,12 @@ rlopen(dev_t dev, int flag, int fmt, struct lwp *l) rc->rc_cyl = (mp >> 7) & 0777; rc->rc_state = DK_OPEN; /* Get disk label */ - printf("%s: ", rc->rc_dev.dv_xname); maj = cdevsw_lookup_major(&rl_cdevsw); if ((msg = readdisklabel(MAKEDISKDEV(maj, - device_unit(&rc->rc_dev), RAW_PART), rlstrategy, dl, NULL))) - printf("%s: ", msg); - printf("size %d sectors\n", dl->d_secperunit); + device_unit(rc->rc_dev), RAW_PART), rlstrategy, dl, NULL))) + aprint_normal_dev(rc->rc_dev, "%s", msg); + aprint_normal_dev(rc->rc_dev, "size %d sectors\n", + dl->d_secperunit); } if (part >= dl->d_npartitions) { error = ENXIO; @@ -395,23 +394,15 @@ rlclose(dev_t dev, int flag, int fmt, struct lwp *l) void rlstrategy(struct buf *bp) { + struct rl_softc * const rc = device_lookup_private(&rl_cd, DISKUNIT(bp->b_dev)); struct disklabel *lp; - struct rlc_softc *sc; - struct rl_softc *rc; - int unit, s, err; - /* - * Make sure this is a reasonable drive to use. - */ - unit = DISKUNIT(bp->b_dev); - if (unit > rl_cd.cd_ndevs || (rc = rl_cd.cd_devs[unit]) == NULL) { - bp->b_error = ENXIO; - goto done; - } - if (rc->rc_state != DK_OPEN) /* How did we end up here at all? */ + int s; + + if (rc == NULL || rc->rc_state != DK_OPEN) /* How did we end up here at all? */ panic("rlstrategy: state impossible"); lp = rc->rc_disk.dk_label; - if ((err = bounds_check_with_label(&rc->rc_disk, bp, 1)) <= 0) + if (bounds_check_with_label(&rc->rc_disk, bp, 1) <= 0) goto done; if (bp->b_bcount == 0) @@ -420,11 +411,10 @@ rlstrategy(struct buf *bp) bp->b_rawblkno = bp->b_blkno + lp->d_partitions[DISKPART(bp->b_dev)].p_offset; bp->b_cylinder = bp->b_rawblkno / lp->d_secpercyl; - sc = (struct rlc_softc *)device_parent(&rc->rc_dev); s = splbio(); - BUFQ_PUT(sc->sc_q, bp); - rlcstart(sc, 0); + BUFQ_PUT(rc->rc_rlc->sc_q, bp); + rlcstart(rc->rc_rlc, 0); splx(s); return; @@ -500,51 +490,49 @@ rlioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l) err = EBADF; break; - case DIOCAWEDGE: - { + case DIOCAWEDGE: { struct dkwedge_info *dkw = (void *) addr; if ((flag & FWRITE) == 0) return (EBADF); /* If the ioctl happens here, the parent is us. */ - strcpy(dkw->dkw_parent, rc->rc_dev.dv_xname); - return (dkwedge_add(dkw)); - } + strcpy(dkw->dkw_parent, device_xname(rc->rc_dev)); + return dkwedge_add(dkw); + } - case DIOCDWEDGE: - { + case DIOCDWEDGE: { struct dkwedge_info *dkw = (void *) addr; if ((flag & FWRITE) == 0) return (EBADF); /* If the ioctl happens here, the parent is us. */ - strcpy(dkw->dkw_parent, rc->rc_dev.dv_xname); - return (dkwedge_del(dkw)); - } + strcpy(dkw->dkw_parent, device_xname(rc->rc_dev)); + return dkwedge_del(dkw); + } - case DIOCLWEDGES: - { + case DIOCLWEDGES: { struct dkwedge_list *dkwl = (void *) addr; - return (dkwedge_list(&rc->rc_disk, dkwl, l)); - } + return dkwedge_list(&rc->rc_disk, dkwl, l); + } default: err = ENOTTY; + break; } return err; } int -rlsize(dev_t dev) +rlpsize(dev_t dev) { + struct rl_softc * const rc = device_lookup_private(&rl_cd, DISKUNIT(dev)); struct disklabel *dl; - struct rl_softc *rc; - int size, unit = DISKUNIT(dev); + int size; - if ((unit >= rl_cd.cd_ndevs) || ((rc = rl_cd.cd_devs[unit]) == 0)) + if (rc == NULL) return -1; dl = rc->rc_disk.dk_label; size = dl->d_partitions[DISKPART(dev)].p_size * @@ -571,7 +559,7 @@ rlwrite(dev_t dev, struct uio *uio, int ioflag) return (physio(rlstrategy, NULL, dev, B_WRITE, minphys, uio)); } -static const char *rlerr[] = { +static const char * const rlerr[] = { "no", "operation incomplete", "read data CRC", @@ -599,7 +587,7 @@ rlcintr(void *arg) bp = sc->sc_active; if (bp == 0) { - printf("%s: strange interrupt\n", sc->sc_dev.dv_xname); + aprint_error_dev(sc->sc_dev, "strange interrupt\n"); return; } bus_dmamap_unload(sc->sc_dmat, sc->sc_dmam); @@ -608,7 +596,7 @@ rlcintr(void *arg) if (cs & RLCS_ERR) { int error = (cs & RLCS_ERRMSK) >> 10; - printf("%s: %s\n", sc->sc_dev.dv_xname, rlerr[error]); + aprint_error_dev(sc->sc_dev, "%s\n", rlerr[error]); bp->b_error = EIO; bp->b_resid = bp->b_bcount; sc->sc_bytecnt = 0; @@ -686,7 +674,7 @@ rlcstart(struct rlc_softc *sc, struct buf *ob) BUS_DMA_NOWAIT); if (err) panic("%s: bus_dmamap_load failed: %d", - sc->sc_dev.dv_xname, err); + device_xname(sc->sc_dev), err); RL_WREG(RL_BA, (sc->sc_dmam->dm_segs[0].ds_addr & 0xffff)); /* Count up vars */ @@ -705,20 +693,21 @@ rlcstart(struct rlc_softc *sc, struct buf *ob) * Retracts all disks and restarts active transfers. */ void -rlcreset(struct device *dev) +rlcreset(device_t dev) { - struct rlc_softc *sc = (struct rlc_softc *)dev; + struct rlc_softc *sc = device_private(dev); struct rl_softc *rc; int i; u_int16_t mp; for (i = 0; i < rl_cd.cd_ndevs; i++) { - if ((rc = rl_cd.cd_devs[i]) == NULL) + if ((rc = device_lookup_private(&rl_cd, i)) == NULL) continue; if (rc->rc_state != DK_OPEN) continue; + if (rc->rc_rlc != sc) + continue; - printf(" %s", rc->rc_dev.dv_xname); RL_WREG(RL_CS, RLCS_RHDR|(rc->rc_hwid << RLCS_USHFT)); waitcrdy(sc); mp = RL_RREG(RL_MP); diff --git a/sys/dev/qbus/rlvar.h b/sys/dev/qbus/rlvar.h index 9396e3d9887..fcaa1871188 100644 --- a/sys/dev/qbus/rlvar.h +++ b/sys/dev/qbus/rlvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: rlvar.h,v 1.7 2007/03/04 06:02:30 christos Exp $ */ +/* $NetBSD: rlvar.h,v 1.8 2008/03/11 05:34:02 matt Exp $ */ /* * Copyright (c) 2000 Ludd, University of Lule}, Sweden. All rights reserved. @@ -36,10 +36,11 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rlvar.h,v 1.7 2007/03/04 06:02:30 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rlvar.h,v 1.8 2008/03/11 05:34:02 matt Exp $"); struct rlc_softc { - struct device sc_dev; + device_t sc_dev; + struct uba_softc *sc_uh; struct evcnt sc_intrcnt; bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; @@ -53,7 +54,8 @@ struct rlc_softc { }; struct rl_softc { - struct device rc_dev; + device_t rc_dev; + struct rlc_softc *rc_rlc; struct disk rc_disk; int rc_state; int rc_head; diff --git a/sys/dev/qbus/ts.c b/sys/dev/qbus/ts.c index 427b328fa1d..3d936879278 100644 --- a/sys/dev/qbus/ts.c +++ b/sys/dev/qbus/ts.c @@ -1,4 +1,4 @@ -/* $NetBSD: ts.c,v 1.23 2008/02/15 13:46:04 ad Exp $ */ +/* $NetBSD: ts.c,v 1.24 2008/03/11 05:34:02 matt Exp $ */ /*- * Copyright (c) 1991 The Regents of the University of California. @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ts.c,v 1.23 2008/02/15 13:46:04 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ts.c,v 1.24 2008/03/11 05:34:02 matt Exp $"); #undef TSDEBUG @@ -101,10 +101,10 @@ __KERNEL_RCSID(0, "$NetBSD: ts.c,v 1.23 2008/02/15 13:46:04 ad Exp $"); #include "ioconf.h" -struct ts { - struct cmd cmd; /* command packet */ - struct chr chr; /* characteristics packet */ - struct status status; /* status packet */ +struct ts { + struct cmd cmd; /* command packet */ + struct chr chr; /* characteristics packet */ + struct status status; /* status packet */ }; /* @@ -112,31 +112,32 @@ struct ts { * also status per tape-unit, since only one unit per controller * (thus we have no struct ts_info) */ -struct ts_softc { - struct device sc_dev; /* Autoconf ... */ - struct uba_unit sc_unit; /* Struct common for UBA to talk */ - struct evcnt sc_intrcnt; /* Interrupt counting */ - struct ubinfo sc_ui; /* mapping info for struct ts */ - struct uba_unit sc_uu; /* Struct for UBA to communicate */ +struct ts_softc { + device_t sc_dev; /* Autoconf ... */ + struct uba_softc *sc_uh; /* the parent UBA */ + struct uba_unit sc_unit; /* Struct common for UBA to talk */ + struct evcnt sc_intrcnt; /* Interrupt counting */ + struct ubinfo sc_ui; /* mapping info for struct ts */ + struct uba_unit sc_uu; /* Struct for UBA to communicate */ bus_space_tag_t sc_iot; bus_addr_t sc_ioh; bus_dma_tag_t sc_dmat; bus_dmamap_t sc_dmam; volatile struct ts *sc_vts; /* Memory address of ts struct */ - struct ts *sc_bts; /* Unibus address of ts struct */ + struct ts *sc_bts; /* Unibus address of ts struct */ int sc_type; /* TS11 or TS05? */ short sc_waddr; /* Value to write to TSDB */ - struct bufq_state *sc_bufq; /* pending I/O requests */ + struct bufq_state *sc_bufq; /* pending I/O requests */ short sc_mapped; /* Unibus map allocated ? */ short sc_state; /* see below: ST_xxx */ short sc_rtc; /* retry count for lcmd */ short sc_openf; /* lock against multiple opens */ short sc_liowf; /* last operation was write */ - struct buf ts_cbuf; /* internal cmd buffer (for ioctls) */ + struct buf ts_cbuf; /* internal cmd buffer (for ioctls) */ }; -#define XNAME sc->sc_dev.dv_xname +#define XNAME sc->sc_dev->dv_xname #define TS_WCSR(csr, val) \ bus_space_write_2(sc->sc_iot, sc->sc_ioh, csr, val) @@ -160,12 +161,12 @@ static void tsinit(struct ts_softc *); static void tscommand(struct ts_softc *, dev_t, int, int); static int tsstart(struct ts_softc *, int); static void tswchar(struct ts_softc *); -static int tsreset(struct ts_softc *); -static int tsmatch(struct device *, struct cfdata *, void *); -static void tsattach(struct device *, struct device *, void *); +static bool tsreset(struct ts_softc *); +static int tsmatch(device_t, cfdata_t, void *); +static void tsattach(device_t, device_t, void *); static int tsready(struct uba_unit *); -CFATTACH_DECL(ts, sizeof(struct ts_softc), +CFATTACH_DECL_NEW(ts, sizeof(struct ts_softc), tsmatch, tsattach, NULL, NULL); dev_type_open(tsopen); @@ -196,8 +197,9 @@ const struct cdevsw ts_cdevsw = { * Probe for device. If found, try to raise an interrupt. */ int -tsmatch(struct device *parent, struct cfdata *match, void *aux) +tsmatch(device_t parent, cfdata_t match, void *aux) { + struct device tsdev; struct ts_softc ssc; struct ts_softc *sc = &ssc; struct uba_attach_args *ua = aux; @@ -206,13 +208,15 @@ tsmatch(struct device *parent, struct cfdata *match, void *aux) sc->sc_iot = ua->ua_iot; sc->sc_ioh = ua->ua_ioh; sc->sc_mapped = 0; - sc->sc_dev.dv_parent = parent; + sc->sc_dev = &tsdev; + sc->sc_uh = device_private(parent); strcpy(XNAME, "ts"); /* Try to reset the device */ - for (i = 0; i < 3; i++) - if (tsreset(sc) == 1) + for (i = 0; i < 3; i++) { + if (tsreset(sc)) break; + } if (i == 3) return 0; @@ -222,33 +226,37 @@ tsmatch(struct device *parent, struct cfdata *match, void *aux) /* completion of this will raise the intr. */ DELAY(1000000); /* Wait for interrupt */ - ubmemfree((void *)parent, &sc->sc_ui); + ubmemfree(sc->sc_uh, &sc->sc_ui); return 1; } /* */ void -tsattach(struct device *parent, struct device *self, void *aux) +tsattach(device_t parent, device_t self, void *aux) { - struct uba_softc *uh = device_private(parent); struct ts_softc *sc = device_private(self); struct uba_attach_args *ua = aux; int error; - char *t; + const char *t; + sc->sc_dev = self; + sc->sc_uh = device_private(parent); sc->sc_iot = ua->ua_iot; sc->sc_ioh = ua->ua_ioh; sc->sc_dmat = ua->ua_dmat; - sc->sc_uu.uu_softc = sc; + sc->sc_uu.uu_dev = self; sc->sc_uu.uu_ready = tsready; tsinit(sc); /* reset and map */ - if ((error = bus_dmamap_create(sc->sc_dmat, (64*1024), 16, (64*1024), - 0, BUS_DMA_NOWAIT, &sc->sc_dmam))) - return printf(": failed create DMA map %d\n", error); + error = bus_dmamap_create(sc->sc_dmat, (64*1024), 16, (64*1024), + 0, BUS_DMA_NOWAIT, &sc->sc_dmam); + if (error) { + aprint_error(": failed create DMA map %d\n", error); + return; + } bufq_alloc(&sc->sc_bufq, "fcfs", 0); @@ -257,11 +265,13 @@ tsattach(struct device *parent, struct device *self, void *aux) */ sc->sc_state = TS_INIT; /* tsintr() checks this ... */ tswchar(sc); - if (tsleep(sc, PRIBIO, "tsattach", 100)) - return printf(": failed SET CHARACTERISTICS\n"); + if (tsleep(sc, PRIBIO, "tsattach", 100)) { + aprint_error(": failed SET CHARACTERISTICS\n"); + return; + } sc->sc_state = TS_RUNNING; - if (uh->uh_type == UBA_UBA) { + if (sc->sc_uh->uh_type == UBA_UBA) { if (sc->sc_vts->status.xst2 & TS_SF_TU80) { sc->sc_type = TYPE_TU80; t = "TU80"; @@ -274,16 +284,17 @@ tsattach(struct device *parent, struct device *self, void *aux) t = "TS05"; } - printf("\n%s: %s\n", XNAME, t); - printf("%s: rev %d, extended features %s, transport %s\n", - XNAME, (sc->sc_vts->status.xst2 & TS_SF_MCRL) >> 2, - (sc->sc_vts->status.xst2 & TS_SF_EFES ? "enabled" : "disabled"), - (TS_RCSR(TSSR) & TS_OFL ? "offline" : "online")); + aprint_normal(": %s\n", t); + aprint_normal_dev(sc->sc_dev, + "rev %d, extended features %s, transport %s\n", + (sc->sc_vts->status.xst2 & TS_SF_MCRL) >> 2, + (sc->sc_vts->status.xst2 & TS_SF_EFES ? "enabled" : "disabled"), + (TS_RCSR(TSSR) & TS_OFL ? "offline" : "online")); uba_intr_establish(ua->ua_icookie, ua->ua_cvec, tsintr, sc, &sc->sc_intrcnt); evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt, - sc->sc_dev.dv_xname, "intr"); + device_xname(sc->sc_dev), "intr"); } /* @@ -300,8 +311,7 @@ tsinit(struct ts_softc *sc) * buffer into Unibus address space. */ sc->sc_ui.ui_size = sizeof(struct ts); - if ((ubmemalloc((void *)device_parent(&sc->sc_dev), - &sc->sc_ui, UBA_CANTWAIT))) + if (ubmemalloc(sc->sc_uh, &sc->sc_ui, UBA_CANTWAIT)) return; sc->sc_vts = (void *)sc->sc_ui.ui_vaddr; sc->sc_bts = (void *)sc->sc_ui.ui_baddr; @@ -421,7 +431,7 @@ tsstart(struct ts_softc *sc, int isloaded) cmd = TS_CMD_STAT; break; default: - printf ("%s: bad ioctl %d\n", sc->sc_dev.dv_xname, + aprint_error_dev(sc->sc_dev, "bad ioctl %d\n", (int)bp->b_resid); /* Need a no-op. get status */ cmd = TS_CMD_STAT; @@ -460,6 +470,7 @@ tsstart(struct ts_softc *sc, int isloaded) printf("tsstart: sending cmdr %x\n", sc->sc_vts->cmd.cmdr); #endif TS_WCSR(TSDB, sc->sc_waddr); + return 1; } /* @@ -468,7 +479,7 @@ tsstart(struct ts_softc *sc, int isloaded) int tsready(struct uba_unit *uu) { - struct ts_softc *sc = uu->uu_softc; + struct ts_softc *sc = device_private(uu->uu_dev); struct buf *bp = BUFQ_PEEK(sc->sc_bufq); if (bus_dmamap_load(sc->sc_dmat, sc->sc_dmam, bp->b_data, @@ -508,7 +519,7 @@ tswchar(struct ts_softc *sc) /* * Reset the TS11. Return 1 if failed, 0 if succeeded. */ -int +bool tsreset(struct ts_softc *sc) { int timeout; @@ -521,9 +532,9 @@ tsreset(struct ts_softc *sc) while ((TS_RCSR(TSSR) & TS_SSR) == 0) { DELAY(10000); if (timeout++ > 1000) - return 0; + return false; } - return 1; + return true; } static void @@ -532,9 +543,9 @@ prtstat(struct ts_softc *sc, int sr) char buf[100]; bitmask_snprintf(sr, TS_TSSR_BITS, buf, sizeof(buf)); - printf("%s: TSSR=%s\n", XNAME, buf); + aprint_normal_dev(sc->sc_dev, "TSSR=%s\n", buf); bitmask_snprintf(sc->sc_vts->status.xst0,TS_XST0_BITS,buf,sizeof(buf)); - printf("%s: XST0=%s\n", XNAME, buf); + aprint_normal_dev(sc->sc_dev, "XST0=%s\n", buf); } /* @@ -552,6 +563,7 @@ tsintr(void *arg) short ccode = sc->sc_vts->cmd.cmdr & TS_CF_CCODE; + bp = BUFQ_PEEK(sc->sc_bufq); #ifdef TSDEBUG { char buf[100]; @@ -578,7 +590,7 @@ tsintr(void *arg) * Ignore unsolicited interrupts. */ log(LOG_WARNING, "%s: stray intr [%x,%x]\n", - sc->sc_dev.dv_xname, sr, mh); + device_xname(sc->sc_dev), sr, mh); return; case TS_INIT: @@ -600,8 +612,9 @@ tsintr(void *arg) break; default: - printf ("%s: unexpected interrupt during state %d [%x,%x]\n", - sc->sc_dev.dv_xname, sc->sc_state, sr, mh); + aprint_error_dev(sc->sc_dev, + "unexpected interrupt during state %d [%x,%x]\n", + sc->sc_state, sr, mh); return; } @@ -654,6 +667,9 @@ tsintr(void *arg) } #endif if (sc->sc_vts->status.xst0 & TS_SF_TMK) { +#ifdef TSDEBUG + printf(("Tape Mark detected")); +#endif /* Read to end-of-file. No error. */ break; } @@ -662,21 +678,12 @@ tsintr(void *arg) #ifdef TSDEBUG printf("TS_TC_TSA: EOT\n"); #endif - bp->b_error = EIO; + if (bp != NULL) + bp->b_error = EIO; break; } if (sc->sc_vts->status.xst0 & TS_SF_RLS) break; - if (sc->sc_vts->status.xst0 & TS_SF_TMK) { -#ifdef TSDEBUG - printf(("Tape Mark detected")); -#endif - } - if (sc->sc_vts->status.xst0 & TS_SF_EOT) { -#ifdef TSDEBUG - printf(("End of Tape")); -#endif - } #ifndef TSDEBUG { char buf[100]; @@ -729,9 +736,10 @@ tsintr(void *arg) printf("TS_TC_TPD: errcnt %d\n", sc->sc_rtc); #endif if (sc->sc_rtc++ == 8) { - printf("%s: failed 8 retries\n", XNAME); + aprint_error_dev(sc->sc_dev, "failed 8 retries\n"); prtstat(sc, sr); - bp->b_error = EIO; + if (bp != NULL) + bp->b_error = EIO; break; } sc->sc_vts->cmd.cmdr = TS_CF_ACK | TS_CF_IE | TS_CMD_SRR; @@ -739,8 +747,6 @@ tsintr(void *arg) TS_WCSR(TSDB, sc->sc_waddr); return; - break; - case TS_TC_TNM: /* * Recoverable Error -- Tape position has not changed. @@ -748,9 +754,10 @@ tsintr(void *arg) * reissue the original command. */ if (sc->sc_rtc++ == 8) { - printf("%s: failed 8 retries\n", XNAME); + aprint_error_dev(sc->sc_dev, "failed 8 retries\n"); prtstat(sc, sr); - bp->b_error = EIO; + if (bp != NULL) + bp->b_error = EIO; break; } tsstart(sc, 1); @@ -762,8 +769,9 @@ tsintr(void *arg) * No valid recovery procedures exist unless the tape * has labels or sequence numbers. */ - printf("Tape position lost\n"); - bp->b_error = EIO; + aprint_error_dev(sc->sc_dev, "tape position lost\n"); + if (bp != NULL) + bp->b_error = EIO; break; case TS_TC_FCE: @@ -774,13 +782,13 @@ tsintr(void *arg) * fatal class code field in the TSSR register for * additional information on the type of fatal error. */ - printf ("Fatal Controller Error\n"); + aprint_error_dev(sc->sc_dev, "fatal controller error\n"); prtstat(sc, sr); break; default: - printf ("%s: error 0x%x, resetting controller\n", - sc->sc_dev.dv_xname, sr & TS_TC); + aprint_error_dev(sc->sc_dev, + "error 0x%x, resetting controller\n", sr & TS_TC); tsreset(sc); } if ((bp = BUFQ_GET(sc->sc_bufq)) != NULL) { @@ -789,7 +797,7 @@ tsintr(void *arg) #endif if (bp != &sc->ts_cbuf) { /* no ioctl */ bus_dmamap_unload(sc->sc_dmat, sc->sc_dmam); - uba_done((void *)device_parent(&sc->sc_dev)); + uba_done(sc->sc_uh); } bp->b_resid = sc->sc_vts->status.rbpcr; biodone (bp); @@ -803,16 +811,11 @@ tsintr(void *arg) * in the run state, call init to initialize the ts controller first. */ int -tsopen(dev_t dev, int flag, int type, struct proc *p) +tsopen(dev_t dev, int flag, int type, struct lwp *l) { - struct ts_softc *sc; - int unit = TS_UNIT(dev); - - if (unit >= ts_cd.cd_ndevs) - return ENXIO; + struct ts_softc *sc = device_lookup_private(&ts_cd, TS_UNIT(dev)); - sc = ts_cd.cd_devs[unit]; - if (sc == 0) + if (sc == NULL) return ENXIO; if (sc->sc_state < TS_RUNNING) @@ -829,13 +832,13 @@ tsopen(dev_t dev, int flag, int type, struct proc *p) * (ie. MTNOP) once and check the actual status.) */ if (TS_RCSR(TSSR) & TS_OFL) { - uprintf("%s: transport is offline.\n", XNAME); + uprintf("%s: transport is offline.\n", device_xname(sc->sc_dev)); sc->sc_openf = 0; return EIO; /* transport is offline */ } tscommand(sc, dev, MTNOP, 1); if ((flag & FWRITE) && (sc->sc_vts->status.xst0 & TS_SF_WLK)) { - uprintf("%s: no write ring.\n", XNAME); + uprintf("%s: no write ring.\n", device_xname(sc->sc_dev)); sc->sc_openf = 0; return EROFS; } @@ -867,9 +870,9 @@ tsopen(dev_t dev, int flag, int type, struct proc *p) * Make the tape available to others, by clearing openf flag. */ int -tsclose(dev_t dev, int flag, int type, struct proc *p) +tsclose(dev_t dev, int flag, int type, struct lwp *l) { - struct ts_softc *sc = ts_cd.cd_devs[TS_UNIT(dev)]; + struct ts_softc *sc = device_lookup_private(&ts_cd, TS_UNIT(dev)); if (flag == FWRITE || ((flag & FWRITE) && sc->sc_liowf)) { /* @@ -897,9 +900,9 @@ tsclose(dev_t dev, int flag, int type, struct proc *p) void tsstrategy(struct buf *bp) { - register int unit = TS_UNIT(bp->b_dev); - struct ts_softc *sc = (void *)ts_cd.cd_devs[unit]; - int s, empty; + struct ts_softc *sc = device_lookup_private(&ts_cd, TS_UNIT(bp->b_dev)); + bool empty; + int s; #ifdef TSDEBUG printf("buf: %p bcount %ld blkno %d\n", bp, bp->b_bcount, bp->b_blkno); @@ -917,15 +920,14 @@ tsstrategy(struct buf *bp) * Catch ioctl commands, and call the "command" routine to do them. */ int -tsioctl(dev, cmd, data, flag, p) - dev_t dev; - u_long cmd; - void *data; - int flag; - struct proc *p; +tsioctl(dev_t dev, + u_long cmd, + void *data, + int flag, + struct lwp *l) { struct buf *bp; - struct ts_softc *sc; + struct ts_softc * const sc = device_lookup_private(&ts_cd, TS_UNIT(dev)); struct mtop *mtop; /* mag tape cmd op to perform */ struct mtget *mtget; /* mag tape struct to get info in */ int callcount; /* number of times to call routine */ @@ -937,7 +939,6 @@ tsioctl(dev, cmd, data, flag, p) printf("tsioctl (%x, %lx, %p, %d)\n", dev, cmd, data, flag); #endif - sc = ts_cd.cd_devs[TS_UNIT(dev)]; bp = &sc->ts_cbuf; switch (cmd) { @@ -1058,11 +1059,7 @@ tswrite(dev_t dev, struct uio *uio, int flag) * */ int -tsdump(dev, blkno, va, size) - dev_t dev; - daddr_t blkno; - void *va; - size_t size; +tsdump(dev_t dev, daddr_t blkno, void *va, size_t size) { return EIO; } diff --git a/sys/dev/qbus/uba.c b/sys/dev/qbus/uba.c index bbc6967938c..ad4c36a9515 100644 --- a/sys/dev/qbus/uba.c +++ b/sys/dev/qbus/uba.c @@ -1,4 +1,4 @@ -/* $NetBSD: uba.c,v 1.76 2007/10/19 12:01:09 ad Exp $ */ +/* $NetBSD: uba.c,v 1.77 2008/03/11 05:34:02 matt Exp $ */ /* * Copyright (c) 1982, 1986 The Regents of the University of California. * All rights reserved. @@ -69,7 +69,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uba.c,v 1.76 2007/10/19 12:01:09 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uba.c,v 1.77 2008/03/11 05:34:02 matt Exp $"); #include <sys/param.h> #include <sys/time.h> @@ -94,7 +94,7 @@ __KERNEL_RCSID(0, "$NetBSD: uba.c,v 1.76 2007/10/19 12:01:09 ad Exp $"); #include "ioconf.h" #include "locators.h" -static int ubasearch (struct device *, struct cfdata *, +static int ubasearch (device_t, cfdata_t, const int *, void *); static int ubaprint (void *, const char *); @@ -110,7 +110,7 @@ uba_enqueue(struct uba_unit *uu) struct uba_softc *uh; int s; - uh = (void *)device_parent((struct device *)(uu->uu_softc)); + uh = device_private(device_parent(uu->uu_dev)); s = spluba(); SIMPLEQ_INSERT_TAIL(&uh->uh_resq, uu, uu_resq); @@ -142,12 +142,12 @@ uba_done(struct uba_softc *uh) * register for reset first through this routine. */ void -uba_reset_establish(void (*reset)(struct device *), struct device *dev) +uba_reset_establish(void (*reset)(device_t), device_t dev) { - struct uba_softc *uh = (void *)device_parent(dev); + struct uba_softc *uh = device_private(device_parent(dev)); struct uba_reset *ur; - ur = malloc(sizeof(struct uba_reset), M_DEVBUF, M_NOWAIT); + ur = malloc(sizeof(struct uba_reset), M_DEVBUF, M_NOWAIT|M_ZERO); if (ur == NULL) panic("uba_reset_establish"); ur->ur_dev = dev; @@ -231,12 +231,12 @@ ubareset(struct uba_softc *uh) s = spluba(); SIMPLEQ_INIT(&uh->uh_resq); - printf("%s: reset", uh->uh_dev.dv_xname); + printf("%s: reset", device_xname(uh->uh_dev)); (*uh->uh_ubainit)(uh); ur = SIMPLEQ_FIRST(&uh->uh_resetq); if (ur) do { - printf(" %s", ur->ur_dev->dv_xname); + printf(" %s", device_xname(ur->ur_dev)); (*ur->ur_reset)(ur->ur_dev); } while ((ur = SIMPLEQ_NEXT(ur, ur_resetq))); @@ -278,7 +278,7 @@ uba_attach(struct uba_softc *sc, paddr_t iopagephys) /* * Now start searching for devices. */ - config_search_ia(ubasearch,(struct device *)sc, "uba", NULL); + config_search_ia(ubasearch, sc->uh_dev, "uba", NULL); if (sc->uh_afterscan) (*sc->uh_afterscan)(sc); @@ -287,10 +287,9 @@ uba_attach(struct uba_softc *sc, paddr_t iopagephys) } int -ubasearch(struct device *parent, struct cfdata *cf, - const int *ldesc, void *aux) +ubasearch(device_t parent, cfdata_t cf, const int *ldesc, void *aux) { - struct uba_softc *sc = (struct uba_softc *)parent; + struct uba_softc *sc = device_private(parent); struct uba_attach_args ua; int i, csr, vec, br; @@ -333,7 +332,7 @@ ubasearch(struct device *parent, struct cfdata *cf, fail: printf("%s%d at %s csr %o %s\n", - cf->cf_name, cf->cf_unit, parent->dv_xname, + cf->cf_name, cf->cf_unit, device_xname(parent), csr, (i ? "zero vector" : "didn't interrupt")); forgetit: diff --git a/sys/dev/qbus/ubavar.h b/sys/dev/qbus/ubavar.h index 786440fc023..91773511ae4 100644 --- a/sys/dev/qbus/ubavar.h +++ b/sys/dev/qbus/ubavar.h @@ -1,4 +1,4 @@ -/* $NetBSD: ubavar.h,v 1.38 2007/03/04 06:02:30 christos Exp $ */ +/* $NetBSD: ubavar.h,v 1.39 2008/03/11 05:34:02 matt Exp $ */ /* * Copyright (c) 1982, 1986 Regents of the University of California. @@ -64,8 +64,8 @@ * wait states are also recorded here. */ struct uba_softc { - struct device uh_dev; /* Device struct, autoconfig */ - struct evcnt uh_intrcnt; /* interrupt counting */ + device_t uh_dev; /* Device struct, autoconfig */ + struct evcnt uh_intrcnt; /* interrupt counting */ SIMPLEQ_HEAD(, uba_unit) uh_resq; /* resource wait chain */ SIMPLEQ_HEAD(, uba_reset) uh_resetq; /* ubareset queue */ int uh_lastiv; /* last free interrupt vector */ @@ -90,7 +90,7 @@ struct uba_softc { */ struct uba_unit { SIMPLEQ_ENTRY(uba_unit) uu_resq;/* Queue while waiting for resources */ - void *uu_softc; /* Pointer to units softc */ + device_t uu_dev; /* unit's device_t */ int uu_bdp; /* for controllers that hang on to bdp's */ int (*uu_ready)(struct uba_unit *); void *uu_ref; /* Buffer this is related to */ @@ -104,8 +104,8 @@ struct uba_unit { */ struct uba_reset { SIMPLEQ_ENTRY(uba_reset) ur_resetq; - void (*ur_reset)(struct device *); - struct device *ur_dev; + void (*ur_reset)(device_t); + device_t ur_dev; }; /* @@ -158,7 +158,7 @@ struct ubinfo { #ifdef _KERNEL void uba_intr_establish(void *, int, void (*)(void *), void *, struct evcnt *); -void uba_reset_establish(void (*)(struct device *), struct device *); +void uba_reset_establish(void (*)(device_t), device_t); void uba_attach(struct uba_softc *, unsigned long); void uba_enqueue(struct uba_unit *); void uba_done(struct uba_softc *); diff --git a/sys/dev/qbus/uda.c b/sys/dev/qbus/uda.c index a96b2b72e51..0e25756e65a 100644 --- a/sys/dev/qbus/uda.c +++ b/sys/dev/qbus/uda.c @@ -1,4 +1,4 @@ -/* $NetBSD: uda.c,v 1.57 2007/10/19 12:01:09 ad Exp $ */ +/* $NetBSD: uda.c,v 1.58 2008/03/11 05:34:02 matt Exp $ */ /* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. @@ -76,7 +76,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uda.c,v 1.57 2007/10/19 12:01:09 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uda.c,v 1.58 2008/03/11 05:34:02 matt Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -101,7 +101,8 @@ __KERNEL_RCSID(0, "$NetBSD: uda.c,v 1.57 2007/10/19 12:01:09 ad Exp $"); * Software status, per controller. */ struct uda_softc { - struct device sc_dev; /* Autoconfig info */ + device_t sc_dev; /* Autoconfig info */ + struct uba_softc *sc_uh; struct evcnt sc_intrcnt; /* Interrupt counting */ struct uba_unit sc_unit; /* Struct common for UBA to communicate */ struct ubinfo sc_ui; @@ -113,20 +114,20 @@ struct uda_softc { int sc_inq; }; -static int udamatch(struct device *, struct cfdata *, void *); -static void udaattach(struct device *, struct device *, void *); -static void udareset(struct device *); +static int udamatch(device_t, cfdata_t, void *); +static void udaattach(device_t, device_t, void *); +static void udareset(device_t ); static void udaintr(void *); static int udaready(struct uba_unit *); -static void udactlrdone(struct device *); +static void udactlrdone(device_t ); static int udaprint(void *, const char *); -static void udasaerror(struct device *, int); -static void udago(struct device *, struct mscp_xi *); +static void udasaerror(device_t, int); +static void udago(device_t, struct mscp_xi *); -CFATTACH_DECL(mtc, sizeof(struct uda_softc), +CFATTACH_DECL_NEW(mtc, sizeof(struct uda_softc), udamatch, udaattach, NULL, NULL); -CFATTACH_DECL(uda, sizeof(struct uda_softc), +CFATTACH_DECL_NEW(uda, sizeof(struct uda_softc), udamatch, udaattach, NULL, NULL); /* @@ -150,15 +151,14 @@ udaprint(void *aux, const char *name) * Poke at a supposed UDA50 to see if it is there. */ int -udamatch(struct device *parent, struct cfdata *cf, void *aux) +udamatch(device_t parent, cfdata_t cf, void *aux) { struct uba_attach_args *ua = aux; + struct uba_softc *uh = device_private(parent); struct mscp_softc mi; /* Nice hack */ - struct uba_softc *ubasc; int tries; /* Get an interrupt vector. */ - ubasc = (void *)parent; mi.mi_iot = ua->ua_iot; mi.mi_iph = ua->ua_ioh; @@ -182,7 +182,7 @@ again: bus_space_write_2(mi.mi_iot, mi.mi_sah, 0, MP_ERR | (NCMDL2 << 11) | (NRSPL2 << 8) | MP_IE | - ((ubasc->uh_lastiv - 4) >> 2)); + ((uh->uh_lastiv - 4) >> 2)); if (mscp_waitstep(&mi, MP_STEP2, MP_STEP2) == 0) { printf("udaprobe: init step2 no change. sa=%x\n", @@ -199,23 +199,25 @@ bad: } void -udaattach(struct device *parent, struct device *self, void *aux) +udaattach(device_t parent, device_t self, void *aux) { struct uda_softc *sc = device_private(self); struct uba_attach_args *ua = aux; - struct uba_softc *uh = (void *)parent; struct mscp_attach_args ma; int error; printf("\n"); - uh->uh_lastiv -= 4; /* remove dynamic interrupt vector */ + sc->sc_dev = self; + sc->sc_uh = device_private(parent); + + sc->sc_uh->uh_lastiv -= 4; /* remove dynamic interrupt vector */ uba_intr_establish(ua->ua_icookie, ua->ua_cvec, udaintr, sc, &sc->sc_intrcnt); - uba_reset_establish(udareset, &sc->sc_dev); + uba_reset_establish(udareset, sc->sc_dev); evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt, - sc->sc_dev.dv_xname, "intr"); + device_xname(sc->sc_dev), "intr"); sc->sc_iot = ua->ua_iot; sc->sc_iph = ua->ua_ioh; @@ -225,7 +227,7 @@ udaattach(struct device *parent, struct device *self, void *aux) /* * Fill in the uba_unit struct, so we can communicate with the uba. */ - sc->sc_unit.uu_softc = sc; /* Backpointer to softc */ + sc->sc_unit.uu_dev = self; /* Backpointer to softc */ sc->sc_unit.uu_ready = udaready;/* go routine called from adapter */ sc->sc_unit.uu_keepbdp = vax_cputype == VAX_750 ? 1 : 0; @@ -234,7 +236,7 @@ udaattach(struct device *parent, struct device *self, void *aux) * response packets into Unibus space. */ sc->sc_ui.ui_size = sizeof(struct mscp_pack); - if ((error = ubmemalloc((void *)parent, &sc->sc_ui, UBA_CANTWAIT))) + if ((error = ubmemalloc(sc->sc_uh, &sc->sc_ui, UBA_CANTWAIT))) return printf("ubmemalloc failed: %d\n", error); bzero(sc->sc_ui.ui_vaddr, sizeof (struct mscp_pack)); @@ -257,10 +259,10 @@ udaattach(struct device *parent, struct device *self, void *aux) ma.ma_swh = sc->sc_sah; ma.ma_dmat = sc->sc_dmat; ma.ma_dmam = sc->sc_ui.ui_dmam; - ma.ma_ivec = uh->uh_lastiv; + ma.ma_ivec = sc->sc_uh->uh_lastiv; ma.ma_ctlrnr = (ua->ua_iaddr == 0172150 ? 0 : 1); /* XXX */ - ma.ma_adapnr = uh->uh_nr; - config_found(&sc->sc_dev, &ma, udaprint); + ma.ma_adapnr = sc->sc_uh->uh_nr; + config_found(sc->sc_dev, &ma, udaprint); } /* @@ -269,9 +271,9 @@ udaattach(struct device *parent, struct device *self, void *aux) * Called from mscp routines. */ void -udago(struct device *usc, struct mscp_xi *mxi) +udago(device_t dv, struct mscp_xi *mxi) { - struct uda_softc *sc = (void *)usc; + struct uda_softc *sc = device_private(dv); struct uba_unit *uu; struct buf *bp = mxi->mxi_bp; int err; @@ -289,11 +291,11 @@ udago(struct device *usc, struct mscp_xi *mxi) return; } } - uu = malloc(sizeof(struct uba_unit), M_DEVBUF, M_NOWAIT); - if (uu == 0) + uu = malloc(sizeof(struct uba_unit), M_DEVBUF, M_NOWAIT|M_ZERO); + if (uu == NULL) panic("udago: no mem"); uu->uu_ready = udaready; - uu->uu_softc = sc; + uu->uu_dev = dv; uu->uu_ref = mxi; uba_enqueue(uu); sc->sc_inq++; @@ -308,7 +310,7 @@ udago(struct device *usc, struct mscp_xi *mxi) int udaready(struct uba_unit *uu) { - struct uda_softc *sc = uu->uu_softc; + struct uda_softc *sc = device_private(uu->uu_dev); struct mscp_xi *mxi = uu->uu_ref; struct buf *bp = mxi->mxi_bp; int err; @@ -325,7 +327,7 @@ udaready(struct uba_unit *uu) return 1; } -static struct saerr { +static const struct saerr { int code; /* error code (including UDA_ERR) */ const char *desc; /* what it means: Efoo => foo error */ } saerr[] = { @@ -375,20 +377,19 @@ static struct saerr { * then (optionally) reset the controller and requeue pending transfers. */ void -udasaerror(struct device *usc, int doreset) +udasaerror(device_t dev, int doreset) { - struct uda_softc *sc = (void *)usc; + struct uda_softc *sc = device_private(dev); int code = bus_space_read_2(sc->sc_iot, sc->sc_sah, 0); - struct saerr *e; + const struct saerr *e; if ((code & MP_ERR) == 0) return; for (e = saerr; e->code; e++) if (e->code == code) break; - printf("%s: controller error, sa=0%o (%s%s)\n", - sc->sc_dev.dv_xname, code, e->desc + 1, - *e->desc == 'E' ? " error" : ""); + aprint_error_dev(sc->sc_dev, "controller error, sa=0%o (%s%s)\n", + code, e->desc + 1, *e->desc == 'E' ? " error" : ""); #if 0 /* XXX we just avoid panic when autoconfig non-existent KFQSA devices */ if (doreset) { mscp_requeue(sc->sc_softc); @@ -406,22 +407,21 @@ static void udaintr(void *arg) { struct uda_softc *sc = arg; - struct uba_softc *uh; /* ctlr fatal error */ if (bus_space_read_2(sc->sc_iot, sc->sc_sah, 0) & MP_ERR) { - udasaerror(&sc->sc_dev, 1); + udasaerror(sc->sc_dev, 1); return; } /* * Handle buffer purge requests. * XXX - should be done in bus_dma_sync(). */ - uh = (void *)device_parent(&sc->sc_dev); #ifdef notyet if (ud->mp_ca.ca_bdp) { - if (uh->uh_ubapurge) - (*uh->uh_ubapurge)(uh, ud->mp_ca.ca_bdp); + if (sc->sc_uh->uh_ubapurge) + (*sc->sc_uh->uh_ubapurge)(sc->sc_uh, + ud->mp_ca.ca_bdp); /* signal purge complete */ bus_space_write_2(sc->sc_iot, sc->sc_sah, 0, 0); } @@ -435,9 +435,9 @@ udaintr(void *arg) * on that Unibus, and requeue outstanding I/O. */ static void -udareset(struct device *dev) +udareset(device_t dev) { - struct uda_softc *sc = (void *)dev; + struct uda_softc *sc = device_private(dev); /* * Our BDP (if any) is gone; our command (if any) is * flushed; the device is no longer mapped; and the @@ -462,12 +462,12 @@ udareset(struct device *dev) } void -udactlrdone(struct device *usc) +udactlrdone(device_t dev) { - struct uda_softc *sc = (void *)usc; + struct uda_softc *sc = device_private(dev); int s; s = spluba(); - uba_done((struct uba_softc *)device_parent(&sc->sc_dev)); + uba_done(sc->sc_uh); splx(s); } diff --git a/sys/dev/xmi/bi_xmi.c b/sys/dev/xmi/bi_xmi.c index ec1792f9983..e48991ec3b1 100644 --- a/sys/dev/xmi/bi_xmi.c +++ b/sys/dev/xmi/bi_xmi.c @@ -1,4 +1,4 @@ -/* $NetBSD: bi_xmi.c,v 1.6 2007/10/19 12:01:24 ad Exp $ */ +/* $NetBSD: bi_xmi.c,v 1.7 2008/03/11 05:34:02 matt Exp $ */ /* * Copyright (c) 2000 Ludd, University of Lule}, Sweden. All rights reserved. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bi_xmi.c,v 1.6 2007/10/19 12:01:24 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bi_xmi.c,v 1.7 2008/03/11 05:34:02 matt Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -69,12 +69,13 @@ bi_xmi_match(struct device *parent, struct cfdata *cf, void *aux) static void bi_xmi_attach(struct device *parent, struct device *self, void *aux) { - struct bi_softc *sc = (void *)self; + struct bi_softc *sc = device_private(self); struct xmi_attach_args *xa = aux; /* * Fill in bus specific data. */ + sc->sc_dev = self; sc->sc_addr = (bus_addr_t)BI_BASE(xa->xa_nodenr, 0); sc->sc_iot = xa->xa_iot; /* No special I/O handling */ sc->sc_dmat = xa->xa_dmat; /* No special DMA handling either */ @@ -83,5 +84,5 @@ bi_xmi_attach(struct device *parent, struct device *self, void *aux) bi_attach(sc); } -CFATTACH_DECL(bi_xmi, sizeof(struct bi_softc), +CFATTACH_DECL_NEW(bi_xmi, sizeof(struct bi_softc), bi_xmi_match, bi_xmi_attach, NULL, NULL); diff --git a/sys/dev/xmi/files.xmi b/sys/dev/xmi/files.xmi index 603504820f3..89166865e14 100644 --- a/sys/dev/xmi/files.xmi +++ b/sys/dev/xmi/files.xmi @@ -1,10 +1,10 @@ -# $NetBSD: files.xmi,v 1.1 2000/06/15 19:01:33 ragge Exp $ +# $NetBSD: files.xmi,v 1.2 2008/03/11 05:34:02 matt Exp $ # # Config file and device description for machine-independent # code for devices Digital Equipment Corp. XMI bus. # Included by ports that need it. -device xmi { node=-1 } +device xmi { node=-1 }: bus file dev/xmi/xmi.c xmi diff --git a/sys/dev/xmi/xmi.c b/sys/dev/xmi/xmi.c index 8bcecdc0b5a..962cc2e49b0 100644 --- a/sys/dev/xmi/xmi.c +++ b/sys/dev/xmi/xmi.c @@ -1,4 +1,4 @@ -/* $NetBSD: xmi.c,v 1.9 2007/10/19 12:01:24 ad Exp $ */ +/* $NetBSD: xmi.c,v 1.10 2008/03/11 05:34:02 matt Exp $ */ /* * Copyright (c) 2000 Ludd, University of Lule}, Sweden. All rights reserved. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: xmi.c,v 1.9 2007/10/19 12:01:24 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xmi.c,v 1.10 2008/03/11 05:34:02 matt Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -51,7 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: xmi.c,v 1.9 2007/10/19 12:01:24 ad Exp $"); static int xmi_print(void *, const char *); -struct xmi_list xmi_list[] = { +const struct xmi_list xmi_list[] = { {XMIDT_KA62, 0, "ka6200"}, {XMIDT_KA64, 1, "ka6400"}, {XMIDT_KA65, 0, "ka6500"}, @@ -64,8 +64,8 @@ struct xmi_list xmi_list[] = { int xmi_print(void *aux, const char *name) { - struct xmi_attach_args *xa = aux; - struct xmi_list *xl; + struct xmi_attach_args * const xa = aux; + const struct xmi_list *xl; for (xl = &xmi_list[0]; xl->xl_nr; xl++) if (xl->xl_nr == bus_space_read_2(xa->xa_iot, xa->xa_ioh, 0)) @@ -91,7 +91,7 @@ xmi_attach(struct xmi_softc *sc) struct xmi_attach_args xa; int nodenr; - printf("\n"); + aprint_normal("\n"); xa.xa_iot = sc->sc_iot; xa.xa_busnr = sc->sc_busnr; @@ -108,8 +108,8 @@ xmi_attach(struct xmi_softc *sc) for (nodenr = 0; nodenr < NNODEXMI; nodenr++) { if (bus_space_map(sc->sc_iot, sc->sc_addr + XMI_NODE(nodenr), PAGE_SIZE, 0, &xa.xa_ioh)) { - printf("xmi_attach: bus_space_map failed, node %d\n", - nodenr); + aprint_error_dev(sc->sc_dev, + "bus_space_map failed, node %d\n", nodenr); return; } if (badaddr((void *)xa.xa_ioh, 4)) { @@ -119,6 +119,6 @@ xmi_attach(struct xmi_softc *sc) xa.xa_nodenr = nodenr; xa.xa_ivec = 256 + lastiv; lastiv += 4; - config_found(&sc->sc_dev, &xa, xmi_print); + config_found(sc->sc_dev, &xa, xmi_print); } } diff --git a/sys/dev/xmi/xmivar.h b/sys/dev/xmi/xmivar.h index 634323f6ec1..817359c4388 100644 --- a/sys/dev/xmi/xmivar.h +++ b/sys/dev/xmi/xmivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: xmivar.h,v 1.1 2000/07/06 17:45:52 ragge Exp $ */ +/* $NetBSD: xmivar.h,v 1.2 2008/03/11 05:34:02 matt Exp $ */ /* * Copyright (c) 2000 Ludd, University of Lule}, Sweden. All rights reserved. @@ -34,7 +34,7 @@ * per-XMI-adapter state. */ struct xmi_softc { - struct device sc_dev; + struct device *sc_dev; bus_space_tag_t sc_iot; /* Space tag for the XMI bus */ bus_dma_tag_t sc_dmat; bus_addr_t sc_addr; /* Address base address for this bus */ @@ -61,9 +61,9 @@ struct xmi_attach_args { * XMI node list. */ struct xmi_list { - u_short xl_nr; /* Unit ID# */ - u_short xl_havedriver; /* Have device driver (informal) */ - char *xl_name; /* DEC name */ + uint16_t xl_nr; /* Unit ID# */ + uint16_t xl_havedriver; /* Have device driver (informal) */ + const char *xl_name; /* DEC name */ }; /* Prototype */ |
