diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2012-08-16 06:45:52 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2012-08-16 06:45:52 +0000 |
commit | 1cdbcfba9d206cd7a59aec149e1c43d1930ca29d (patch) | |
tree | 63c0d8de7da6fbcb0cfb873f1e7fc51aed6dbfe9 /sys | |
parent | a6a1b02a10d0901cfc35a856166641adfc922c08 (diff) |
stop passing mfi_softc around as a member of the ccb, consistently give it
as the first argument to functions. like mfii.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ic/mfi.c | 66 | ||||
-rw-r--r-- | sys/dev/ic/mfivar.h | 8 |
2 files changed, 34 insertions, 40 deletions
diff --git a/sys/dev/ic/mfi.c b/sys/dev/ic/mfi.c index 3493a214b02..c2ba0bcb7aa 100644 --- a/sys/dev/ic/mfi.c +++ b/sys/dev/ic/mfi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfi.c,v 1.133 2012/08/16 06:05:56 dlg Exp $ */ +/* $OpenBSD: mfi.c,v 1.134 2012/08/16 06:45:51 dlg Exp $ */ /* * Copyright (c) 2006 Marco Peereboom <marco@peereboom.us> * @@ -78,19 +78,20 @@ int mfi_initialize_firmware(struct mfi_softc *); int mfi_get_info(struct mfi_softc *); uint32_t mfi_read(struct mfi_softc *, bus_size_t); void mfi_write(struct mfi_softc *, bus_size_t, uint32_t); -int mfi_poll(struct mfi_ccb *); -int mfi_create_sgl(struct mfi_ccb *, int); +int mfi_poll(struct mfi_softc *, struct mfi_ccb *); +int mfi_create_sgl(struct mfi_softc *, struct mfi_ccb *, int); /* commands */ -int mfi_scsi_ld(struct mfi_ccb *, struct scsi_xfer *); -int mfi_scsi_io(struct mfi_ccb *, struct scsi_xfer *, uint64_t, - uint32_t); -void mfi_scsi_xs_done(struct mfi_ccb *); +int mfi_scsi_ld(struct mfi_softc *sc, struct mfi_ccb *, + struct scsi_xfer *); +int mfi_scsi_io(struct mfi_softc *sc, struct mfi_ccb *, + struct scsi_xfer *, uint64_t, uint32_t); +void mfi_scsi_xs_done(struct mfi_softc *sc, struct mfi_ccb *); int mfi_mgmt(struct mfi_softc *, uint32_t, uint32_t, uint32_t, void *, uint8_t *); int mfi_do_mgmt(struct mfi_softc *, struct mfi_ccb * , uint32_t, uint32_t, uint32_t, void *, uint8_t *); -void mfi_mgmt_done(struct mfi_ccb *); +void mfi_mgmt_done(struct mfi_softc *, struct mfi_ccb *); #if NBIO > 0 int mfi_ioctl(struct device *, u_long, caddr_t); @@ -109,7 +110,7 @@ void mfi_refresh_sensors(void *); #endif /* NBIO > 0 */ void mfi_start(struct mfi_softc *, struct mfi_ccb *); -void mfi_done(struct mfi_ccb *); +void mfi_done(struct mfi_softc *, struct mfi_ccb *); u_int32_t mfi_xscale_fw_state(struct mfi_softc *); void mfi_xscale_intr_ena(struct mfi_softc *); int mfi_xscale_intr(struct mfi_softc *); @@ -233,8 +234,6 @@ mfi_init_ccb(struct mfi_softc *sc) for (i = 0; i < sc->sc_max_cmds; i++) { ccb = &sc->sc_ccb[i]; - ccb->ccb_sc = sc; - /* select i'th frame */ ccb->ccb_frame = (union mfi_frame *) (MFIMEM_KVA(sc->sc_frames) + sc->sc_frames_size * i); @@ -463,7 +462,7 @@ mfi_initialize_firmware(struct mfi_softc *sc) 0, MFIMEM_LEN(sc->sc_pcq), BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - rv = mfi_poll(ccb); + rv = mfi_poll(sc, ccb); mfi_put_ccb(sc, ccb); @@ -791,9 +790,8 @@ nopcq: } int -mfi_poll(struct mfi_ccb *ccb) +mfi_poll(struct mfi_softc *sc, struct mfi_ccb *ccb) { - struct mfi_softc *sc = ccb->ccb_sc; struct mfi_frame_header *hdr; int to = 0, rv = 0; @@ -864,7 +862,7 @@ mfi_intr(void *arg) ccb = &sc->sc_ccb[ctx]; DNPRINTF(MFI_D_INTR, "%s: mfi_intr context %#x\n", DEVNAME(sc), ctx); - mfi_done(ccb); + mfi_done(sc, ccb); claimed = 1; } @@ -883,8 +881,8 @@ mfi_intr(void *arg) } int -mfi_scsi_io(struct mfi_ccb *ccb, struct scsi_xfer *xs, uint64_t blockno, - uint32_t blockcnt) +mfi_scsi_io(struct mfi_softc *sc, struct mfi_ccb *ccb, + struct scsi_xfer *xs, uint64_t blockno, uint32_t blockcnt) { struct scsi_link *link = xs->sc_link; struct mfi_io_frame *io; @@ -918,7 +916,7 @@ mfi_scsi_io(struct mfi_ccb *ccb, struct scsi_xfer *xs, uint64_t blockno, ccb->ccb_data = xs->data; ccb->ccb_len = xs->datalen; - if (mfi_create_sgl(ccb, (xs->flags & SCSI_NOSLEEP) ? + if (mfi_create_sgl(sc, ccb, (xs->flags & SCSI_NOSLEEP) ? BUS_DMA_NOWAIT : BUS_DMA_WAITOK)) return (1); @@ -926,10 +924,9 @@ mfi_scsi_io(struct mfi_ccb *ccb, struct scsi_xfer *xs, uint64_t blockno, } void -mfi_scsi_xs_done(struct mfi_ccb *ccb) +mfi_scsi_xs_done(struct mfi_softc *sc, struct mfi_ccb *ccb) { struct scsi_xfer *xs = ccb->ccb_cookie; - struct mfi_softc *sc = ccb->ccb_sc; struct mfi_frame_header *hdr = &ccb->ccb_frame->mfr_header; DNPRINTF(MFI_D_INTR, "%s: mfi_scsi_xs_done %#x %#x\n", @@ -969,7 +966,7 @@ mfi_scsi_xs_done(struct mfi_ccb *ccb) } int -mfi_scsi_ld(struct mfi_ccb *ccb, struct scsi_xfer *xs) +mfi_scsi_ld(struct mfi_softc *sc, struct mfi_ccb *ccb, struct scsi_xfer *xs) { struct scsi_link *link = xs->sc_link; struct mfi_pass_frame *pf; @@ -1006,7 +1003,7 @@ mfi_scsi_ld(struct mfi_ccb *ccb, struct scsi_xfer *xs) ccb->ccb_data = xs->data; ccb->ccb_len = xs->datalen; - if (mfi_create_sgl(ccb, (xs->flags & SCSI_NOSLEEP) ? + if (mfi_create_sgl(sc, ccb, (xs->flags & SCSI_NOSLEEP) ? BUS_DMA_NOWAIT : BUS_DMA_WAITOK)) return (1); } @@ -1048,7 +1045,7 @@ mfi_scsi_cmd(struct scsi_xfer *xs) rwb = (struct scsi_rw_big *)xs->cmd; blockno = (uint64_t)_4btol(rwb->addr); blockcnt = _2btol(rwb->length); - if (mfi_scsi_io(ccb, xs, blockno, blockcnt)) + if (mfi_scsi_io(sc, ccb, xs, blockno, blockcnt)) goto stuffup; break; @@ -1058,7 +1055,7 @@ mfi_scsi_cmd(struct scsi_xfer *xs) blockno = (uint64_t)(_3btol(rw->addr) & (SRW_TOPADDR << 16 | 0xffff)); blockcnt = rw->length ? rw->length : 0x100; - if (mfi_scsi_io(ccb, xs, blockno, blockcnt)) + if (mfi_scsi_io(sc, ccb, xs, blockno, blockcnt)) goto stuffup; break; @@ -1067,7 +1064,7 @@ mfi_scsi_cmd(struct scsi_xfer *xs) rw16 = (struct scsi_rw_16 *)xs->cmd; blockno = _8btol(rw16->addr); blockcnt = _4btol(rw16->length); - if (mfi_scsi_io(ccb, xs, blockno, blockcnt)) + if (mfi_scsi_io(sc, ccb, xs, blockno, blockcnt)) goto stuffup; break; @@ -1081,7 +1078,7 @@ mfi_scsi_cmd(struct scsi_xfer *xs) /* NOTREACHED */ default: - if (mfi_scsi_ld(ccb, xs)) + if (mfi_scsi_ld(sc, ccb, xs)) goto stuffup; break; } @@ -1089,7 +1086,7 @@ mfi_scsi_cmd(struct scsi_xfer *xs) DNPRINTF(MFI_D_CMD, "%s: start io %d\n", DEVNAME(sc), target); if (xs->flags & SCSI_POLL) { - if (mfi_poll(ccb)) { + if (mfi_poll(sc, ccb)) { /* XXX check for sense in ccb->ccb_sense? */ printf("%s: mfi_scsi_cmd poll failed\n", DEVNAME(sc)); @@ -1119,9 +1116,8 @@ complete: } int -mfi_create_sgl(struct mfi_ccb *ccb, int flags) +mfi_create_sgl(struct mfi_softc *sc, struct mfi_ccb *ccb, int flags) { - struct mfi_softc *sc = ccb->ccb_sc; struct mfi_frame_header *hdr; bus_dma_segment_t *sgd; union mfi_sgl *sgl; @@ -1241,14 +1237,14 @@ mfi_do_mgmt(struct mfi_softc *sc, struct mfi_ccb *ccb, uint32_t opc, ccb->ccb_len = len; ccb->ccb_sgl = &dcmd->mdf_sgl; - if (mfi_create_sgl(ccb, BUS_DMA_WAITOK)) { + if (mfi_create_sgl(sc, ccb, BUS_DMA_WAITOK)) { rv = EINVAL; goto done; } } if (cold) { - if (mfi_poll(ccb)) { + if (mfi_poll(sc, ccb)) { rv = EIO; goto done; } @@ -1279,7 +1275,7 @@ done: } void -mfi_mgmt_done(struct mfi_ccb *ccb) +mfi_mgmt_done(struct mfi_softc *sc, struct mfi_ccb *ccb) { struct mfi_frame_header *hdr = &ccb->ccb_frame->mfr_header; @@ -2042,10 +2038,8 @@ mfi_start(struct mfi_softc *sc, struct mfi_ccb *ccb) } void -mfi_done(struct mfi_ccb *ccb) +mfi_done(struct mfi_softc *sc, struct mfi_ccb *ccb) { - struct mfi_softc *sc = ccb->ccb_sc; - bus_dmamap_sync(sc->sc_dmat, MFIMEM_MAP(sc->sc_frames), ccb->ccb_pframe_offset, sc->sc_frames_size, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); @@ -2059,7 +2053,7 @@ mfi_done(struct mfi_ccb *ccb) bus_dmamap_unload(sc->sc_dmat, ccb->ccb_dmamap); } - ccb->ccb_done(ccb); + ccb->ccb_done(sc, ccb); } u_int32_t diff --git a/sys/dev/ic/mfivar.h b/sys/dev/ic/mfivar.h index c4546cba6e3..4222b5be999 100644 --- a/sys/dev/ic/mfivar.h +++ b/sys/dev/ic/mfivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mfivar.h,v 1.48 2012/08/14 10:44:36 dlg Exp $ */ +/* $OpenBSD: mfivar.h,v 1.49 2012/08/16 06:45:51 dlg Exp $ */ /* * Copyright (c) 2006 Marco Peereboom <marco@peereboom.us> * @@ -15,6 +15,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +struct mfi_softc; #define DEVNAME(_s) ((_s)->sc_dev.dv_xname) /* #define MFI_DEBUG */ @@ -54,8 +55,6 @@ struct mfi_prod_cons { }; struct mfi_ccb { - struct mfi_softc *ccb_sc; - union mfi_frame *ccb_frame; paddr_t ccb_pframe; bus_addr_t ccb_pframe_offset; @@ -79,7 +78,8 @@ struct mfi_ccb { #define MFI_DATA_OUT 2 void *ccb_cookie; - void (*ccb_done)(struct mfi_ccb *); + void (*ccb_done)(struct mfi_softc *, + struct mfi_ccb *); volatile enum { MFI_CCB_FREE, |