Skip to content

Commit

Permalink
Stop assuming that bio_cmd is a bit field.
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.freebsd.org/D5587
  • Loading branch information
bsdimp committed Mar 10, 2016
1 parent 2a2fa54 commit d5aea12
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions sys/dev/fdc/fdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ fdc_worker(struct fdc_data *fdc)
/* Disable ISADMA if we bailed while it was active */
if (fd != NULL && (fd->flags & FD_ISADMA)) {
isa_dmadone(
bp->bio_cmd & BIO_READ ? ISADMA_READ : ISADMA_WRITE,
bp->bio_cmd == BIO_READ ? ISADMA_READ : ISADMA_WRITE,
fd->fd_ioptr, fd->fd_iosize, fdc->dmachan);
mtx_lock(&fdc->fdc_mtx);
fd->flags &= ~FD_ISADMA;
Expand Down Expand Up @@ -983,7 +983,7 @@ fdc_worker(struct fdc_data *fdc)
fd = fdc->fd = bp->bio_driver1;
fdc->retry = 0;
fd->fd_ioptr = bp->bio_data;
if (bp->bio_cmd & BIO_FMT) {
if (bp->bio_cmd == BIO_FMT) {
i = offsetof(struct fd_formb, fd_formb_cylno(0));
fd->fd_ioptr += i;
fd->fd_iosize = bp->bio_length - i;
Expand Down Expand Up @@ -1021,7 +1021,7 @@ fdc_worker(struct fdc_data *fdc)
fdctl_wr(fdc, fd->ft->trans);
#endif

if (bp->bio_cmd & BIO_PROBE) {
if (bp->bio_cmd == BIO_PROBE) {
if ((!(device_get_flags(fd->dev) & FD_NO_CHLINE) &&
#ifndef PC98
!(fdin_rd(fdc) & FDI_DCHG) &&
Expand Down Expand Up @@ -1059,7 +1059,7 @@ fdc_worker(struct fdc_data *fdc)
#endif

/* Check if the floppy is write-protected */
if (bp->bio_cmd & (BIO_FMT | BIO_WRITE)) {
if (bp->bio_cmd == BIO_FMT || bp->bio_cmd == BIO_WRITE) {
retry_line = __LINE__;
if(fdc_sense_drive(fdc, &st3) != 0)
return (1);
Expand All @@ -1078,10 +1078,11 @@ fdc_worker(struct fdc_data *fdc)
sec = sec % fd->ft->sectrac + 1;

/* If everything is going swimmingly, use multisector xfer */
if (fdc->retry == 0 && bp->bio_cmd & (BIO_READ|BIO_WRITE)) {
if (fdc->retry == 0 &&
(bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE)) {
fd->fd_iosize = imin(nsect * fd->sectorsize, bp->bio_resid);
nsect = fd->fd_iosize / fd->sectorsize;
} else if (bp->bio_cmd & (BIO_READ|BIO_WRITE)) {
} else if (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE) {
fd->fd_iosize = fd->sectorsize;
nsect = 1;
}
Expand Down Expand Up @@ -1141,10 +1142,12 @@ fdc_worker(struct fdc_data *fdc)
fd->fd_ioptr, fdc->retry);

/* Setup ISADMA if we need it and have it */
if ((bp->bio_cmd & (BIO_READ|BIO_WRITE|BIO_FMT))
if ((bp->bio_cmd == BIO_READ ||
bp->bio_cmd == BIO_WRITE ||
bp->bio_cmd == BIO_FMT)
&& !(fdc->flags & FDC_NODMA)) {
isa_dmastart(
bp->bio_cmd & BIO_READ ? ISADMA_READ : ISADMA_WRITE,
bp->bio_cmd == BIO_READ ? ISADMA_READ : ISADMA_WRITE,
fd->fd_ioptr, fd->fd_iosize, fdc->dmachan);
mtx_lock(&fdc->fdc_mtx);
fd->flags |= FD_ISADMA;
Expand All @@ -1153,9 +1156,12 @@ fdc_worker(struct fdc_data *fdc)

/* Do PIO if we have to */
if (fdc->flags & FDC_NODMA) {
if (bp->bio_cmd & (BIO_READ|BIO_WRITE|BIO_FMT))
if (bp->bio_cmd == BIO_READ ||
bp->bio_cmd == BIO_WRITE ||
bp->bio_cmd == BIO_FMT)
fdbcdr_wr(fdc, 1, fd->fd_iosize);
if (bp->bio_cmd & (BIO_WRITE|BIO_FMT))
if (bp->bio_cmd == BIO_WRITE ||
bp->bio_cmd == BIO_FMT)
fdc_pio(fdc);
}

Expand Down Expand Up @@ -1218,13 +1224,13 @@ fdc_worker(struct fdc_data *fdc)
i = tsleep(fdc, PRIBIO, "fddata", hz);

/* PIO if the read looks good */
if (i == 0 && (fdc->flags & FDC_NODMA) && (bp->bio_cmd & BIO_READ))
if (i == 0 && (fdc->flags & FDC_NODMA) && (bp->bio_cmd == BIO_READ))
fdc_pio(fdc);

/* Finish DMA */
if (fd->flags & FD_ISADMA) {
isa_dmadone(
bp->bio_cmd & BIO_READ ? ISADMA_READ : ISADMA_WRITE,
bp->bio_cmd == BIO_READ ? ISADMA_READ : ISADMA_WRITE,
fd->fd_ioptr, fd->fd_iosize, fdc->dmachan);
mtx_lock(&fdc->fdc_mtx);
fd->flags &= ~FD_ISADMA;
Expand Down Expand Up @@ -1668,15 +1674,15 @@ fd_start(struct bio *bp)
fd = bp->bio_to->geom->softc;
fdc = fd->fdc;
bp->bio_driver1 = fd;
if (bp->bio_cmd & BIO_GETATTR) {
if (bp->bio_cmd == BIO_GETATTR) {
if (g_handleattr_int(bp, "GEOM::fwsectors", fd->ft->sectrac))
return;
if (g_handleattr_int(bp, "GEOM::fwheads", fd->ft->heads))
return;
g_io_deliver(bp, ENOIOCTL);
return;
}
if (!(bp->bio_cmd & (BIO_READ|BIO_WRITE))) {
if (!(bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE)) {
g_io_deliver(bp, EOPNOTSUPP);
return;
}
Expand Down

0 comments on commit d5aea12

Please sign in to comment.