- use device_lookup_private to get softc

- ansify
This commit is contained in:
cegger 2008-06-11 18:46:24 +00:00
parent 96a9f67868
commit 3e484e6172
4 changed files with 52 additions and 115 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ct.c,v 1.15 2008/04/28 20:23:48 martin Exp $ */
/* $NetBSD: ct.c,v 1.16 2008/06/11 18:46:24 cegger Exp $ */
/*-
* Copyright (c) 1996-2003 The NetBSD Foundation, Inc.
@ -121,7 +121,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ct.c,v 1.15 2008/04/28 20:23:48 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: ct.c,v 1.16 2008/06/11 18:46:24 cegger Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -372,15 +372,12 @@ ctattach(parent, self, aux)
/*ARGSUSED*/
int
ctopen(dev, flag, type, l)
dev_t dev;
int flag, type;
struct lwp *l;
ctopen(dev_t dev, int flag, int type, struct lwp *l)
{
struct ct_softc *sc;
u_int8_t opt;
sc = device_lookup(&ct_cd, CTUNIT(dev));
sc = device_lookup_private(&ct_cd, CTUNIT(dev));
if (sc == NULL || (sc->sc_flags & CTF_ALIVE) == 0)
return (ENXIO);
@ -404,14 +401,11 @@ ctopen(dev, flag, type, l)
/*ARGSUSED*/
int
ctclose(dev, flag, fmt, l)
dev_t dev;
int flag, fmt;
struct lwp *l;
ctclose(dev_t dev, int flag, int fmt, struct lwp *l)
{
struct ct_softc *sc;
sc = device_lookup(&ct_cd, CTUNIT(dev));
sc = device_lookup_private(&ct_cd, CTUNIT(dev));
if (sc == NULL)
return (ENXIO);
@ -438,16 +432,13 @@ ctclose(dev, flag, fmt, l)
}
void
ctcommand(dev, cmd, cnt)
dev_t dev;
int cmd;
int cnt;
ctcommand(dev_t dev, int cmd, int cnt)
{
struct ct_softc *sc;
struct buf *bp;
struct buf *nbp = 0;
sc = device_lookup(&ct_cd, CTUNIT(dev));
sc = device_lookup_private(&ct_cd, CTUNIT(dev));
bp = &sc->sc_bufstore;
DPRINTF(CDB_FOLLOW, ("ctcommand: called\n"));
@ -497,8 +488,7 @@ ctcommand(dev, cmd, cnt)
}
void
ctstrategy(bp)
struct buf *bp;
ctstrategy(struct buf *bp)
{
struct ct_softc *sc;
int s;
@ -507,7 +497,7 @@ ctstrategy(bp)
bp, bp->b_dev, bp->b_blkno, bp->b_bcount,
(bp->b_flags & B_READ) ? 'R' : 'W'));
sc = device_lookup(&ct_cd, CTUNIT(bp->b_dev));
sc = device_lookup_private(&ct_cd, CTUNIT(bp->b_dev));
s = splbio();
BUFQ_PUT(sc->sc_tab, bp);

View File

