From 708f88d69f9f2770d5e57af0d084cc9ed998685e Mon Sep 17 00:00:00 2001 From: cegger Date: Thu, 12 Jun 2008 23:06:14 +0000 Subject: [PATCH] use device_lookup_private to get softc --- sys/dev/qbus/qd.c | 34 +++++++++++++--------------------- sys/dev/sbus/agten.c | 18 ++++++++++-------- sys/dev/scsipi/cd.c | 6 +++--- sys/dev/sequencer.c | 6 +++--- 4 files changed, 29 insertions(+), 35 deletions(-) diff --git a/sys/dev/qbus/qd.c b/sys/dev/qbus/qd.c index f95a2d2dd65a..b57895cdbfff 100644 --- a/sys/dev/qbus/qd.c +++ b/sys/dev/qbus/qd.c @@ -1,4 +1,4 @@ -/* $NetBSD: qd.c,v 1.43 2008/03/11 05:34:01 matt Exp $ */ +/* $NetBSD: qd.c,v 1.44 2008/06/12 23:06:14 cegger Exp $ */ /*- * Copyright (c) 1988 Regents of the University of California. @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: qd.c,v 1.43 2008/03/11 05:34:01 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: qd.c,v 1.44 2008/06/12 23:06:14 cegger Exp $"); #include "opt_ddb.h" @@ -792,14 +792,12 @@ void qd_attach(parent, self, aux) /*ARGSUSED*/ int -qdopen(dev, flag, mode, p) - dev_t dev; - int flag, mode; - struct proc *p; +qdopen(dev_t dev, int flag, int mode, struct proc *p) { volatile struct dga *dga; /* ptr to gate array struct */ struct tty *tp; volatile struct duart *duart; + struct uba_softc *sc; int unit; int minor_dev; @@ -809,8 +807,9 @@ qdopen(dev, flag, mode, p) /* * check for illegal conditions */ - if (unit >= qd_cd.cd_ndevs || qd_cd.cd_devs[unit] == NULL) - return (ENXIO); /* no such device or address */ + sc = device_lookup_private(&qd_cd, unit); + if (sc == NULL) + return ENXIO; duart = (struct duart *) qdmap[unit].duart; dga = (struct dga *) qdmap[unit].dga; @@ -878,10 +877,7 @@ qdopen(dev, flag, mode, p) /*ARGSUSED*/ int -qdclose(dev, flag, mode, p) - dev_t dev; - int flag, mode; - struct proc *p; +qdclose(dev_t dev, int flag, int mode, struct proc *p) { struct tty *tp; struct qdmap *qd; @@ -899,8 +895,7 @@ qdclose(dev, flag, mode, p) unit = minor_dev >> 2; /* get QDSS number */ qd = &qdmap[unit]; - uh = (struct uba_softc *) - device_parent((device_t )(qd_cd.cd_devs[unit])); + uh = device_private(device_parent(device_lookup(&qd_cd, unit))); if ((minor_dev & 0x03) == 2) { @@ -1102,8 +1097,7 @@ qdioctl(dev, cmd, datap, flags, p) short *temp; /* a pointer to template RAM */ struct uba_softc *uh; - uh = (struct uba_softc *) - device_parent((device_t )(qd_cd.cd_devs[unit])); + uh = device_private(device_parent(device_lookup(&qd_cd, unit))); /* * service graphic device ioctl commands @@ -1718,8 +1712,7 @@ qd_strategy(bp) unit = (minor(bp->b_dev) >> 2) & 0x07; - uh = (struct uba_softc *) - device_parent((device_t )(qd_cd.cd_devs[unit])); + uh = device_private(device_parent(device_lookup(&qd_cd, unit))); /* * init pointers @@ -2313,8 +2306,7 @@ qdaint(arg) */ static void -qdiint(arg) - void *arg; +qdiint(void *arg) { device_t dv = arg; struct _vs_event *event; @@ -2785,7 +2777,7 @@ GET_TBUTTON: if (qdpolling) return; - if (unit >= qd_cd.cd_ndevs || qd_cd.cd_devs[unit] == NULL) + if (unit >= qd_cd.cd_ndevs || device_lookup(&qd_cd, unit) == NULL) return; /* no such device or address */ tp = qd_tty[unit << 2]; diff --git a/sys/dev/sbus/agten.c b/sys/dev/sbus/agten.c index 176f6254f871..a4738032707a 100644 --- a/sys/dev/sbus/agten.c +++ b/sys/dev/sbus/agten.c @@ -1,4 +1,4 @@ -/* $NetBSD: agten.c,v 1.14 2008/05/17 17:55:50 macallan Exp $ */ +/* $NetBSD: agten.c,v 1.15 2008/06/12 23:06:14 cegger Exp $ */ /*- * Copyright (c) 2007 Michael Lorenz @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: agten.c,v 1.14 2008/05/17 17:55:50 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: agten.c,v 1.15 2008/06/12 23:06:14 cegger Exp $"); /* * a driver for the Fujitsu AG-10e SBus framebuffer @@ -914,10 +914,10 @@ agten_fb_unblank(device_t dev) static int agten_fb_open(dev_t dev, int flags, int mode, struct lwp *l) { - struct agten_softc *sc = device_private(agten_cd.cd_devs[minor(dev)]); - int unit = minor(dev); + struct agten_softc *sc; - if (unit >= agten_cd.cd_ndevs || agten_cd.cd_devs[unit] == NULL) + sc = device_lookup_private(&agten_cd, minor(dev)); + if (sc == NULL) return (ENXIO); if (sc->sc_fb_is_open) return 0; @@ -931,7 +931,9 @@ agten_fb_open(dev_t dev, int flags, int mode, struct lwp *l) static int agten_fb_close(dev_t dev, int flags, int mode, struct lwp *l) { - struct agten_softc *sc = device_private(agten_cd.cd_devs[minor(dev)]); + struct agten_softc *sc; + + sc = device_lookup_private(&agten_cd, minor(dev)); sc->sc_fb_is_open--; if (sc->sc_fb_is_open < 0) @@ -948,7 +950,7 @@ agten_fb_close(dev_t dev, int flags, int mode, struct lwp *l) static int agten_fb_ioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l) { - struct agten_softc *sc = device_private(agten_cd.cd_devs[minor(dev)]); + struct agten_softc *sc = device_lookup_private(&agten_cd, minor(dev)); struct fbgattr *fba; int error; @@ -1043,7 +1045,7 @@ agten_fb_ioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l) static paddr_t agten_fb_mmap(dev_t dev, off_t off, int prot) { - struct agten_softc *sc = device_private(agten_cd.cd_devs[minor(dev)]); + struct agten_softc *sc = device_lookup_private(&agten_cd, minor(dev)); /* * mappings are subject to change diff --git a/sys/dev/scsipi/cd.c b/sys/dev/scsipi/cd.c index 99502f32baea..0cac3f867ba6 100644 --- a/sys/dev/scsipi/cd.c +++ b/sys/dev/scsipi/cd.c @@ -1,4 +1,4 @@ -/* $NetBSD: cd.c,v 1.281 2008/05/12 21:39:56 jnemeth Exp $ */ +/* $NetBSD: cd.c,v 1.282 2008/06/12 23:06:14 cegger Exp $ */ /*- * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation, @@ -50,7 +50,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.281 2008/05/12 21:39:56 jnemeth Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.282 2008/06/12 23:06:14 cegger Exp $"); #include "rnd.h" @@ -934,7 +934,7 @@ cdbounce(struct buf *bp) struct cdbounce *bounce = (struct cdbounce *)bp->b_private; struct buf *obp = bounce->obp; struct cd_softc *cd = - device_private(cd_cd.cd_devs[CDUNIT(obp->b_dev)]); + device_lookup_private(&cd_cd, CDUNIT(obp->b_dev)); struct disklabel *lp = cd->sc_dk.dk_label; if (bp->b_error != 0) { diff --git a/sys/dev/sequencer.c b/sys/dev/sequencer.c index 755c430535bf..4738681a08b9 100644 --- a/sys/dev/sequencer.c +++ b/sys/dev/sequencer.c @@ -1,4 +1,4 @@ -/* $NetBSD: sequencer.c,v 1.48 2008/04/28 20:23:47 martin Exp $ */ +/* $NetBSD: sequencer.c,v 1.49 2008/06/12 23:06:14 cegger Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sequencer.c,v 1.48 2008/04/28 20:23:47 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sequencer.c,v 1.49 2008/06/12 23:06:14 cegger Exp $"); #include "sequencer.h" @@ -1182,7 +1182,7 @@ midiseq_open(int unit, int flags) error = cdev_open(dev, flags, 0, 0); if (error) return (0); - sc = device_private(midi_cd.cd_devs[unit]); + sc = device_lookup_private(&midi_cd, unit); sc->seqopen = 1; md = malloc(sizeof *md, M_DEVBUF, M_WAITOK|M_ZERO); sc->seq_md = md;