From 4b77d307471bc8c1eac6d2856702374846fb9a38 Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 6 May 2000 07:01:47 +0000 Subject: Step down a level and issue format requests with a struct bio instead of a struct buf. --- sys/dev/fdc/fdc.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'sys/dev/fdc') diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c index f3d47b4..34acddb 100644 --- a/sys/dev/fdc/fdc.c +++ b/sys/dev/fdc/fdc.c @@ -58,7 +58,6 @@ #include #include #include -#include #include #include #include @@ -2203,6 +2202,12 @@ retrier(struct fdc_data *fdc) return (1); } +static void +fdbiodone(struct bio *bp) +{ + wakeup(bp); +} + static int fdformat(dev, finfo, p) dev_t dev; @@ -2212,7 +2217,7 @@ fdformat(dev, finfo, p) fdu_t fdu; fd_p fd; - struct buf *bp; + struct bio *bp; int rv = 0, s; size_t fdblk; @@ -2221,36 +2226,34 @@ fdformat(dev, finfo, p) fdblk = 128 << fd->ft->secsize; /* set up a buffer header for fdstrategy() */ - bp = (struct buf *)malloc(sizeof(struct buf), M_TEMP, M_NOWAIT); + bp = (struct bio *)malloc(sizeof(struct bio), M_TEMP, M_NOWAIT); if(bp == 0) - return ENOBUFS; + return ENOMEM; /* * keep the process from being swapped */ PHOLD(p); - bzero((void *)bp, sizeof(struct buf)); - BUF_LOCKINIT(bp); - BUF_LOCK(bp, LK_EXCLUSIVE); - bp->b_flags = B_PHYS; - bp->b_iocmd = BIO_FORMAT; + bzero((void *)bp, sizeof(*bp)); + bp->bio_cmd = BIO_FORMAT; /* * calculate a fake blkno, so fdstrategy() would initiate a * seek to the requested cylinder */ - bp->b_blkno = (finfo->cyl * (fd->ft->sectrac * fd->ft->heads) + bp->bio_blkno = (finfo->cyl * (fd->ft->sectrac * fd->ft->heads) + finfo->head * fd->ft->sectrac) * fdblk / DEV_BSIZE; - bp->b_bcount = sizeof(struct fd_idfield_data) * finfo->fd_formb_nsecs; - bp->b_data = (caddr_t)finfo; + bp->bio_bcount = sizeof(struct fd_idfield_data) * finfo->fd_formb_nsecs; + bp->bio_data = (caddr_t)finfo; /* now do the format */ - bp->b_dev = dev; - DEV_STRATEGY(bp, 0); + bp->bio_dev = dev; + bp->bio_done = fdbiodone; + fdstrategy(bp); /* ...and wait for it to complete */ s = splbio(); - while(!(bp->b_flags & B_DONE)) { + while(!(bp->bio_flags & BIO_DONE)) { rv = tsleep((caddr_t)bp, PRIBIO, "fdform", 20 * hz); if (rv == EWOULDBLOCK) break; @@ -2261,16 +2264,13 @@ fdformat(dev, finfo, p) /* timed out */ rv = EIO; device_unbusy(fd->dev); - biodone(&bp->b_io); /* XXX: HUH ? */ } - if (bp->b_ioflags & BIO_ERROR) - rv = bp->b_error; + if (bp->bio_flags & BIO_ERROR) + rv = bp->bio_error; /* * allow the process to be swapped */ PRELE(p); - BUF_UNLOCK(bp); - BUF_LOCKFREE(bp); free(bp, M_TEMP); return rv; } -- cgit v1.1