From 3cb6be927bd929c0fac02f961c4c912a97c9cd8d Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 10 Mar 2016 06:25:47 +0000 Subject: [PATCH] Don't assume that bio_cmd is a bitfield. Differential Revision: https://reviews.freebsd.org/D5591 --- sys/mips/cavium/octeon_ebt3000_cf.c | 45 +++++++++++++++-------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/sys/mips/cavium/octeon_ebt3000_cf.c b/sys/mips/cavium/octeon_ebt3000_cf.c index 18db10ff7664..8d2b9edcd3dc 100644 --- a/sys/mips/cavium/octeon_ebt3000_cf.c +++ b/sys/mips/cavium/octeon_ebt3000_cf.c @@ -215,37 +215,38 @@ static void cf_start (struct bio *bp) * the bio struct. */ - if(bp->bio_cmd & BIO_GETATTR) { + switch (bp->bio_cmd) { + case BIO_GETATTR: if (g_handleattr_int(bp, "GEOM::fwsectors", cf_priv->drive_param.sec_track)) return; if (g_handleattr_int(bp, "GEOM::fwheads", cf_priv->drive_param.heads)) return; g_io_deliver(bp, ENOIOCTL); return; + + case BIO_READ: + error = cf_cmd_read(bp->bio_length / cf_priv->drive_param.sector_size, + bp->bio_offset / cf_priv->drive_param.sector_size, bp->bio_data); + break; + case BIO_WRITE: + error = cf_cmd_write(bp->bio_length / cf_priv->drive_param.sector_size, + bp->bio_offset/cf_priv->drive_param.sector_size, bp->bio_data); + break; + + default: + printf("%s: unrecognized bio_cmd %x.\n", __func__, bp->bio_cmd); + error = ENOTSUP; + break; } - if ((bp->bio_cmd & (BIO_READ | BIO_WRITE))) { - - if (bp->bio_cmd & BIO_READ) { - error = cf_cmd_read(bp->bio_length / cf_priv->drive_param.sector_size, - bp->bio_offset / cf_priv->drive_param.sector_size, bp->bio_data); - } else if (bp->bio_cmd & BIO_WRITE) { - error = cf_cmd_write(bp->bio_length / cf_priv->drive_param.sector_size, - bp->bio_offset/cf_priv->drive_param.sector_size, bp->bio_data); - } else { - printf("%s: unrecognized bio_cmd %x.\n", __func__, bp->bio_cmd); - error = ENOTSUP; - } - - if (error != 0) { - g_io_deliver(bp, error); - return; - } - - bp->bio_resid = 0; - bp->bio_completed = bp->bio_length; - g_io_deliver(bp, 0); + if (error != 0) { + g_io_deliver(bp, error); + return; } + + bp->bio_resid = 0; + bp->bio_completed = bp->bio_length; + g_io_deliver(bp, 0); }