diff options
| author | christos <christos@NetBSD.org> | 1996-03-07 15:00:07 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 1996-03-07 15:00:07 +0000 |
| commit | d318abdbc471c916e89e2f7514dfd50b4b24c4ff (patch) | |
| tree | f8371e2bb7fc2d84f5e9f75134519a1a8ab2b880 /sys/dev/ccd.c | |
| parent | bdc697d9103085fcf1db98dc6ef20cdcfbcce742 (diff) | |
prototypes for ccd audio and ncr5380
Diffstat (limited to 'sys/dev/ccd.c')
| -rw-r--r-- | sys/dev/ccd.c | 98 |
1 files changed, 45 insertions, 53 deletions
diff --git a/sys/dev/ccd.c b/sys/dev/ccd.c index 69662b440a2..355f36a62bd 100644 --- a/sys/dev/ccd.c +++ b/sys/dev/ccd.c @@ -1,4 +1,4 @@ -/* $NetBSD: ccd.c,v 1.28 1996/02/28 01:08:28 thorpej Exp $ */ +/* $NetBSD: ccd.c,v 1.29 1996/03/07 15:00:11 christos Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -99,7 +99,6 @@ #include <sys/buf.h> #include <sys/malloc.h> #include <sys/namei.h> -#include <sys/conf.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/disklabel.h> @@ -108,7 +107,9 @@ #include <sys/syslog.h> #include <sys/fcntl.h> #include <sys/vnode.h> +#include <sys/cpu.h> +#include <dev/dev_conf.h> #include <dev/ccdvar.h> #if defined(CCDDEBUG) && !defined(DEBUG) @@ -144,19 +145,12 @@ struct ccdbuf { #define CCDLABELDEV(dev) \ (MAKEDISKDEV(major((dev)), ccdunit((dev)), RAW_PART)) -/* {b,c}devsw[] function prototypes */ -dev_type_open(ccdopen); -dev_type_close(ccdclose); -dev_type_strategy(ccdstrategy); -dev_type_ioctl(ccdioctl); -dev_type_read(ccdread); -dev_type_write(ccdwrite); - /* called by main() at boot time */ void ccdattach __P((int)); /* called by biodone() at interrupt time */ -void ccdiodone __P((struct ccdbuf *cbp)); +void ccdiodone __P((struct buf *)); +int ccdsize __P((dev_t)); static void ccdstart __P((struct ccd_softc *, struct buf *)); static void ccdinterleave __P((struct ccd_softc *, int)); @@ -187,8 +181,6 @@ void ccdattach(num) int num; { - int i; - if (num <= 0) { #ifdef DIAGNOSTIC panic("ccdattach: count <= 0"); @@ -220,7 +212,7 @@ ccdinit(ccd, cpaths, p) struct proc *p; { register struct ccd_softc *cs = &ccd_softc[ccd->ccd_unit]; - register struct ccdcinfo *ci; + register struct ccdcinfo *ci = NULL; register size_t size; register int ix; struct vnode *vp; @@ -261,8 +253,9 @@ ccdinit(ccd, cpaths, p) * Copy in the pathname of the component. */ bzero(tmppath, sizeof(tmppath)); /* sanity */ - if (error = copyinstr(cpaths[ix], tmppath, - MAXPATHLEN, &ci->ci_pathlen)) { + error = copyinstr(cpaths[ix], tmppath, + MAXPATHLEN, &ci->ci_pathlen); + if (error) { #ifdef DEBUG if (ccddebug & (CCDB_FOLLOW|CCDB_INIT)) printf("%s: can't copy path, error = %d\n", @@ -277,7 +270,7 @@ ccdinit(ccd, cpaths, p) /* * XXX: Cache the component's dev_t. */ - if (error = VOP_GETATTR(vp, &va, p->p_ucred, p)) { + if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)) != 0) { #ifdef DEBUG if (ccddebug & (CCDB_FOLLOW|CCDB_INIT)) printf("%s: %s: getattr failed %s = %d\n", @@ -293,8 +286,9 @@ ccdinit(ccd, cpaths, p) /* * Get partition information for the component. */ - if (error = VOP_IOCTL(vp, DIOCGPART, (caddr_t)&dpart, - FREAD, p->p_ucred, p)) { + error = VOP_IOCTL(vp, DIOCGPART, (caddr_t)&dpart, + FREAD, p->p_ucred, p); + if (error) { #ifdef DEBUG if (ccddebug & (CCDB_FOLLOW|CCDB_INIT)) printf("%s: %s: ioctl failed, error = %d\n", @@ -324,9 +318,6 @@ ccdinit(ccd, cpaths, p) * Calculate the size, truncating to an interleave * boundary if necessary. */ - if (size < 0) - size = 0; - if (cs->sc_ileave > 1) size -= size % cs->sc_ileave; @@ -440,7 +431,7 @@ ccdinterleave(cs, unit) #ifdef DEBUG if (ccddebug & CCDB_INIT) - printf("ccdinterleave(%x): ileave %d\n", cs, cs->sc_ileave); + printf("ccdinterleave(%p): ileave %d\n", cs, cs->sc_ileave); #endif /* * Allocate an interleave table. @@ -551,7 +542,7 @@ ccdopen(dev, flags, fmt, p) return (ENXIO); cs = &ccd_softc[unit]; - if (error = ccdlock(cs)) + if ((error = ccdlock(cs)) != 0) return (error); lp = cs->sc_dkdev.dk_label; @@ -615,7 +606,7 @@ ccdclose(dev, flags, fmt, p) return (ENXIO); cs = &ccd_softc[unit]; - if (error = ccdlock(cs)) + if ((error = ccdlock(cs)) != 0) return (error); part = DISKPART(dev); @@ -643,14 +634,13 @@ ccdstrategy(bp) { register int unit = ccdunit(bp->b_dev); register struct ccd_softc *cs = &ccd_softc[unit]; - register daddr_t bn; - register int sz, s; + register int s; int wlabel; struct disklabel *lp; #ifdef DEBUG if (ccddebug & CCDB_FOLLOW) - printf("ccdstrategy(%x): unit %d\n", bp, unit); + printf("ccdstrategy(%p): unit %d\n", bp, unit); #endif if ((cs->sc_flags & CCDF_INITED) == 0) { bp->b_error = ENXIO; @@ -699,7 +689,7 @@ ccdstart(cs, bp) #ifdef DEBUG if (ccddebug & CCDB_FOLLOW) - printf("ccdstart(%x, %x)\n", cs, bp); + printf("ccdstart(%p, %p)\n", cs, bp); #endif /* Instrumentation. */ @@ -751,13 +741,13 @@ ccdbuffer(cs, bp, bn, addr, bcount, cbpp) long bcount; struct ccdbuf **cbpp; { - register struct ccdcinfo *ci, *ci2; + register struct ccdcinfo *ci, *ci2 = NULL; register struct ccdbuf *cbp; register daddr_t cbn, cboff; #ifdef DEBUG if (ccddebug & CCDB_IO) - printf("ccdbuffer(%x, %x, %d, %x, %d)\n", + printf("ccdbuffer(%p, %p, %d, %p, %d)\n", cs, bp, bn, addr, bcount); #endif /* @@ -819,7 +809,7 @@ ccdbuffer(cs, bp, bn, addr, bcount, cbpp) cbp = getccdbuf(); cbp->cb_flags = 0; cbp->cb_buf.b_flags = bp->b_flags | B_CALL; - cbp->cb_buf.b_iodone = (void (*)())ccdiodone; + cbp->cb_buf.b_iodone = ccdiodone; cbp->cb_buf.b_proc = bp->b_proc; cbp->cb_buf.b_dev = ci->ci_dev; /* XXX */ cbp->cb_buf.b_blkno = cbn + cboff; @@ -844,7 +834,7 @@ ccdbuffer(cs, bp, bn, addr, bcount, cbpp) #ifdef DEBUG if (ccddebug & CCDB_IO) - printf(" dev %x(u%d): cbp %x bn %d addr %x bcnt %d\n", + printf(" dev %x(u%d): cbp %p bn %d addr %p bcnt %d\n", ci->ci_dev, ci-cs->sc_cinfo, cbp, cbp->cb_buf.b_blkno, cbp->cb_buf.b_data, cbp->cb_buf.b_bcount); #endif @@ -873,7 +863,7 @@ ccdintr(cs, bp) #ifdef DEBUG if (ccddebug & CCDB_FOLLOW) - printf("ccdintr(%x, %x)\n", cs, bp); + printf("ccdintr(%p, %p)\n", cs, bp); #endif /* * Request is done for better or worse, wakeup the top half. @@ -890,9 +880,10 @@ ccdintr(cs, bp) * take a ccd interrupt. */ void -ccdiodone(cbp) - struct ccdbuf *cbp; +ccdiodone(vbp) + struct buf *vbp; { + struct ccdbuf *cbp = (struct ccdbuf *) vbp; register struct buf *bp = cbp->cb_obp; register int unit = cbp->cb_unit; struct ccd_softc *cs = &ccd_softc[unit]; @@ -902,14 +893,14 @@ ccdiodone(cbp) s = splbio(); #ifdef DEBUG if (ccddebug & CCDB_FOLLOW) - printf("ccdiodone(%x)\n", cbp); + printf("ccdiodone(%p)\n", cbp); if (ccddebug & CCDB_IO) { if (cbp->cb_flags & CBF_MIRROR) printf("ccdiodone: mirror component\n"); else - printf("ccdiodone: bp %x bcount %d resid %d\n", + printf("ccdiodone: bp %p bcount %d resid %d\n", bp, bp->b_bcount, bp->b_resid); - printf(" dev %x(u%d), cbp %x bn %d addr %x bcnt %d\n", + printf(" dev %x(u%d), cbp %p bn %d addr %p bcnt %d\n", cbp->cb_buf.b_dev, cbp->cb_comp, cbp, cbp->cb_buf.b_blkno, cbp->cb_buf.b_data, cbp->cb_buf.b_bcount); @@ -961,7 +952,7 @@ ccdread(dev, uio, flags) #ifdef DEBUG if (ccddebug & CCDB_FOLLOW) - printf("ccdread(%x, %x)\n", dev, uio); + printf("ccdread(%x, %p)\n", dev, uio); #endif if (unit >= numccd) return (ENXIO); @@ -990,7 +981,7 @@ ccdwrite(dev, uio, flags) #ifdef DEBUG if (ccddebug & CCDB_FOLLOW) - printf("ccdwrite(%x, %x)\n", dev, uio); + printf("ccdwrite(%x, %p)\n", dev, uio); #endif if (unit >= numccd) return (ENXIO); @@ -1038,7 +1029,7 @@ ccdioctl(dev, cmd, data, flag, p) if ((flag & FWRITE) == 0) return (EBADF); - if (error = ccdlock(cs)) + if ((error = ccdlock(cs)) != 0) return (error); /* Fill in some important bits. */ @@ -1067,7 +1058,7 @@ ccdioctl(dev, cmd, data, flag, p) #ifdef DEBUG if (ccddebug & CCDB_INIT) for (i = 0; i < ccio->ccio_ndisks; ++i) - printf("ccdioctl: component %d: 0x%x\n", + printf("ccdioctl: component %d: 0x%p\n", i, cpp[i]); #endif @@ -1076,7 +1067,7 @@ ccdioctl(dev, cmd, data, flag, p) if (ccddebug & CCDB_INIT) printf("ccdioctl: lookedup = %d\n", lookedup); #endif - if (error = ccdlookup(cpp[i], p, &vpp[i])) { + if ((error = ccdlookup(cpp[i], p, &vpp[i])) != 0) { for (j = 0; j < lookedup; ++j) (void)vn_close(vpp[j], FREAD|FWRITE, p->p_ucred, p); @@ -1094,7 +1085,7 @@ ccdioctl(dev, cmd, data, flag, p) /* * Initialize the ccd. Fills in the softc for us. */ - if (error = ccdinit(&ccd, cpp, p)) { + if ((error = ccdinit(&ccd, cpp, p)) != 0) { for (j = 0; j < lookedup; ++j) (void)vn_close(vpp[j], FREAD|FWRITE, p->p_ucred, p); @@ -1134,7 +1125,7 @@ ccdioctl(dev, cmd, data, flag, p) if ((flag & FWRITE) == 0) return (EBADF); - if (error = ccdlock(cs)) + if ((error = ccdlock(cs)) != 0) return (error); /* @@ -1223,7 +1214,7 @@ ccdioctl(dev, cmd, data, flag, p) if ((flag & FWRITE) == 0) return (EBADF); - if (error = ccdlock(cs)) + if ((error = ccdlock(cs)) != 0) return (error); cs->sc_flags |= CCDF_LABELLING; @@ -1320,9 +1311,9 @@ ccdlookup(path, p, vpp) int error; NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, path, p); - if (error = vn_open(&nd, FREAD|FWRITE, 0)) { + if ((error = vn_open(&nd, FREAD|FWRITE, 0)) != 0) { #ifdef DEBUG - if (ccddebug & CCDB_FOLLOW|CCDB_INIT) + if (ccddebug & (CCDB_FOLLOW|CCDB_INIT)) printf("ccdlookup: vn_open error = %d\n", error); #endif return (error); @@ -1335,9 +1326,9 @@ ccdlookup(path, p, vpp) return (EBUSY); } - if (error = VOP_GETATTR(vp, &va, p->p_ucred, p)) { + if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)) != 0) { #ifdef DEBUG - if (ccddebug & CCDB_FOLLOW|CCDB_INIT) + if (ccddebug & (CCDB_FOLLOW|CCDB_INIT)) printf("ccdlookup: getattr error = %d\n", error); #endif VOP_UNLOCK(vp); @@ -1406,8 +1397,9 @@ ccdgetdisklabel(dev) /* * Call the generic disklabel extraction routine. */ - if (errstring = readdisklabel(CCDLABELDEV(dev), ccdstrategy, - cs->sc_dkdev.dk_label, cs->sc_dkdev.dk_cpulabel)) + errstring = readdisklabel(CCDLABELDEV(dev), ccdstrategy, + cs->sc_dkdev.dk_label, cs->sc_dkdev.dk_cpulabel); + if (errstring) ccdmakedisklabel(cs); #ifdef DEBUG |