@ -1,4 +1,4 @@
/* $NetBSD: gpib.c,v 1.12 2008/04/28 20:23:48 martin Exp $ */
/* $NetBSD: gpib.c,v 1.13 2008/06/11 18:46:24 cegger Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: gpib.c,v 1.12 2008/04/28 20:23:48 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: gpib.c,v 1.13 2008/06/11 18:46:24 cegger Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -518,14 +518,11 @@ recverror:
*/
int
gpibopen(dev, flags, mode, l)
dev_t dev;
int flags, mode;
struct lwp *l;
gpibopen(dev_t dev, int flags, int mode, struct lwp *l)
{
struct gpib_softc *sc;
sc = device_lookup(&gpib_cd, GPIBUNIT(dev));
sc = device_lookup_private(&gpib_cd, GPIBUNIT(dev));
if (sc == NULL)
return (ENXIO);
@ -539,14 +536,11 @@ gpibopen(dev, flags, mode, l)
}
int
gpibclose(dev, flag, mode, l)
dev_t dev;
int flag, mode;
struct lwp *l;
gpibclose(dev_t dev, int flag, int mode, struct lwp *l)
{
struct gpib_softc *sc;
sc = device_lookup(&gpib_cd, GPIBUNIT(dev));
sc = device_lookup_private(&gpib_cd, GPIBUNIT(dev));
if (sc == NULL)
return (ENXIO);
@ -558,14 +552,11 @@ gpibclose(dev, flag, mode, l)
}
int
gpibread(dev, uio, flags)
dev_t dev;
struct uio *uio;
int flags;
gpibread(dev_t dev, struct uio *uio, int flags)
{
struct gpib_softc *sc;
sc = device_lookup(&gpib_cd, GPIBUNIT(dev));
sc = device_lookup_private(&gpib_cd, GPIBUNIT(dev));
if (sc == NULL)
return (ENXIO);
@ -575,14 +566,11 @@ gpibread(dev, uio, flags)
}
int
gpibwrite(dev, uio, flags)
dev_t dev;
struct uio *uio;
int flags;
gpibwrite(dev_t dev, struct uio *uio, int flags)
{
struct gpib_softc *sc;
sc = device_lookup(&gpib_cd, GPIBUNIT(dev));
sc = device_lookup_private(&gpib_cd, GPIBUNIT(dev));
if (sc == NULL)
return (ENXIO);
@ -592,16 +580,11 @@ gpibwrite(dev, uio, flags)
}
int
gpibioctl(dev, cmd, data, flag, l)
dev_t dev;
u_long cmd;
void *data;
int flag;
struct lwp *l;
gpibioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
{
struct gpib_softc *sc;
sc = device_lookup(&gpib_cd, GPIBUNIT(dev));
sc = device_lookup_private(&gpib_cd, GPIBUNIT(dev));
if (sc == NULL)
return (ENXIO);
@ -618,14 +601,11 @@ gpibioctl(dev, cmd, data, flag, l)
}
int
gpibpoll(dev, events, l)
dev_t dev;
int events;
struct lwp *l;
gpibpoll(dev_t dev, int events, struct lwp *l)
{
struct gpib_softc *sc;
sc = device_lookup(&gpib_cd, GPIBUNIT(dev));
sc = device_lookup_private(&gpib_cd, GPIBUNIT(dev));
if (sc == NULL)
return (ENXIO);

View File

@ -1,4 +1,4 @@
/* $NetBSD: mt.c,v 1.14 2008/04/28 20:23:48 martin Exp $ */
/* $NetBSD: mt.c,v 1.15 2008/06/11 18:46:24 cegger Exp $ */
/*-
* Copyright (c) 1996-2003 The NetBSD Foundation, Inc.
@ -114,7 +114,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mt.c,v 1.14 2008/04/28 20:23:48 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: mt.c,v 1.15 2008/06/11 18:46:24 cegger Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -367,16 +367,13 @@ getstats:
}
int
mtopen(dev, flag, mode, l)
dev_t dev;
int flag, mode;
struct lwp *l;
mtopen(dev_t dev, int flag, int mode, struct lwp *l)
{
struct mt_softc *sc;
int req_den;
int error;
sc = device_lookup(&mt_cd, MTUNIT(dev));
sc = device_lookup_private(&mt_cd, MTUNIT(dev));
if (sc == NULL || (sc->sc_flags & MTF_EXISTS) == 0)
return (ENXIO);
@ -473,14 +470,11 @@ errout:
}
int
mtclose(dev, flag, fmt, l)
dev_t dev;
int flag, fmt;
struct lwp *l;
mtclose(dev_t dev, int flag, int fmt, struct lwp *l)
{
struct mt_softc *sc;
sc = device_lookup(&mt_cd, MTUNIT(dev));
sc = device_lookup_private(&mt_cd, MTUNIT(dev));
if (sc == NULL)
return (ENXIO);
@ -496,16 +490,13 @@ mtclose(dev, flag, fmt, l)
}
int
mtcommand(dev, cmd, cnt)
dev_t dev;
int cmd;
int cnt;
mtcommand(dev_t dev, int cmd, int cnt)
{
struct mt_softc *sc;
struct buf *bp;
int error = 0;
sc = device_lookup(&mt_cd, MTUNIT(dev));
sc = device_lookup_private(&mt_cd, MTUNIT(dev));
bp = &sc->sc_bufstore;
if (bp->b_cflags & BC_BUSY)
@ -537,13 +528,12 @@ mtcommand(dev, cmd, cnt)
* Only thing to check here is for legal record lengths (writes only).
*/
void
mtstrategy(bp)
struct buf *bp;
mtstrategy(struct buf *bp)
{
struct mt_softc *sc;
int s;
sc = device_lookup(&mt_cd, MTUNIT(bp->b_dev));
sc = device_lookup_private(&mt_cd, MTUNIT(bp->b_dev));
DPRINTF(MDB_ANY, ("%s strategy", device_xname(&sc->sc_dev)));
@ -1010,28 +1000,22 @@ error:
}
int
mtread(dev, uio, flags)
dev_t dev;
struct uio *uio;
int flags;
mtread(dev_t dev, struct uio *uio, int flags)
{
struct mt_softc *sc;
sc = device_lookup(&mt_cd, MTUNIT(dev));
sc = device_lookup_private(&mt_cd, MTUNIT(dev));
return (physio(mtstrategy, &sc->sc_bufstore,
dev, B_READ, minphys, uio));
}
int
mtwrite(dev, uio, flags)
dev_t dev;
struct uio *uio;
int flags;
mtwrite(dev_t dev, struct uio *uio, int flags)
{
struct mt_softc *sc;
sc = device_lookup(&mt_cd, MTUNIT(dev));
sc = device_lookup_private(&mt_cd, MTUNIT(dev));
return (physio(mtstrategy, &sc->sc_bufstore,
dev, B_WRITE, minphys, uio));

View File

@ -1,4 +1,4 @@
/* $NetBSD: rd.c,v 1.20 2008/04/28 20:23:48 martin Exp $ */
/* $NetBSD: rd.c,v 1.21 2008/06/11 18:46:24 cegger Exp $ */
/*-
* Copyright (c) 1996-2003 The NetBSD Foundation, Inc.
@ -111,7 +111,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.20 2008/04/28 20:23:48 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.21 2008/06/11 18:46:24 cegger Exp $");
#include "rnd.h"
@ -502,15 +502,12 @@ rdgetinfo(sc)
}
int
rdopen(dev, flags, mode, l)
dev_t dev;
int flags, mode;
struct lwp *l;
rdopen(dev_t dev, int flags, int mode, struct lwp *l)
{
struct rd_softc *sc;
int error, mask, part;
sc = device_lookup(&rd_cd, RDUNIT(dev));
sc = device_lookup_private(&rd_cd, RDUNIT(dev));
if (sc == NULL || (sc->sc_flags & RDF_ALIVE) ==0)
return (ENXIO);
@ -558,16 +555,13 @@ rdopen(dev, flags, mode, l)
}
int
rdclose(dev, flag, mode, l)
dev_t dev;
int flag, mode;
struct lwp *l;
rdclose(dev_t dev, int flag, int mode, struct lwp *l)
{
struct rd_softc *sc;
struct disk *dk;
int mask, s;
sc = device_lookup(&rd_cd, RDUNIT(dev));
sc = device_lookup_private(&rd_cd, RDUNIT(dev));
if (sc == NULL)
return (ENXIO);
@ -601,8 +595,7 @@ rdclose(dev, flag, mode, l)
}
void
rdstrategy(bp)
struct buf *bp;
rdstrategy(struct buf *bp)
{
struct rd_softc *sc;
struct partition *pinfo;
@ -610,7 +603,7 @@ rdstrategy(bp)
int sz, s;
int offset;
sc = device_lookup(&rd_cd, RDUNIT(bp->b_dev));
sc = device_lookup_private(&rd_cd, RDUNIT(bp->b_dev));
DPRINTF(RDB_FOLLOW,
("rdstrategy(%p): dev %x, bn %" PRId64 ", bcount %ld, %c\n",
@ -1022,18 +1015,13 @@ rdwrite(dev, uio, flags)
}
int
rdioctl(dev, cmd, data, flag, l)
dev_t dev;
u_long cmd;
void *data;
int flag;
struct lwp *l;
rdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
{
struct rd_softc *sc;
struct disklabel *lp;
int error, flags;
sc = device_lookup(&rd_cd, RDUNIT(dev));
sc = device_lookup_private(&rd_cd, RDUNIT(dev));
if (sc == NULL)
return (ENXIO);
lp = sc->sc_dk.dk_label;
@ -1124,13 +1112,12 @@ rdgetdefaultlabel(sc, lp)
}
int
rdsize(dev)
dev_t dev;
rdsize(dev_t dev)
{
struct rd_softc *sc;
int psize, didopen = 0;
sc = device_lookup(&rd_cd, RDUNIT(dev));
sc = device_lookup_private(&rd_cd, RDUNIT(dev));
if (sc == NULL || (sc->sc_flags & RDF_ALIVE) == 0)
return (-1);
@ -1158,11 +1145,7 @@ static int rddoingadump; /* simple mutex */
* Non-interrupt driven, non-dma dump routine.
*/
int
rddump(dev, blkno, va, size)
dev_t dev;
daddr_t blkno;
void *va;
size_t size;
rddump(dev_t dev, daddr_t blkno, void *va, size_t size)
{
struct rd_softc *sc;
int sectorsize; /* size of a disk sector */
@ -1179,7 +1162,7 @@ rddump(dev, blkno, va, size)
return (EFAULT);
rddoingadump = 1;
sc = device_lookup(&rd_cd, RDUNIT(dev));
sc = device_lookup_private(&rd_cd, RDUNIT(dev));
if (sc == NULL || (sc->sc_flags & RDF_ALIVE) == 0)
return (ENXIO);